Testbench无法正常工作

时间:2016-06-08 10:05:09

标签: vhdl modelsim quartus test-bench

以下测试台未能为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的指令工作正常。它只是QAUQBU信号不起作用,因此我的Q信号是我的输出。

有什么原因吗?

1 个答案:

答案 0 :(得分:1)

您对两个刺激信号的声明表示您遇到问题SIGNAL QAU : STD_LOGIC;。当您对此未初始化信号(not)执行'U'时,结果为'X'。如果您将此信号声明为SIGNAL QAU : STD_LOGIC := '0';,则信号应按预期在您的测试平台中切换。您可能已经意识到这一点,正如您为CLOCK_50信号所做的那样。