Changeset 8218

Show
Ignore:
Timestamp:
08/27/08 13:03:39 (5 years ago)
Author:
mcarrick
Message:

adding automated testing

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/mcarrick/VHDL/reg/reg_tb.vhd

    r8203 r8218  
    33library ieee; 
    44use ieee.std_logic_1164.all; 
     5use ieee.numeric_std.all; 
    56 
    67entity reg_tb is 
     
    2223        end component reg; 
    2324 
    24  
    25         signal DATAIN, DATAOUT : std_logic_vector(3 downto 0); 
     25        signal DATAIN : std_logic_vector(3 downto 0) := (others => '0'); 
     26        signal DATAOUT : std_logic_vector(3 downto 0); 
    2627        signal CHIPENABLE, RESET : std_logic; 
    2728        signal CLOCK : std_logic := '0'; 
     
    4142                        ); 
    4243 
    43  
    44  
    4544                        run_clock : process 
    4645                        begin 
     
    5049                 
    5150                        enter_inputs : process 
     51                                variable errors : boolean; 
     52 
    5253                        begin 
    53                                 -- test inputs 
    54                                 wait for 10 ns; 
     54 
     55                                -- reset chip, set enable 
     56                                RESET <= '1'; 
    5557                                CHIPENABLE <= '1'; 
     58                                wait for 30 ns; 
     59                                 
    5660                                RESET <= '0'; 
    57                                 DATAIN <= x"0"; 
    5861 
    59                                 wait for 20 ns; 
    60                                 DATAIN <= x"1"; 
    61                          
    62                                 wait for 20 ns; 
    63                                 DATAIN <= x"2"; 
    64                          
    65                                 wait for 20 ns; 
    66                                 DATAIN <= x"3"; 
     62                                for i in 0 to 15 loop 
    6763 
    68                                 -- test the chip enable 
    69                                 wait for 20 ns; 
    70                                 CHIPENABLE <= '0'; 
     64                                        DATAIN <= std_logic_vector(unsigned(DATAIN) + 1); 
     65                                        wait for 20 ns; 
    7166 
    72                                 wait for 20 ns; 
    73                                 DATAIN <= x"4"; 
    74                          
    75                                 wait for 20 ns; 
    76                                 DATAIN <= x"5"; 
    77                          
    78                                 wait for 20 ns; 
    79                                 DATAIN <= x"6"; 
    80                          
    81                                 -- test the reset 
    82                                 wait for 20 ns; 
    83                                 RESET <= '1'; 
    84                                 DATAIN <= x"7"; 
    85                          
    86                                 wait for 20 ns; 
    87                                 DATAIN <= x"8"; 
    88                          
    89                                 wait for 20 ns; 
    90                                 CHIPENABLE <= '1'; 
    91                                 RESET <= '1'; 
    92                                 DATAIN <= x"9"; 
    93                          
    94                                 wait for 20 ns; 
    95                                 RESET <= '0'; 
    96                                 DATAIN <= x"A"; 
    97                          
    98                                 wait for 20 ns; 
    99                                 DATAIN <= x"B"; 
     67                                        if (DATAIN /= DATAOUT) then 
     68                                                report "DATAIN does not equal DATAOUT"; 
     69                                        end if; 
     70 
     71                                end loop; 
     72 
     73                                assert errors 
     74                                        report "Test failed." 
     75                                        severity error; 
     76                                assert not(errors) 
     77                                        report "Test Passed." 
     78                                        severity note; 
     79 
     80                                wait; 
    10081 
    10182                        end process enter_inputs; 
     
    10687 
    10788 
     89