cudaqi.vhd

来自「一些很好的FPGA设计实例」· VHDL 代码 · 共 44 行

VHD
44
字号
-----------------方案1:not_ok-----------------------
library ieee;
use ieee.std_logic_1164.all;
------------------------------------------------------
entity cudaqi is
  port( d,clk: in std_logic;
           q: buffer std_logic;
           qbar: out std_logic);
end cudaqi;
-------------------------------------------------------
architecture not_ok of cudaqi is 
  begin 
   process(clk)
  begin 
   if (clk 'event and clk ='1')then
     q<= d;
     qbar<= not q;-- 因为q的值还没有更新,所以qbar是将以前的q值取反后输出
   end if;--正确的qbar值输出会延时一个时钟周期
 end process;
end not_ok;
--------------------------------------------------------


-----------------方案2:ok--------------------------------
library ieee;
use ieee.std_logic_1164.all;
------------------------------------------------------
entity cudaqi is
  port( d,clk: in std_logic;
           q: buffer std_logic;
           qbar: out std_logic);
end cudaqi;
-------------------------------------------------------
architecture ok of cudaqi is 
  begin 
   process(clk)
  begin 
   if (clk 'event and clk ='1')then
     q<= d;
    end if;
end process;
     qbar<= not q;-- 放到进程以外,与进程是并发的,当q 发生变化后,qbar的值立即可以实现更新
end ok;
-------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?