AHDL中的4位计数器

问题描述

我必须在AHDL中编写4位计数器。 我以前从未与AHDL联系过。

任务是:

请在电路中实现一个4位数计数器(BCD计数) Cyclone IV EP3CE115F29C7 FPGA是调试的核心 系统来自Derasic的De2-115。

计数器应与1Hz时钟一起工作,以便能够观察状态变化 显示在开发套件中。 七段解码器的输出应连接到适当的 使用FPGA引脚实现显示控制。

最终程序应允许FPGA编程和观察 反算。

我在VHDL中有类似的东西。你们能帮助我如何将其重写为Altera吗? 可能有转换器吗?我看到了类似的内容,但仅从AHDL到VHDL。 我将感谢所有提示。

  library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity bcd_counter is
    generic (
    width : integer := 4
    );
    port (
    clk : in std_logic;
    enable : in std_logic;
    reset : in std_logic;
    output : out std_logic_vector(width - 1 downto 0)
    );
end entity bcd_counter;

architecture behaviour of bcd_counter is
 signal state : unsigned (2 ** width - 1 downto 0);
begin
output <= std_logic_vector(state);
count : process(clk,reset,enable)
begin
  if(reset = '0') then
    state <= (others=> '0');
  elsif(rising_edge(clk) and enable = '1') then
        state <= state + 1;
  end if;
end process count;
end architecture behaviour;

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity counter_logic is
    generic (
    digits : integer := 4
    );
    port (
    clk : in std_logic;
    reset : in std_logic;
    output : out std_logic_vector (4 * digits - 1 downto 0)
    );
end entity counter_logic;

architecture behaviour of counter_logic is
 constant digitWidth : integer := 4;
 signal state : std_logic_vector(digitWidth * digits -1 downto 0);
 signal resetLines : std_logic_vector(digits - 1 downto 0);
 signal enableLines : std_logic_vector(digits - 1 downto 0);
 component bcd_counter is
    generic (
    width : integer := 4
    );
    port (
    clk : in std_logic;
    enable : in std_logic;
    reset : in std_logic;
    output : out std_logic_vector(width - 1 downto 0)
    );
 end component;
begin
counters: for i in digits - 1 downto 0 generate
 nthCounter : bcd_counter 
 generic map (width => digitWidth)
 port map (
  clk => clk,enable => enableLines(i),reset => resetLines(i),--przypisanie wyjść liczników do linii
  output => state((i + 1) * digitWidth - 1 downto i * digitWidth)
 );
 resetLines(i) <= (not state(i * digitWidth) and state(i * digitWidth + 1) and state(i * digitWidth + 2) and not state(i * digitWidth + 3)) or reset;
end generate counters;
--TODO: add if generate for case of single digit counter
enableLinesCondition: if digitWidth > 1 generate
lines: for i in digits - 2 downto 0 generate
 enableLines(i + 1) <= not state(i * digitWidth) and state(i * digitWidth + 1) and state(i * digitWidth + 2) and not state(i * digitWidth + 3);
end generate lines;
end generate enableLinesCondition;
enableLines(0) <= '1';
output <= state;
end architecture behaviour;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...