【发布时间】:2015-05-23 07:15:01
【问题描述】:
library ieee;
use ieee.std_logic_1164.all;
entity ccou is
port(clk2 : in bit;
qc: out bit_vector(3 downto 0);
qnc: out bit_vector(3 downto 0));
end entity;
architecture a_ccou of ccou is
component dfff
port(d,clk1:in bit;
qd,qnd:out bit);
end component;
signal tqc,tqnc: bit_vector(3 downto 0);
begin
g1 : dfff port map(tqnc(3),clk2,tqc(0),tqnc(0));
g2 : dfff port map(tqc(0),clk2,tqc(1),tqnc(1));
g3 : dfff port map(tqc(1),clk2,tqc(2),tqnc(2));
g4 : dfff port map(tqc(2),clk2,tqc(3),tqnc(3));
qc(3 downto 0) <= tqc(3 downto 0);
qnc(3 downto 0) <= tqnc(3 downto 0);
end architecture;
我使用结构建模设计了一个环形计数器,以d触发器为组件。问题是程序进入无限循环。我尝试将 tqnc(3) 替换为“1”或“0”,程序运行有限时间但输出错误。有什么问题,帮我解决一下。
sr 触发器的代码是
library ieee;
use ieee.std_logic_1164.all;
entity srfff is
port(s,r,clk: in bit;
q,qn:out bit);
end srfff;
architecture a_srff of srfff is
component nnand
port(a,b:in bit;
c:inout bit);
end component;
signal ts,tr : bit;
signal tq,tqn: bit;
begin
g1 : nnand port map(s,clk,ts);
g2 : nnand port map(r,clk,tr);
g3 : nnand port map(ts,tqn,tq);
g4 : nnand port map(tr,tq,tqn);
q <= tq;
qn <=tqn;
end a_srff;
【问题讨论】:
-
为什么你的 DFF 输出 qd、qnd inout 而不是只输出? CCOU 输出也一样...
-
基本上我从一个带有门级设计的 sr ff 开发了 dff,其中 q 和 qn 用作第一个与非门的输入,因此它们被声明为 inout,我将发布电路构造了一个 sr ff,然后我将 d 的值取反为 r 输入。
-
你真的不应该使用
inout,这意味着合成并不总是支持三态缓冲区(顶层除外)。正确的做法是在你的架构中为端口使用一个信号,并添加分配qd <= qd_i;。 -
@Jonathan Drolet,我改变了模式,但模拟再次进入无限循环,输出波形为 1111,但是当我通过 '1' 而不是 cqnd 我得到输出,即 1111。