【问题标题】:VHDL, D-type asynchronous flip flopVHDL,D型异步触发器
【发布时间】:2017-10-08 21:02:30
【问题描述】:

我刚开始学习 vhdl 代码,我为 D 型异步触发器编写了这段代码。我应该如何修改我的代码,使其具有第二个 D 类型,第二个的输入来自第一个的输出?

library ieee;
use ieee.std_logic_1164.all;

entity FLIPFLOP is
port ( 
  clk : in  std_logic ;
  clr : in  std_logic ;
  D   : in  std_logic ;
  Q   : out  std_logic
  );
end FLIPFLOP;

architecture behav of FLIPFLOP is
begin
process (clk,clr,D)
begin
if clr = '1' then
Q<= '0';
elsif rising_edge (clk) then
Q<= D;
end if;
end process;
end behav;

【问题讨论】:

  • 过程敏感度列表中不需要 D。见VHDL D-type asynch flip flop。它被称为移位寄存器。例如,请参阅 Structural design of Shift Register in VHDLDesign a shift register in VHDL
  • process (clk, clr) variable reg: std_logic_vector(1 downto 0);begin if clk = '1' then reg := "00"; elsif rising_edge(clk) then reg := D &amp; reg(1); end if; Q &lt;= reg(0); end process; 如果这不是您想要的,则表明您的问题不清楚,它符合您的所有标准。两个触发器是 reg(1) 和 reg(0)。变量 reg 也可以是一个信号,要求 Q 赋值在另一个进程中(如在一个并发的信号赋值中,它被详细描述为一个进程语句)。

标签: vhdl


【解决方案1】:

我认为您需要编写一个使用 DFF 架构的顶级 VHDL 文件:

entity top is
port (
  clk: in std_logic;
  clr: in std_logic;
  some_input_signal: in std_logic;
  some_output_signal: out std_logic
);
end top;

architecture rtl of top is
  signal x: std_logic;
begin
  e1: entity work.FLIPFLOP
  port map (
    clk => clk,
    clr => clr,
    D => some_input_signal,
    Q => x );

  e2: entity work.FLIPFLOP
  port map (
    clk => clk,
    clr => clr,
    D => x,
    Q => some_output_signal );
end;

x是第一个DFF输出并输入第二个DFF的信号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-07
    相关资源
    最近更新 更多