dio cane
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
library IEEE;
|
||||
use IEEE.numeric_bit.all;
|
||||
|
||||
entity Sim_CSA16 is
|
||||
end Sim_CSA16;
|
||||
|
||||
architecture MySim_CSA16 of Sim_CSA16 is
|
||||
component CSA16_2x8
|
||||
Port (A,B: in bit_vector(15 downto 0);
|
||||
cin: in bit;
|
||||
S: out bit_vector(15 downto 0);
|
||||
cout: out bit);
|
||||
end component;
|
||||
component CSA16_4x4
|
||||
Port (A,B: in bit_vector(15 downto 0);
|
||||
cin: in bit;
|
||||
S: out bit_vector(15 downto 0);
|
||||
cout: out bit);
|
||||
end component;
|
||||
|
||||
signal IA,IB,OS1,OS2: bit_vector(15 downto 0);
|
||||
signal Icin, Ocout1,Ocout2: bit;
|
||||
|
||||
begin
|
||||
CUT1: CSA16_2x8 port map(IA,IB,Icin,OS1,Ocout1);
|
||||
CUT2: CSA16_4x4 port map(IA,IB,Icin,OS2,Ocout2);
|
||||
process begin
|
||||
Icin <= '0';
|
||||
for j in 65279 to 65535 loop
|
||||
for k in 65279 to 65535 loop
|
||||
IA <= bit_vector(to_signed(j,16));
|
||||
IB <= bit_vector(to_signed(k,16));
|
||||
wait for 10ns;
|
||||
end loop;
|
||||
end loop;
|
||||
Icin <= '1';
|
||||
for j in 65279 to 65535 loop
|
||||
for k in 65279 to 65535 loop
|
||||
IA <= bit_vector(to_signed(j,16));
|
||||
IB <= bit_vector(to_signed(k,16));
|
||||
wait for 10ns;
|
||||
end loop;
|
||||
end loop;
|
||||
wait;
|
||||
end process;
|
||||
|
||||
end MySim_CSA16;
|
||||
@@ -0,0 +1,47 @@
|
||||
entity Sim_FullAdder is
|
||||
end Sim_FullAdder;
|
||||
|
||||
architecture MySim_FullAdder of Sim_FullAdder is
|
||||
component FullAdder is
|
||||
Port ( a,b,cin : in bit;
|
||||
s,cout : out bit);
|
||||
end component;
|
||||
|
||||
signal Ia, Ib, Icin, Os, Ocout: bit;
|
||||
begin
|
||||
CUT: FullAdder port map(Ia, Ib, Icin, Os, Ocout);
|
||||
process begin
|
||||
Ia <= '0';
|
||||
Ib <= '0';
|
||||
Icin <= '0';
|
||||
wait for 10ns;
|
||||
Ia <= '1';
|
||||
Ib <= '0';
|
||||
Icin <= '0';
|
||||
wait for 10ns;
|
||||
Ia <= '0';
|
||||
Ib <= '1';
|
||||
Icin <= '0';
|
||||
wait for 10ns;
|
||||
Ia <= '0';
|
||||
Ib <= '0';
|
||||
Icin <= '1';
|
||||
wait for 10ns;
|
||||
Ia <= '1';
|
||||
Ib <= '1';
|
||||
Icin <= '0';
|
||||
wait for 10ns;
|
||||
Ia <= '1';
|
||||
Ib <= '0';
|
||||
Icin <= '1';
|
||||
wait for 10ns;
|
||||
Ia <= '0';
|
||||
Ib <= '1';
|
||||
Icin <= '1';
|
||||
wait for 10ns;
|
||||
Ia <= '1';
|
||||
Ib <= '1';
|
||||
Icin <= '1';
|
||||
end process;
|
||||
|
||||
end MySim_FullAdder;
|
||||
@@ -0,0 +1,37 @@
|
||||
library IEEE;
|
||||
use IEEE.numeric_bit.all;
|
||||
|
||||
entity Sim_RCA4 is
|
||||
end Sim_RCA4;
|
||||
|
||||
architecture MySim_RCA4 of Sim_RCA4 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 IA,IB,OS: bit_vector(3 downto 0);
|
||||
signal Icin, Ocout: bit;
|
||||
begin
|
||||
CUT: RCA4 port map(IA,IB,Icin,OS,Ocout);
|
||||
process begin
|
||||
Icin <= '0';
|
||||
for j in 0 to 15 loop
|
||||
for k in 0 to 15 loop
|
||||
IA <= bit_vector(to_signed(j,4));
|
||||
IB <= bit_vector(to_signed(k,4));
|
||||
wait for 10ns;
|
||||
end loop;
|
||||
end loop;
|
||||
Icin <= '1';
|
||||
for j in 0 to 15 loop
|
||||
for k in 0 to 15 loop
|
||||
IA <= bit_vector(to_signed(j,4));
|
||||
IB <= bit_vector(to_signed(k,4));
|
||||
wait for 10ns;
|
||||
end loop;
|
||||
end loop;
|
||||
end process;
|
||||
end MySim_RCA4;
|
||||
@@ -0,0 +1,37 @@
|
||||
library IEEE;
|
||||
use IEEE.numeric_bit.all;
|
||||
|
||||
entity Sim_RCA8 is
|
||||
end Sim_RCA8;
|
||||
|
||||
architecture MySim_RCA8 of Sim_RCA8 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 IA,IB,OS: bit_vector(7 downto 0);
|
||||
signal Icin, Ocout: bit;
|
||||
begin
|
||||
CUT: RCA8 port map(IA,IB,Icin,OS,Ocout);
|
||||
process begin
|
||||
Icin <= '0';
|
||||
for j in 0 to 255 loop
|
||||
for k in 0 to 255 loop
|
||||
IA <= bit_vector(to_signed(j,8));
|
||||
IB <= bit_vector(to_signed(k,8));
|
||||
wait for 10ns;
|
||||
end loop;
|
||||
end loop;
|
||||
Icin <= '1';
|
||||
for j in 0 to 255 loop
|
||||
for k in 0 to 255 loop
|
||||
IA <= bit_vector(to_signed(j,8));
|
||||
IB <= bit_vector(to_signed(k,8));
|
||||
wait for 10ns;
|
||||
end loop;
|
||||
end loop;
|
||||
end process;
|
||||
end MySim_RCA8;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user