Circuito Somador e Subtrator - Chu

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar

Estrutura

Código VHDL

--Book: Chu/172
--8 bits
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity addsub is 
	port( a,b: in std_logic_vector (7 downto 0);
			ctrl: in std_logic;
			r: out std_logic_vector(7 downto 0));
			
end entity;

architecture direct_Arch of addsub is
	signal src0, src1, sum: signed (7 downto 0);

begin
	src0 <= signed(a);
	src1 <= signed(b);
	sum  <= src0 + src1 when ctrl='0' else	
			  src0 - src1;
	r<= std_logic_vector(sum);
end architecture;

Testbench

  • Código
  • Resultado (print)

Simulações

Nº Bits ALMs Delay Potência (mW)
x x x x
x x x x
x x x x
x x x x