This commit is contained in:
Tommischiri
2026-10-24 17:18:17 +02:00
parent 86e83215ea
commit 5d92d66a7b
148 changed files with 48187 additions and 1 deletions
@@ -0,0 +1,33 @@
entity CSA16_2x8 is
Port (A,B: in bit_vector(15 downto 0);
cin: in bit;
S: out bit_vector(15 downto 0);
cout: out bit);
end CSA16_2x8;
architecture MyCSA16_2x8 of CSA16_2x8 is
component RCA8 is
Port (A,B: in bit_vector(7 downto 0);
cin: in bit;
S: out bit_vector(7 downto 0);
cout: out bit);
end component;
signal c8: bit;
signal cout0, cout1: bit;
signal SL: bit_vector(7 downto 0);
signal SH: bit_vector(15 downto 8);
signal S0,S1: bit_vector(15 downto 8);
begin
RCA8_1: RCA8 port map(A(7 downto 0),B(7 downto 0),cin,SL,c8);
RCA8_21: RCA8 port map(A(15 downto 8),B(15 downto 8),'0',S0,cout0);
RCA8_22: RCA8 port map(A(15 downto 8),B(15 downto 8),'1',S1,cout1);
cout <= cout0 when c8='0' else cout1;
SH <= S0 when c8='0' else S1;
S(15 downto 8) <= SH;
S(7 downto 0) <= SL;
end MyCSA16_2x8;
@@ -0,0 +1,48 @@
entity CSA16_4x4 is
Port (A,B: in bit_vector(15 downto 0);
cin: in bit;
S: out bit_vector(15 downto 0);
cout: out bit);
end CSA16_4x4;
architecture MyCSA16_4x4 of CSA16_4x4 is
component RCA4 is
Port (A,B: in bit_vector(3 downto 0);
cin: in bit;
S: out bit_vector(3 downto 0);
cout: out bit);
end component;
signal c4,c8,c12: bit;
signal cout0, cout1: bit_vector(3 downto 1);
signal SL_L: bit_vector(3 downto 0);
signal S10,S11,SL_H: bit_vector(7 downto 4);
signal S20,S21,SH_L: bit_vector(11 downto 8);
signal S30,S31,SH_H: bit_vector(15 downto 12);
begin
RCA0: RCA4 port map(A(3 downto 0),B(3 downto 0),cin,SL_L, c4);
RCA10: RCA4 port map(A(7 downto 4),B(7 downto 4),'0',S10, cout0(1));
RCA11: RCA4 port map(A(7 downto 4),B(7 downto 4),'1',S11, cout1(1));
RCA20: RCA4 port map(A(11 downto 8),B(11 downto 8),'0',S20, cout0(2));
RCA21: RCA4 port map(A(11 downto 8),B(11 downto 8),'1',S21, cout1(2));
RCA30: RCA4 port map(A(15 downto 12),B(15 downto 12),'0',S30, cout0(3));
RCA31: RCA4 port map(A(15 downto 12),B(15 downto 12),'1',S31, cout1(3));
c8 <= cout0(1) when c4='0' else cout1(1);
c12 <= cout0(2) when c8='0' else cout1(2);
cout <= cout0(3) when c12='0' else cout1(3);
SL_H <= S10 when c4='0' else S11;
SH_L <= S20 when c8='0' else S21;
SH_H <= S30 when c12='0' else S31;
S(15 downto 12) <= SH_H;
S(11 downto 8) <= SH_L;
S(7 downto 4) <= SL_H;
S(3 downto 0) <= SL_L;
end MyCSA16_4x4;
@@ -0,0 +1,12 @@
entity FullAdder is
Port ( a,b,cin : in bit;
s,cout : out bit);
end FullAdder;
architecture MyFullAdder of FullAdder is
signal p: bit;
begin
p <= a xor b;
s <= p xor cin;
cout <= a when p='0' else cin;
end MyFullAdder;
@@ -0,0 +1,21 @@
entity RCA4 is
Port (A,B: in bit_vector(3 downto 0);
cin: in bit;
S: out bit_vector(3 downto 0);
cout: out bit);
end RCA4;
architecture MyRCA4 of RCA4 is
signal C: bit_vector(3 downto 1);
component FullAdder is
Port ( a,b,cin : in bit;
s,cout : out bit);
end component;
begin
FA0: FullAdder port map(A(0),B(0),cin,S(0),C(1));
FA1: FullAdder port map(A(1),B(1),C(1),S(1),C(2));
FA2: FullAdder port map(A(2),B(2),C(2),S(2),C(3));
FA3: FullAdder port map(A(3),B(3),C(3),S(3),cout);
end MyRCA4;
@@ -0,0 +1,19 @@
entity RCA8 is
Port (A,B: in bit_vector(7 downto 0);
cin: in bit;
S: out bit_vector(7 downto 0);
cout: out bit);
end RCA8;
architecture MyRCA8 of RCA8 is
component RCA4 is
Port (A,B: in bit_vector(3 downto 0);
cin: in bit;
S: out bit_vector(3 downto 0);
cout: out bit);
end component;
signal c4: bit;
begin
RCA4_1: RCA4 port map(A(3 downto 0),B(3 downto 0), cin, S(3 downto 0), c4);
RCA4_2: RCA4 port map(A(7 downto 4),B(7 downto 4), c4, S(7 downto 4), cout);
end MyRCA8;