测试台不工作
Testbench not working
以下测试平台无法为 QAU 和 QBU 提供预期信号:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY VHDLfinal_vhd_tst IS
END VHDLfinal_vhd_tst;
ARCHITECTURE VHDLfinal_arch OF VHDLfinal_vhd_tst IS
-- constants
CONSTANT clk_period : TIME := 20 ns;
CONSTANT num_clk_cycles : INTEGER := 100;
CONSTANT n_period : TIME := 80 ns;
CONSTANT n_cycles : INTEGER := 50;
-- signals
SIGNAL CLOCK_50 : STD_LOGIC := '0';
SIGNAL LOAD : STD_LOGIC;
SIGNAL Number : STD_LOGIC_VECTOR(0 TO 7);
SIGNAL Q : STD_LOGIC_VECTOR(0 TO 7);
SIGNAL QAU : STD_LOGIC;
SIGNAL QBU : STD_LOGIC;
SIGNAL Reset : STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL TEST_A : STD_LOGIC;
SIGNAL TEST_Ap : STD_LOGIC;
SIGNAL TEST_B : STD_LOGIC;
SIGNAL TEST_Bp : STD_LOGIC;
SIGNAL TEST_Count : STD_LOGIC;
COMPONENT VHDLfinal
PORT (
CLOCK_50 : IN STD_LOGIC;
LOAD : IN STD_LOGIC;
Number : IN STD_LOGIC_VECTOR(0 TO 7);
Q : OUT STD_LOGIC_VECTOR(0 TO 7);
QAU : IN STD_LOGIC;
QBU : IN STD_LOGIC;
Reset : IN STD_LOGIC_VECTOR(2 DOWNTO 0);
TEST_A : OUT STD_LOGIC;
TEST_Ap : OUT STD_LOGIC;
TEST_B : OUT STD_LOGIC;
TEST_Bp : OUT STD_LOGIC;
TEST_Count : OUT STD_LOGIC
);
END COMPONENT;
BEGIN
i1 : VHDLfinal
PORT MAP (
-- list connections between master ports and signals
CLOCK_50 => CLOCK_50,
LOAD => LOAD,
Number => Number,
Q => Q,
QAU => QAU,
QBU => QBU,
Reset => Reset,
TEST_A => TEST_A,
TEST_Ap => TEST_Ap,
TEST_B => TEST_B,
TEST_Bp => TEST_Bp,
TEST_Count => TEST_Count
);
init1 : PROCESS
BEGIN
Reset(0) <= '0',
'1' after 415 ns, -- Reset the Clock
'0' after 815 ns;
Reset(1) <= '0',
'1' after 415 ns, -- Reset the Decoder
'0' after 815 ns;
Reset(2) <= '0',
'1' after 415 ns, -- Reset the counter
'0' after 815 ns;
WAIT;
END PROCESS init1;
init2 : PROCESS
BEGIN
-- Clock Generation
for i in 1 to num_clk_cycles loop
CLOCK_50 <= not CLOCK_50;
wait for clk_period/2;
CLOCK_50 <= not CLOCK_50;
wait for clk_period/2;
end loop;
WAIT;
END PROCESS init2;
init3 : PROCESS
BEGIN
for j in 1 to n_cycles loop
QAU <= not QAU;
wait for n_period;
QAU <= not QAU;
wait for n_period;
end loop;
WAIT;
END PROCESS init3;
init4 : PROCESS
BEGIN
for k in 1 to n_cycles loop
QBU <= not QBU;
wait for n_period/2;
QBU <= not QBU;
wait for n_period/2;
end loop;
WAIT;
END PROCESS init4;
always : PROCESS
-- optional sensitivity list
-- ( )
-- variable declarations
BEGIN
-- -- code executes for every event on sensitivity list
WAIT;
END PROCESS always;
END VHDLfinal_arch;
循环过程对于 CLOCK_50
信号似乎工作正常,我为 Reset
提供的说明也工作正常。只是 QAU
和 QBU
信号不起作用,因此,我的 Q
信号是我的输出。
有什么原因吗?
您对遇到问题的两个刺激信号的声明看起来像 SIGNAL QAU : STD_LOGIC;
。当您对这个未初始化的信号 ('U'
) 执行 not
时,结果是 'X'
。如果您像这样 SIGNAL QAU : STD_LOGIC := '0';
声明您的信号,该信号应该在您的测试台中按您预期的那样切换。您可能已经意识到这一点,因为您已经为 CLOCK_50
信号做到了。
以下测试平台无法为 QAU 和 QBU 提供预期信号:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY VHDLfinal_vhd_tst IS
END VHDLfinal_vhd_tst;
ARCHITECTURE VHDLfinal_arch OF VHDLfinal_vhd_tst IS
-- constants
CONSTANT clk_period : TIME := 20 ns;
CONSTANT num_clk_cycles : INTEGER := 100;
CONSTANT n_period : TIME := 80 ns;
CONSTANT n_cycles : INTEGER := 50;
-- signals
SIGNAL CLOCK_50 : STD_LOGIC := '0';
SIGNAL LOAD : STD_LOGIC;
SIGNAL Number : STD_LOGIC_VECTOR(0 TO 7);
SIGNAL Q : STD_LOGIC_VECTOR(0 TO 7);
SIGNAL QAU : STD_LOGIC;
SIGNAL QBU : STD_LOGIC;
SIGNAL Reset : STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL TEST_A : STD_LOGIC;
SIGNAL TEST_Ap : STD_LOGIC;
SIGNAL TEST_B : STD_LOGIC;
SIGNAL TEST_Bp : STD_LOGIC;
SIGNAL TEST_Count : STD_LOGIC;
COMPONENT VHDLfinal
PORT (
CLOCK_50 : IN STD_LOGIC;
LOAD : IN STD_LOGIC;
Number : IN STD_LOGIC_VECTOR(0 TO 7);
Q : OUT STD_LOGIC_VECTOR(0 TO 7);
QAU : IN STD_LOGIC;
QBU : IN STD_LOGIC;
Reset : IN STD_LOGIC_VECTOR(2 DOWNTO 0);
TEST_A : OUT STD_LOGIC;
TEST_Ap : OUT STD_LOGIC;
TEST_B : OUT STD_LOGIC;
TEST_Bp : OUT STD_LOGIC;
TEST_Count : OUT STD_LOGIC
);
END COMPONENT;
BEGIN
i1 : VHDLfinal
PORT MAP (
-- list connections between master ports and signals
CLOCK_50 => CLOCK_50,
LOAD => LOAD,
Number => Number,
Q => Q,
QAU => QAU,
QBU => QBU,
Reset => Reset,
TEST_A => TEST_A,
TEST_Ap => TEST_Ap,
TEST_B => TEST_B,
TEST_Bp => TEST_Bp,
TEST_Count => TEST_Count
);
init1 : PROCESS
BEGIN
Reset(0) <= '0',
'1' after 415 ns, -- Reset the Clock
'0' after 815 ns;
Reset(1) <= '0',
'1' after 415 ns, -- Reset the Decoder
'0' after 815 ns;
Reset(2) <= '0',
'1' after 415 ns, -- Reset the counter
'0' after 815 ns;
WAIT;
END PROCESS init1;
init2 : PROCESS
BEGIN
-- Clock Generation
for i in 1 to num_clk_cycles loop
CLOCK_50 <= not CLOCK_50;
wait for clk_period/2;
CLOCK_50 <= not CLOCK_50;
wait for clk_period/2;
end loop;
WAIT;
END PROCESS init2;
init3 : PROCESS
BEGIN
for j in 1 to n_cycles loop
QAU <= not QAU;
wait for n_period;
QAU <= not QAU;
wait for n_period;
end loop;
WAIT;
END PROCESS init3;
init4 : PROCESS
BEGIN
for k in 1 to n_cycles loop
QBU <= not QBU;
wait for n_period/2;
QBU <= not QBU;
wait for n_period/2;
end loop;
WAIT;
END PROCESS init4;
always : PROCESS
-- optional sensitivity list
-- ( )
-- variable declarations
BEGIN
-- -- code executes for every event on sensitivity list
WAIT;
END PROCESS always;
END VHDLfinal_arch;
循环过程对于 CLOCK_50
信号似乎工作正常,我为 Reset
提供的说明也工作正常。只是 QAU
和 QBU
信号不起作用,因此,我的 Q
信号是我的输出。
有什么原因吗?
您对遇到问题的两个刺激信号的声明看起来像 SIGNAL QAU : STD_LOGIC;
。当您对这个未初始化的信号 ('U'
) 执行 not
时,结果是 'X'
。如果您像这样 SIGNAL QAU : STD_LOGIC := '0';
声明您的信号,该信号应该在您的测试台中按您预期的那样切换。您可能已经意识到这一点,因为您已经为 CLOCK_50
信号做到了。