简体   繁体   English

VHDL,D型异步触发器

[英]VHDL, D-type asynchronous flip flop

I just started learning vhdl code and i wrote this code for a D type asynch flip flop. 我刚刚开始学习vhdl代码,并为D型异步触发器编写了此代码。 How should i modify my code so that it has a second D-type, with the input to the second being fed from the output of the first?. 我应该如何修改我的代码,使其具有第二种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;

I think you need to write a top level VHDL file which uses you DFF architecture: 我认为您需要编写一个使用您的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 is the signal which is outputed by the first DFF and inputed to the second DFF. x是由第一DFF输出并输入到第二DFF的信号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM