Professional Documents
Culture Documents
com/x/ELM
desing
-- sumador total
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity sumador_total is
end sumador_total;
COMPONENT sumador_medio
PORT(
A :in std_logic;
B :in std_logic;
cout:out std_logic;
suma: out std_logic);
END COMPONENT;
COMPONENT sumador_completo
PORT( cin:in std_logic;
A :in std_logic;
B :in std_logic;
cout:out std_logic;
suma: out std_logic);
END COMPONENT;
Inst_sumador_medio:sumador_medio
port map(A=> ent1(0),
B=> ent2(0),
cout=>CO ,
suma=>resultado(0));
Inst_sumador_completo1:sumador_completo
port map(cin=>c1,
A=> ent1(1),
B=> ent2(1),
cout=>C1 ,
suma=>resultado(1));
Inst_sumador_completo2:sumador_completo
port map(cin=>CO,
A=> ent1(2),
B=> ent2(2),
cout=>CO ,
suma=>resultado(2));
Inst_sumador_completo3:sumador_completo
port map(cin=>C1,
A=> ent1(3),
B=> ent2(3),
cout=>carry,
suma=>resultado(3));
end behavioral;
--------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity calculadora is
Port( A,B:IN std_logic_vector(3 downto 0);
Sa,Sb:IN std_logic;
Cal:IN std_logic_vector(1 downto 0);
Sig:OUT std_logic;
Result:OUT std_logic_vector(7 downto 0));
end calculadora;
begin
---------------------------------------------------------------------------
--------------------------------------------------------------------------
Sig<=
Result <=
Rsuma
Rresta
Sgsum<=Sa;
C1<= '1' when Sa = Sb else
'0';
------------------------------------------------------------------------------------------
Sp2(0)<=A(0)
Sp2(1)<=A(1)
Sp2(2)<=A(2)
Sp2(3)<=A(3)
k2(0)<=(B(0)
k2(1)<=(B(1)
k2(2)<=(B(2)
Sp2(4)<=(B(3)
Sp2(5)<= '0';
Sp2(6)<= '0';
Sp2(7)<= '0';
G<='0';
----------------------------------mutiplicacion-----------------------------------------
Va1<=('0', '0', '0', (A(3) and B(0)), (A(2) and B(0)), (A(1) and B(0)), (A(0) and
B(0)));
Va2<=('0', '0', (A(3) and B(1)), (A(2) and B(1)), (A(1) and B(1)), (A(0) and
B(1)), '0');
Va3<=('0', (A(3) and B(2)), (A(2) and B(2)), (A(1) and B(2)), (A(0) and
B(2)), '0', '0');
Va4<=((A(3) and B(3)), (A(2) and B(3)), (A(1) and B(3)), (A(0) and B(3)), '0',
'0', '0'); ------------------------------resultado de suma---------------------------------
S(0)<=(Va2(0) AND G)
E(0)<=(Va4(0) and
G)
end Behavioral;
testbench
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY calcul_tb IS
END calcul_tb;
COMPONENT calculadora
PORT(
BEGIN
PROCESS
BEGIN
wait for 1 ps;
test_A<= "1010";
test_B<="0111";
test_Sa<='1';
test_Sb<='1';
test_Cal<="00";
test_A<= "1110";
test_B<="0101";
test_Sa<='1';
test_Sb<='1';
test_Cal<="00";
test_A<= "1011";
test_B<="0110";
test_Sa<='0';
test_Sb<='0';
test_Cal<="10";
wait for 1 ps;
test_A<= "1111";
test_B<="0101";
test_Sa<='0';
test_Sb<='1';
test_Cal<="11";
wait;
end process;
END;
tabla de verdad
B
Ci
Co
0
1
2
3
4
5
6
7
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
1
0
1
0
0
1
0
0
0
1
0
1
1
1