-- (C) David Vajda -- 2024-11-30 -- Ripple Carry Chain Adder library ieee; use ieee.std_logic_1164.all; entity fulladder20241130 is port ( a: in std_logic; b: in std_logic; c: out std_logic; s: out std_logic; t: in std_logic ); end; architecture behaviour of fulladder20241130 is begin c <= (a xor b xor t); s <= (a and b) or ((a or b) and t); end; library ieee; use ieee.std_logic_1164.all; entity ripplecarrychainadder20241130 is port ( a3, a2, a1, a0: in std_logic; b3, b2, b1, b0: in std_logic; c3, c2, c1, c0: out std_logic; s: out std_logic; t: in std_logic ); end; architecture behaviour of ripplecarrychainadder20241130 is component fulladder20241130 port ( a: in std_logic; b: in std_logic; c: out std_logic; s: out std_logic; t: in std_logic ); end component; signal s3, s2, s1: std_logic; begin fa4: fulladder20241130 PORT MAP (c=>c3, b=>b3, a=>a3, t=>s3, s=>s); fa3: fulladder20241130 PORT MAP (c=>c2, b=>b2, a=>a2, t=>s2, s=>s3); fa2: fulladder20241130 PORT MAP (c=>c1, b=>b1, a=>a1, t=>s1, s=>s2); fa1: fulladder20241130 PORT MAP (c=>c0, b=>b0, a=>a0, t=>t, s=>s1); end; library ieee; use ieee.std_logic_1164.all; entity ripplecarrychainadder20241130testbench is port ( c3, c2, c1, c0: out std_logic; s: out std_logic ); end; architecture behaviour of ripplecarrychainadder20241130testbench is component ripplecarrychainadder20241130 port ( a3, a2, a1, a0: in std_logic; b3, b2, b1, b0: in std_logic; c3, c2, c1, c0: out std_logic; s: out std_logic; t: in std_logic ); end component; signal a3, a2, a1, a0: std_logic; signal b3, b2, b1, b0: std_logic; signal t: std_logic; begin rplca: ripplecarrychainadder20241130 PORT MAP (b3=>b3, b2=>b2, b1=>b1, b0=>b0, c3=>c3, c2=>c2, c1=>c1, c0=>c0, a3=>a3, a2=>a2, a1=>a1, a0=>a0, t=>t, s=>s); b3 <= '1' after 0 ns, '0' after 10 ns; b2 <= '0' after 0 ns, '0' after 10 ns; b1 <= '0' after 0 ns, '0' after 10 ns; b0 <= '1' after 0 ns, '0' after 10 ns; a3 <= '0' after 0 ns, '0' after 10 ns; a2 <= '0' after 0 ns, '0' after 10 ns; a1 <= '1' after 0 ns, '0' after 10 ns; a0 <= '1' after 0 ns, '0' after 10 ns; t <= '0' after 0 ns; end;