【问题标题】:digital circuit scheme to vhdl ring counter multiplexervhdl环形计数器多路复用器的数字电路方案
【发布时间】:2014-11-28 23:51:38
【问题描述】:

我有这个电路,我想在 vhdl 中实现。有一个时钟输入,哪个时钟事件依次改变1 引脚输出。 0001 -> 0010 -> 0100 -> 1000 ...

我想知道这样做的正确方法是什么。我可以用多个 ifs 和 elsifs 以及一个整数计数器信号来做到这一点。抱歉这个菜鸟问题,这种电路有名字吗?

【问题讨论】:

  • 可能正在寻找“约翰逊计数器”。搜索并自己决定。

标签: vhdl hdl


【解决方案1】:

根据您的描述,这似乎是一个环形计数器。你的门似乎是多余的:

library ieee;
use ieee.std_logic_1164.all;

entity ring_counter is
    port (
        clk:    in  std_logic;
        q:      out std_logic_vector (0 to 3)
    );
end entity;

architecture your_representation of ring_counter is
    signal qint: std_logic_vector (0 to 3) := "0000";
    signal all_zero:        std_logic;
begin
YOURS:
    process(clk)
    begin
        if rising_edge(clk) then
            qint(0) <= qint(3);
            qint(1) <= all_zero or qint(0);
            qint (2 to 3) <= qint(1 to 2);
        end if;
    end process;

    all_zero <= '1' when qint = "0000" else
                '0';

    q <= (qint(0) or all_zero) & qint(1 to 3);
end architecture;

带有测试台:

library ieee;
use ieee.std_logic_1164.all;

entity ring_counter_tb is
end entity;

architecture foo of ring_counter_tb is
    signal clk:     std_logic := '0';
    signal q:       std_logic_vector(0 to 3);
begin
DUT:
    entity work.ring_counter(your_representation)
        port map (
            clk => clk,
            q => q
        );
CLOCK:
    process
    begin
        wait for 10 ns;
        clk <= not clk;
        if Now > 200 ns then
            wait;
        end if;
    end process;

end architecture;

给予:

(可点击)

虽然是经典的环形计数器:

architecture classic of ring_counter is
    signal qint: std_logic_vector (0 to 3) := "1000";
begin
RING_CTR:
    process(clk)
    begin
        if rising_edge(clk) then
            qint <= qint(3) & qint(0 to 2);
        end if;
    end process;

    q <= qint;

end architecture;

(和修改后的测试台):

    entity work.ring_counter(classic)

给予:

(可点击)

而且起始阶段都处于初始状态。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    • 1970-01-01
    相关资源
    最近更新 更多