Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --use IEEE.NUMERIC_STD.ALL;
- -- Uncomment the following library declaration if instantiating
- -- any Xilinx primitives in this code.
- --library UNISIM;
- --use UNISIM.VComponents.all;
- entity Somador8bits is
- port(
- operandoA, operandoB: in std_logic_vector(7 downto 0);
- operacao: in std_logic;
- ValorAlto, ValorBaixo: out std_logic_vector(6 downto 0);
- flag_Z, flag_N, flag_C, flag_V: out std_logic
- );
- end Somador8bits;
- architecture Soma8 of Somador8bits is
- signal Bi,n: std_logic_vector(7 downto 0);
- signal s1, s2: std_logic_vector(3 downto 0);
- signal c: std_logic;
- begin
- A0: entity work.Somador1bit port map(cin=>c, a=>operandoA(0), b=>Bi(0), cout=>n(0), s=>s1(0));
- A1: entity work.Somador1bit port map(cin=>n(0), a=>operandoA(1), b=>Bi(1), cout=>n(1), s=>s1(1));
- A2: entity work.Somador1bit port map(cin=>n(1), a=>operandoA(2), b=>Bi(2), cout=>n(2), s=>s1(2));
- A3: entity work.Somador1bit port map(cin=>n(2), a=>operandoA(3), b=>Bi(3), cout=>n(3), s=>s1(3));
- A4: entity work.Somador1bit port map(cin=>n(3), a=>operandoA(4), b=>Bi(4), cout=>n(4), s=>s2(0));
- A5: entity work.Somador1bit port map(cin=>n(4), a=>operandoA(5), b=>Bi(5), cout=>n(5), s=>s2(1));
- A6: entity work.Somador1bit port map(cin=>n(5), a=>operandoA(6), b=>Bi(6), cout=>n(6), s=>s2(2));
- A7: entity work.Somador1bit port map(cin=>n(6), a=>operandoA(7), b=>Bi(7), cout=>n(7), s=>s2(3));
- with operacao select
- Bi<= not operandoB when '1',
- operandoB when '0';
- with s1 select
- ValorBaixo<= "1111110" when "0000",
- "0110000" when "0001",
- "1101101" when "0010",
- "1111001" when "0011",
- "1100011" when "0100",
- "1110011" when "0101",
- "1011111" when "0110",
- "1110010" when "0111",
- "1111111" when "1000",
- "1100111" when "1001",
- "1110111" when "1010",
- "0011111" when "1011",
- "1001110" when "1100",
- "0111101" when "1101",
- "1001111" when "1110",
- "1000111" when "1111";
- with s2 select
- ValorAlto<= "1111110" when "0000",
- "0110000" when "0001",
- "1101101" when "0010",
- "1111001" when "0011",
- "1100011" when "0100",
- "1110011" when "0101",
- "1011111" when "0110",
- "1110010" when "0111",
- "1111111" when "1000",
- "1100111" when "1001",
- "1110111" when "1010",
- "0011111" when "1011",
- "1001110" when "1100",
- "0111101" when "1101",
- "1001111" when "1110",
- "1000111" when "1111";
- flag_Z<= '1' when s1 & s2=x"0" else '0';
- flag_N<= '1' when s1 & s2<x"0" else '0';
- flag_C<= n(7);
- flag_V<= '1' when ((operacao='1') and ((operandoA>x"0" and Bi>x"0" and S1 & S2<x"0") or (operandoA<x"0" and Bi<x"0" and S1 & S2>x"0"))) or
- ((operacao='0') and ((operandoA>x"0" and Bi>x"0" and S1 & S2<x"0") or (operandoA<x"0" and Bi<x"0" and S1 & S2>x"0")))
- else '0';
- end Soma8;
Advertisement
Add Comment
Please, Sign In to add comment