Vlsi Lab Pgms
Vlsi Lab Pgms
Structural Modeling:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity haddstructural is
Port ( a : in std_logic;
b : in std_logic;
sum : out std_logic;
carry : out std_logic);
end haddstructural;
architecture structural of haddstructural is
component xor2
LOGIC DIAGRAM port(a,b:instd_logic;
z:out std_logic);
VHDL SOURCE CODE: end component;
--Design : HALF ADDER component and2
port(a,b:instd_logic;
Dataflow Modeling: z:out std_logic);
library IEEE; end component;
use IEEE.STD_LOGIC_1164.ALL; begin
use IEEE.STD_LOGIC_ARITH.ALL; x1: xor2 port map (a,b,sum);
use IEEE.STD_LOGIC_UNSIGNED.ALL; a1: and2 port map (a,b,carry);
entity hadd is end structural;
Port ( a : in std_logic;
b : in std_logic; and2 component source code:
sum : out std_logic; library IEEE;
carry : out std_logic); use IEEE.STD_LOGIC_1164.ALL;
end hadd; use IEEE.STD_LOGIC_ARITH.ALL;
architecture dataflow of hadd is use IEEE.STD_LOGIC_UNSIGNED.ALL;
begin entity and2 is
sum <= a xor b; Port ( a : in std_logic;
carry <= a and b; b : in std_logic;
end dataflow; z : out std_logic);
end and2;
architecture dataflow of and2 is
begin Port ( a : in std_logic;
z<= a and b; b : in std_logic;
end dataflow; diff : out std_logic;
borrow : out std_logic);
xor2 component source code: end hsub_behv;
library IEEE; architecture Behavioral of hsub_behv is
use IEEE.STD_LOGIC_1164.ALL; begin
use IEEE.STD_LOGIC_ARITH.ALL; p1:process(a,b)
use IEEE.STD_LOGIC_UNSIGNED.ALL; variable abar:std_logic;
entity xor2 is begin
Port ( a : in std_logic; abar:= not a;
b : in std_logic; diff<=a xor b;
z : out std_logic); borrow<=abar and b;
end xor2; end process p1;
architecture dataflow of xor2 is end Behavioral;
begin
z<= a xor b; Structural Modeling:
end dataflow; library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
HALF SUBSTRACTOR: use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity hsub_structural is
Port ( a : in std_logic;
b : in std_logic;
diff : out std_logic;
borrow : out std_logic);
end hsub_structural;
architecture structural of hsub_structural is
component xor2
port(a,b:instd_logic;
LOGIC DIAGRAM z:out std_logic);
end component;
VHDL SOURCE CODE: component and2
port(a,b:instd_logic;
Dataflow Modeling: z:out std_logic);
library IEEE; end component;
use IEEE.STD_LOGIC_1164.ALL; component not1
use IEEE.STD_LOGIC_ARITH.ALL; port(a:instd_logic;
use IEEE.STD_LOGIC_UNSIGNED.ALL; z:out std_logic);
entity hsub_dataflow is end component;
Port ( a : in std_logic; signal abar:std_logic;
b : in std_logic; beginx1:xor2 port map (a,b,diff);
diff : out std_logic; a1:and2 port map (abar,b,borrow);
borrow : out std_logic); n1:not1 port map (a,abar);
end hsub_dataflow; end structural;
architecture dataflow of hsub_dataflowisbegin
diff <= a xor b; and2 component source code:
borrow <= not a and b; library IEEE;
end dataflow; use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
Behavioral Modeling: use IEEE.STD_LOGIC_UNSIGNED.ALL;
library IEEE; entity and2 is
use IEEE.STD_LOGIC_1164.ALL; Port ( a : in std_logic;
use IEEE.STD_LOGIC_ARITH.ALL; b : in std_logic;
use IEEE.STD_LOGIC_UNSIGNED.ALL; z : out std_logic);
entity hsub_behv is end and2;
architecture dataflow of and2 is carry : out std_logic);
begin end fadd_dataflow;
z<= a and b; architecture dataflow of fadd_dataflow is
end dataflow; signal p,q,r,s:std_logic;
begin
xor2 component source code: p<= a xor b;
library IEEE; q<= a and b;
use IEEE.STD_LOGIC_1164.ALL; r<= b and c;
use IEEE.STD_LOGIC_ARITH.ALL; s<= c and a;
use IEEE.STD_LOGIC_UNSIGNED.ALL; sum<= p xor c;
entity xor2 is carry<= q or r or s;
Port ( a : in std_logic; end dataflow;
b : in std_logic;
z : out std_logic); Behavioral Modeling:
end xor2; library IEEE;
architecture dataflow of xor2 is use IEEE.STD_LOGIC_1164.ALL;
begin use IEEE.STD_LOGIC_ARITH.ALL;
z<= a xor b; use IEEE.STD_LOGIC_UNSIGNED.ALL;
end dataflow; entity fadd_behv is
not1 component source code: Port ( a : in std_logic;
library IEEE; b : in std_logic;
use IEEE.STD_LOGIC_1164.ALL; c : in std_logic;
use IEEE.STD_LOGIC_ARITH.ALL; diff : out std_logic;
use IEEE.STD_LOGIC_UNSIGNED.ALL; borrow : out std_logic);
entity not1 is end fsub_behv;
Port ( a : in std_logic; architecture Behavioral of fsub_behv is
z : out std_logic); begin
end not1; p1:process(a,b,c)
architecture dataflow of not1 is variable abar,r,s,t:std_logic;
begin begin
z<= not a; abar:=not a;
end dataflow; r:=abar and b;
s:=b and c;
FULL ADDER: t:=c and abar;
LOGIC DIAGRAM: diff<=a xor b xor c;
borrow<=r or s or t;
end process p1;
end Behavioral;
Structural Modeling:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
VHDL SOURCE CODE: entity fsub_structural is
Port ( a : in std_logic;
Dataflow Modeling: b : in std_logic;
library IEEE; c : in std_logic;
use IEEE.STD_LOGIC_1164.ALL; diff : out std_logic;
use IEEE.STD_LOGIC_ARITH.ALL; borrow : out std_logic);
end fsub_structural;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
architecture structural of fsub_structural is
entity fadd_dataflow is
component xor2
Port ( a : in std_logic;
port(a,b:instd_logic;
b : in std_logic;
z:out std_logic);
c : in std_logic;
end component;
sum : out std_logic;
component and2 library IEEE;
port(a,b:instd_logic; use IEEE.STD_LOGIC_1164.ALL;
z:out std_logic); use IEEE.STD_LOGIC_ARITH.ALL;
end component; use IEEE.STD_LOGIC_UNSIGNED.ALL;
component not1 entity xor2 is
port(a:instd_logic; Port ( a : in std_logic;
z:out std_logic); b : in std_logic;
end component; z : out std_logic);
component or3 end xor2;
port(a,b,c:instd_logic; architecture dataflow of xor2 is
z:out std_logic); begin
end component; z<= a xor b;
signal p,q,r,s,abar:std_logic; end dataflow;
begin
x1:xor2 port map (a,b,p); FULL SUBSTRACTOR:
x2:xor2 port map (p,c,diff); LOGIC DIAGRAM:
n1:not1 port map (a,abar);
a1:and2 port map (abar,b,q);
a2:and2 port map (b,c,r);
a3:and2 port map (c,abar,s);
o1:or3 port map (q,r,s,borrow);
end structural;
Structural Modeling:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity encoder_struct is
Port ( d : in std_logic_vector(7 downto 0);
z : out std_logic_vector(2 downto 0));
VHDL SOURCE CODE:
end encoder_struct;
architecture structural of encoder_struct is
Dataflow Modeling:
component or4
library IEEE;
port(a,b,c,d:instd_logic;
use IEEE.STD_LOGIC_1164.ALL;
z:out std_logic);
use IEEE.STD_LOGIC_ARITH.ALL;
end component;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
begin
entity decoder_dataflow is
o1:or4 port map (d(4),d(5),d(6),d(7),z(0));
Port ( a : in std_logic;
o2:or4 port map (d(2),d(3),d(6),d(7),z(1));
b : in std_logic;
o3:or4 port map (d(1),d(3),d(5),d(7),z(2));
e : in std_logic;
end structural;
z : out std_logic_vector(3 downto 0)); port(a:instd_logic;
end decoder_dataflow; z:out std_logic);
architecture dataflow of decoder_dataflow is end component;
signal abar,bbar:std_logic; signal abar,bbar:std_logic;
begin begin
abar<= not a; n1:not1 port map (a,abar);
bbar<= not b; n2:not1 port map (b,bbar);
z(0)<= not (abar and bbar and e); a1:nand3 port map (abar,bbar,e,z(0));
z(1)<= not (abar and b and e); a2:nand3 port map (abar,b,e,z(1));
z(2)<= not (a and bbar and e); a3:nand3 port map (a,bbar,e,z(2));
z(3)<= not (a and b and e); a4:nand3 port map (a,b,e,z(3));
end dataflow; end structural;
D FLIPFLOP:
LOGIC DIAGRAM:
TRUTH TABLE:
TRUTH TABLE:
T FLIPFLOP:
LOGIC DIAGRAM:
TRUTH TABLE:
SYNCHRONOUS COUNTER:
LOGIC DIAGRAM:
VHDL SOURCE CODE: t2:tff port map (q(0),clk,rst,q(1),x4);
Structural Modeling: t3:tff port map (x1,clk,rst,q(2),x5);
library IEEE; t4:tff port map (x2,clk,rst,q(3),x6);
use IEEE.STD_LOGIC_1164.ALL; a1:and2 port map (q(0),q(1),x1);
use IEEE.STD_LOGIC_ARITH.ALL; a2:and2 port map (x1,q(2),x2);
use IEEE.STD_LOGIC_UNSIGNED.ALL; end structural;
entity syncounter is
Port ( clk : in std_logic; tff component source code:
rst : in std_logic; library IEEE;
q : inoutstd_logic_vector(3 downto 0)); use IEEE.STD_LOGIC_1164.ALL;
end syncounter; use IEEE.STD_LOGIC_ARITH.ALL;
architecture structural of syncounter is use IEEE.STD_LOGIC_UNSIGNED.ALL;
component tff entity tff is
port(t,clk,rst:instd_logic; Port ( t : in std_logic;
q,qbar:inoutstd_logic); clk : in std_logic;
end component; rst : in std_logic;
component and2 q : inoutstd_logic;
port(a,b:instd_logic; qbar : inoutstd_logic);
z:out std_logic); end tff;
end component; architecture Behavioral of tff is
signal x1,x2:std_logic; begin
signal x3,x4,x5,x6:std_logic:='Z'; process(t,clk,rst,q,qbar)
begin begin
t1:tff port map ('1',clk,rst,q(0),x3); if (rst='1') then
q<='0';
qbar<='1'; end Behavioral;
elsif (clk='1' and clk'event) then
if (t='0') then and2 component source code:
q<=q; library IEEE;
qbar<=qbar; use IEEE.STD_LOGIC_1164.ALL;
else use IEEE.STD_LOGIC_ARITH.ALL;
q<=not q; use IEEE.STD_LOGIC_UNSIGNED.ALL;
qbar<=not qbar; entity and2 is
end if; Port ( a : in std_logic;
end if; b : in std_logic;
end process; z : out std_logic);
end and2;
architecture dataflow of and2 is
begin
z<=a and b;
end dataflow;
ASYNCHRONOUS COUNTER:
LOGIC DIAGRAM: