Changeset 8225 for ossiedev/branches/mcarrick/VHDL/carry_lookahead_adder/carry_lookahead_adder_tb.vhd
- Timestamp:
- 08/28/08 14:15:18 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/mcarrick/VHDL/carry_lookahead_adder/carry_lookahead_adder_tb.vhd
r8216 r8225 3 3 library ieee; 4 4 use ieee.std_logic_1164.all; 5 use ieee.numeric_std.all; 5 6 6 7 entity test_CLA is … … 20 21 end component carry_lookahead_adder; 21 22 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); 23 25 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 25 30 begin 26 31 … … 35 40 ); 36 41 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 37 47 enter_inputs : process 38 48 begin 39 49 40 A <= x"0"; 41 B <= x"0"; 42 CIN <= '0'; 50 -- loop for CIN 51 for i in 0 to 1 loop 43 52 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 48 62 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; 53 68 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; 58 77 59 wait for 5 ns; 60 A <= x"F"; 61 B <= x"F"; 62 CIN <= '1'; 78 wait for 1 ns; 63 79 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; 68 83 69 wait for 5 ns; 84 end loop; 85 86 end loop; 87 88 end loop; 70 89 71 90 end process enter_inputs; … … 74 93 75 94 76 77 95 96