Eecs 318 Cad Computer Aided Design
Eecs 318 Cad Computer Aided Design
LECTURE 3: LECTURE 3: The VHDL N-bit Adder The VHDL N-bit Adder
Instructor: Francis G. Wolff [email protected] Case Western Reserve University CWRU EECS 318
IN std_logic; IN std_logic; OUT std_logic OUT std_logic Optional Entity END name; Optional Entity END name; Architecture Declaration Architecture Declaration
ARCHITECTURE full_adder_arch_1 OF full_adder IS ARCHITECTURE full_adder_arch_1 OF full_adder IS BEGIN BEGIN Sum <= ((((x XOR y ))XOR z ); Sum <= x XOR y XOR z ); Carry <= (( x AND y ))OR (z AND (x AND y))); Carry <= (( x AND y OR (z AND (x AND y))); END full_adder_arch_1; END full_adder_arch_1; Optional Architecture END name; Optional Architecture END name;
CWRU EECS 318
SIGNAL
Like variables in a programming language such as C, signals can be assigned values, e.g. 0, 1
For example
wave <= 0, 1 after 10 ns, 0 after 15 ns, 1 after 25 ns;
ARCHITECTURE full_adder_arch_2 OF full_adder IS ARCHITECTURE full_adder_arch_2 OF full_adder IS SIGNAL S1, S2, S3: std_logic; SIGNAL S1, S2, S3: std_logic; Signals (like wires) Signals (like wires) BEGIN BEGIN are not PORTs they s1 after 15 ns; are not PORTs they s1 <= ((a XOR b )) <= a XOR b after 15 ns; s2 do not have s2 <= ((c_in AND s1 ))after 5 ns; <= c_in AND s1 after 5 ns; do not have s3 after 5 ns; direction s3 <= ((a AND b )) <= a AND b after 5 ns; direction Sum <= ((s1 XOR c_in ))after 15 ns; Sum <= s1 XOR c_in after 15 ns; (i.e. IN, OUT) (i.e. IN, OUT) Carry <= ((s2 OR s3 )) after 5 ns; Carry <= s2 OR s3 after 5 ns; END; END; CWRU EECS 318
No, No, this this is is not not C! C! NetNetlists lists have have same same beha beha vior vior & & paral paral lel lel
CWRU EECS 318
IN std_logic; IN std_logic; IN std_logic; IN std_logic; OUT std_logic; OUT std_logic; OUT std_logic OUT std_logic
FA1: full_adder PORT FA1: full_adder PORT MAP (Cin=>x, a0=>y, b0=>z, S0=>Sum, t1=>Carry); MAP (Cin=>x, a0=>y, b0=>z, S0=>Sum, t1=>Carry); FA1: full_adder PORT FA1: full_adder PORT MAP (Cin=>x, a0=>y, b0=>z, t1=>Carry, S0=>Sum); MAP (Cin=>x, a0=>y, b0=>z, t1=>Carry, S0=>Sum); FA1: full_adder PORT FA1: full_adder PORT MAP (t1=>Carry, S0=>Sum, a0=>y, b0=>z, Cin=>x); MAP (t1=>Carry, S0=>Sum, a0=>y, b0=>z, Cin=>x);
CWRU EECS 318
std_vectors make it easier to replicate structures std_vectors make it easier to replicate structures
CWRU EECS 318
ARCHITECTURE ripple_n_arch OF adder_bits_n IS COMPONENT full_adder PORT (x, y, z: IN std_logic; Sum, Carry: OUT std_logic); END COMPONENT; SIGNAL t: std_logic_vector(n downto 0); BEGIN t(0) <= Cin; Cout <= t(n); FA: for i in 0 to n-1 generate FA_i: full_adder PORT MAP (t(i), a(i), b(i), S(i), t(i+1)); end generate; END;
CWRU EECS 318
BEGIN x <= 0000, 0001 after 50 ns, 0101, after 100 ns; y <= 0010, 0011 after 50 ns, 1010, after 100 ns; c <= 1, 0 after 50 ns; Override UUT_ADDER_4: adder_bits_n GENERIC MAP(4) Override default default PORT MAP (c, x, y, Sum, Cout); END;
The output of the testbench will be observe by the digital waveform of the simulator.