VHDL Code For Half Adder Using Three Modeling
VHDL Code For Half Adder Using Three Modeling
Dataflow Modeling
Library ieee;
use ieee.std_logic_1164.all;
entity half_adder is
port(a,b:in bit;
sum, carry:out bit);
end half_adder;
architecture HA of half_adder is
begin
sum<= a xor b;
carry <= a and b;
end HA;
a) Behavioral Modeling
Library ieee;
use ieee.std_logic_1164.all;
entity half_adder is
port(a,b:in bit;
sum, carry:out bit);
end half_adder;
architecture HA of half_adder is
begin
process (a,b);
sum<= a xor b;
carry <= a and b;
end process;
end HA;
b) Structural modeling
Library ieee;
use ieee.std_logic_1164.all;
entity half_adder is
port(a,b:in bit;
sum, carry:out bit);
end half_adder;
architecture HA of half_adder is
component xor2
port(a, b: in bit;
y:out bit);
end component
component and2
port(a, b: in bit;
y:out bit);
end component
begin
o1: xor2 portmap(a,b,sum);
o2:and2 portmap(a,b,carry);
end HA