Show
Ignore:
Timestamp:
08/28/08 14:15:18 (5 years ago)
Author:
mcarrick
Message:

added automated testing

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/mcarrick/VHDL/carry_lookahead_adder/carry_lookahead_adder_tb.vhd

    r8216 r8225  
    33library ieee; 
    44use ieee.std_logic_1164.all; 
     5use ieee.numeric_std.all; 
    56 
    67entity test_CLA is 
     
    2021        end component carry_lookahead_adder; 
    2122         
    22         signal A, B, S : std_logic_vector(3 downto 0); 
     23        signal A, B : std_logic_vector(3 downto 0) := (others => '0'); 
     24        signal S : std_logic_vector(3 downto 0); 
    2325        signal CIN, COUT : std_logic; 
    24          
     26 
     27        signal result : std_logic_vector(4 downto 0); 
     28        signal check : std_logic_vector(4 downto 0); 
     29 
    2530        begin 
    2631 
     
    3540                        ); 
    3641 
     42                -- calculate 5 bit result from circuit 
     43                result <= COUT & S; 
     44                -- calculate 5 bit result independently 
     45                check <= std_logic_vector(unsigned("0" & A) + unsigned("0" & B) + ("000" & CIN)); 
     46 
    3747                enter_inputs : process 
    3848                begin 
    3949 
    40                         A <= x"0"; 
    41                         B <= x"0"; 
    42                         CIN <= '0'; 
     50                        -- loop for CIN 
     51                        for i in 0 to 1 loop 
    4352 
    44                         wait for 5 ns; 
    45                         A <= x"0"; 
    46                         B <= x"1"; 
    47                         CIN <= '1'; 
     53                                -- set CIN test values 
     54                                if (i = 0) then 
     55                                        CIN <= '0'; 
     56                                else 
     57                                        CIN <= '1'; 
     58                                end if; 
     59                         
     60                                -- loop for A 
     61                                for iA in 0 to 15 loop 
    4862 
    49                         wait for 5 ns; 
    50                         A <= x"2"; 
    51                         B <= x"2"; 
    52                         CIN <= '0'; 
     63                                        if (iA = 0) then 
     64                                                A <= (others => '0'); 
     65                                        elsif (iA > 0) then 
     66                                                A <= std_logic_vector(unsigned(A) + 1); 
     67                                        end if; 
    5368 
    54                         wait for 5 ns; 
    55                         A <= x"F"; 
    56                         B <= x"1"; 
    57                         CIN <= '0'; 
     69                                        -- loop for B 
     70                                        for iB in 0 to 15 loop 
     71                                         
     72                                                if (iB = 0) then 
     73                                                        B <= (others => '0'); 
     74                                                elsif (iB > 0) then 
     75                                                        B <= std_logic_vector(unsigned(B) + 1); 
     76                                                end if; 
    5877 
    59                         wait for 5 ns; 
    60                         A <= x"F"; 
    61                         B <= x"F"; 
    62                         CIN <= '1'; 
     78                                                wait for 1 ns; 
    6379 
    64                         wait for 5 ns; 
    65                         A <= x"A"; 
    66                         B <= x"5"; 
    67                         CIN <= '1'; 
     80                                                if (check /= result) then 
     81                                                        report "The summation has been calculated incorrectly!"; 
     82                                                end if; 
    6883 
    69                         wait for 5 ns; 
     84                                        end loop; 
     85 
     86                                end loop; 
     87 
     88                        end loop; 
    7089 
    7190                end process enter_inputs; 
     
    7493 
    7594 
    76          
    7795 
     96