【发布时间】:2013-11-04 01:33:51
【问题描述】:
所以,我一直在做一些 VHDL 作业,但我的测试台遇到了一些问题。基本上,我的测试台正在运行许多触发器的不同可能性。但是,由于其中一个人字拖导致我不断得到“U”,虽然我确切地知道原因,但我不知道如何解决它。
基本上,对于我的 T 触发器,由于在执行 XOR 操作时未设置 Q,因此程序永远不会在 XOR 操作之后为 Q 赋值。所以基本上,如果 Q 尚未定义,我需要一种将 Q 设置为 0 的方法。
仅供参考,这是我的 T 触发器代码
library ieee;
use ieee.std_logic_1164.all;
entity T_FF is
port (
T, clk : in std_logic;
Q : inout std_logic);
end T_FF;
architecture behv of T_FF is
begin
process (clk) is
variable hold1, hold2 : std_logic;
begin
if (clk'event) then
hold1 := Q and (not T);
hold2 := T and (not Q);
Q <= hold1 or hold2;
end if;
end process;
end behv;
还有测试台:
library ieee;
use ieee.std_logic_1164.all;
entity tb is
end tb;
architecture behv of tb is
-- Component declaration
component T_FF is
port (
T, clk : in std_logic;
Q : inout std_logic);
end component;
signal sT : std_logic :='0';
signal sclk : std_logic :='0';
signal sQT : std_logic :='0';
for TFF : T_FF use entity work.T_FF(behv);
begin
TFF: T_FF port map (T=>sT, clk=>sclk, Q=>sQT);
sclk <= not sclk after 50 ns;
sT <= not sT after 100 ns;
end;
【问题讨论】:
-
欢迎来到 Stack Overflow!您的问题可能更适合 electronics.stackexchange.com,我们的姊妹网站之一。