RESULT: Half Adder is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
(STRUCTURAL MODEL) AIM:
Simulation and verification of Full Adder using structural model.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
entity fa2 is
port(a1,b1,c1:in bit;sum,cout1:out bit);
end fa2;
use vamsi.all;
architecture struc of fa2 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;
component or2
port(a,b:in bit;y:out bit);
end component;
signal s1,s2,s3,s4,s5:bit;
begin
d1:exor1 port map(a1,b1,s1);
d2:exor1 port map(s1,c1,sum);
d3:and1 port map(a1,b1,s2);
d4:and1 port map(a1,c1,s3);
d5:and1 port map(b1,c1, s4);
d6:or1 port map(s2,s3,s5);
d7:or1 port map(s4,s5,cout1);
end struc;
SIMULATION OUTPUT:
AIM:
Simulation and verification of Half Subtractor using structural model.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
use vamsi.all;
entity hfsub is
port(A,B:in bit;D,B0:out bit);
end hfsub;
architecture struct of hfsub is component xor2 is
port(a,b:in bit;y:out bit);
end component;
component and2 is port(a,b:in bit;y:out bit);
end component;
component not1 is port(a:in bit;y:out bit);
end component;
signal s:bit;
Begin
X1:xor1 port map(A,B,D);
X2:not1 port map(A,s);
X3:and1 port map(s,B,B0);
end struct;
SIMULATION OUTPUT:
RESULT: Half Subtractor is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
(STRUCTURAL MODEL) AIM:
Simulation and verification of Full Subtractor using structural model.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
use vamsi.all;
entity fulsub is
port(A,B,C:in bit;D,Bo:out bit);
end fulsub;
architecture struct of fulsub is component and2 is
port(a,b:in bit;y:out bit);
end component;
component xor2 is port(a,b:in bit;y:out bit);
end component;
component or2 is
port(a,b:in bit;c:out bit);
end component;
component not1 is port(a:in bit;y:out bit);
end component;
signal S0,S1,S2,S3,S4,S5:bit;
Begin
X1:xor1 port map(A,B,S1);
X2:xor1 port map(S1,C,D);
X3:not1 port map(A,S0);
X4:and1 port map(S0,B,S2);
X5:and1 port map(S0,C,S3);
X6:or1 port map(S2,S3,S5);
X7:and1 port map(B,C,S4);
X8:or1 port map(S5,S4,Bo);
RESULT: Full Subtractor is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of 2 x 4 AND gate decoder.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity dec24 is
port(a,b,e:in std_logic; z:out std_logic_vector(0 to 3));
end dec24;
architecture data of dec24 is begin
z(0)<= NOT((not a) AND (not b) AND e);
z(1)<= NOT (B AND (not a) and e);
z(2)<= NOT(a and (not b) and e);
z(3)<= NOT(a and b and e);
end data;
SIMULATION OUTPUT:
RESULT: 2 to 4 Decoder is simulated and verified.
AIM:
Simulation and verification of 2 to 4 NAND gate decoder.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity dec is
port(a,b,e:in bit;z0,z1,z2,z3:out bit);
end dec;
architecture bm3 of dec is begin
process(a,b,e)
variable abar,bbar:bit;
begin
abar:=not a;
bbar:=not b;
if e='1' then z3<=not(a and b);
z0<=not(abar and bbar);
z2<=not(a and bbar);
z1<=not(abar and b);
end if;
end process;
end bm3;
SIMULATION OUTPUT: :
RESULT: 2 to 4 Decoder is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of 4 x 1 NAND gate decoder.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
entity mu4to1 is port(i0,i1,i2,i3:in bit;
s:in bit_vector(1 downto 0);
z:out bit);
end mu4to1;
architecture df1 of mu4to1 is signal t0,t1,t2,t3,t4:bit;
begin
t0<=(i0 and not s(1) and not s(0));
t1<=(i1 and not s(1) and s(0));
t2<=(i2 and s(1) and not s(0));
t3<=(i3 and s(1) and s(0));
z<=t0 or t1 or t2 or t3;
end df1;
SIMULATION OUTPUT: :
AIM:
Simulation and verification of 9-bit parity generator using structural model.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
use vamsi.all;
entity pg is
port(d0,d1,d2,d3,d4,d5,d6,d7,d8:in bit;od:out bit);
end pg;
architecture str of pg is component xor2
port(a,b:in bit;y:out bit);
end component;
component not1
port(a:in bit;y:out bit);
end component;
signal e0,e1,e2,e3,f0,f1,a0,ev:bit;
begin
x1:xor2 port map(d0,d1,e0);
x2:xor2 port map(d2,d3,e1);
x3:xor2 port map(d4,d5,e2);
x4:xor2 port map(d6,d7,e3);
x5:xor2 port map(f0,f1,a0);
x6:xor2 port map(a0,d8,ev);
x7:not1 port map(ev,od);
end str;
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
RESULT: 9 bit Priority encoder is simulated and verified.
AIM:
Simulation and verification of 17-bit parity generator using structural model.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
use vamsi.all;
entity pg1 is
port(d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16:in bit;
od:buffer bit;ev:buffer bit);
end pg1;
architecture str of pg1 is component xor2
port(a,b:in bit;y:out bit);
end component;
component xor2
port(a,b:in bit;y:buffer bit);
end component;
component not1
port(a:in bit;y:buffer bit);
end component;
signal e0,e1,e2,e3,e4,e5,e6,e7,a0,a1,a2,a3,b0,b1,f0:bit;
begin
x1:xor2 port map(d0,d1,e0);
x2:xor2 port map(d2,d3,e1);
x3:xor2 port map(d4,d5,e2);
x4:xor2 port map(d6,d7,e3);
x5:xor2 port map(d8,d9,e4);
x6:xor2 port map(d10,d11,e5);
x7:xor2 port map(d12,d13,e6);
x8:xor2 port map(d14,d15,e7);
x9:xor2 port map(e0,e1,a0);
x10:xor2 port map(e2,e3,a1);
x11:xor2 port map(e4,e5,a2);
x12:xor2 port map(e6,e7,a3);
x13:xor2 port map(a0,a1,b0);
x14:xor2 port map(a2,a3,b1);
x15:xor2 port map(b0,b1,f0);
x16:xor2 port map(f0,d16,od);
x17:not1 port map(od,ev);
end str;
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
simulation and verification of arithmetic operations.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity arithmatic is
port(a,b:in std_logic_vector(3 downto 0);
q1:out std_logic_vector(4 downto 0);
q2:out std_logic_vector(3 downto 0);
q3:out std_logic_vector(7 downto 0));
end arithmatic;
architecture df of arithmatic is begin
q1<=('0'&a)+('0'&b);
q2<=a-b;
q3<=a*b;
end df;
SIMULATION OUTPUT: :
RESULT: ALU is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
simulation and verification of 1’s 2’s complement arithmetic operations.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity complement is
port(a:in std_logic_vector(4 downto 0);
c2:out std_logic_vector(4 downto 0));
end complement;
architecture beh of complement is signal c1:std_logic_vector(4 downto 0);
begin c1<=(not a);
c2<=c1 + 1;
end beh;
SIMULATION OUTPUT: :
RESULT:ALU is simulated and verified.
AIM:
simulation and verification of BCD to Excess – 3 code.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bin2ex3 is
port(d: in std_logic_vector(3 downto 0);
q: out std_logic_vector(3 downto 0);p:out std_logic);
end bin2ex3;
architecture bin2ex3 of bin2ex3 is signal s:std_logic_vector(4 downto 0);
begin
s<=('0'& d)+"0011";
q<=s(3 downto 0);
p<=s(4);
end bin2ex3;
SIMULATION OUTPUT: :
RESULT: BCD TO EXCESS-3 CODE CONVERSION is simulated and verified
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of 2 x 4decoder.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
use soujanya.all;
entity twoto4dec is
ort(A,B,E:in bit;Z0,Z1,Z2,Z3:out bit);
end twoto4dec;
architecture struct of twoto4dec is component nand2 is
port(a,b,c:in bit;y:out bit);
end component;
component not1 is port(a:in bit;y:out bit);
end component;
signal A0,B0:bit;
Begin
X1:not1 port map(A,A0);
X2:not1 port map(B,B0);
X3:nand2 port map(A0,B0,E,Z0);
X4:nand2 port map(A0,B,E,Z1);
X5:nand2 port map(A,B0,E,Z2);
X6:nand2 port map(A,B,E,Z3);
end struct;
SIMULATION OUTPUT: :
AIM:
simulation and verification of binary to gray code conversion.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bi_to_g is
port(b:in std_logic_vector(3 downto 0);
g:out std_logic_vector(3 downto 0));
end bi_to_g;
architecture df of bi_to_g is begin
g(3)<=b(3);
g(2)<=b(3) xor b(2);
g(1)<=b(2) xor b(1);
g(0)<=b(1) xor B(0);
end df;
SIMULATION OUTPUT: :
RESULT: BINARY TO GRAY CODE CONVERSION is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
simulation and verification of gray to binary code conversion.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity gryb2 is
port(d: in std_logic_vector(3 downto 0);q: out std_logic_vector(3 downto 0));
end gryb2;
architecture gryb2 of gryb2 is begin
q(3)<=d(3);
q(2)<=d(3) xor d(2);
q(1)<=d(1) xor d(2) xor d(3);
q(0)<=d(1) xor d(0) xor d(2) xor d(3);
end gryb2;
SIMULATION OUTPUT: :
RESULT: GRAY TO BINARY CODE CONVERSION is simulated and verified.
AIM:
Simulation and verification of RS-latch using behavioural model PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
entity rslatch is
port(r,s,clk:in bit;q,nq:inout bit);
end rslatch;
architecture beh of rslatch is signal temp:bit;
begin
b1: block(clk='1') begin
temp<=guarded(r nand q);
nq<=temp;
q<=s nand nq after 5 ns;
end block b1;
end beh;
SIMULATION OUTPUT: :
RESULT: RS LATCH is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of T- FLIP FLOP using behavioural model PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
entity tff is
port(t,clk:in std_logic;
q:inout std_logic:='0');
end tff;
architecture beh of tff is begin
process(clk) begin
if (clk' event and clk='1') then if(t='1') then
q<= not (q);
else q<=q;
end if;
end if;
end process;
end beh;
SIMULATION OUTPUT: :
RESULT: T FLIP FLOP is simulated and verified.
AIM:
Simulation and verification of D- LATCH using behavioural model PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
entity dl2 is
port(d,e:in bit; q:out bit);
end dl2;
architecture beh of dl2 is begin
process(d,e) begin if e='1' then q<=d;
end if;
end process;
end beh;
SIMULATION OUTPUT: :
RESULT: D- LATCH is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of positive level triggered D-FLIP FLOP using behavioural model
PROGRAM:
library ieee;
entity dff2 is
port(d,clk:in bit;q:out bit);
end dff2;
architecture dff of dff2 is begin
process(d,clk) begin
if clk='1' then q<=d;
end if;
end process;
end dff;
SIMULATION OUTPUT: :
RESULT: positive level triggered D-FLIP FLOP using behavioural model is simulated
AIM:
Simulation and verification of positive edge triggered D-FLIP FLOP using behavioural model
PROGRAM:
library ieee;
entity dff3 is
port(d,clk:in bit;q:out bit);
end dff3;
architecture dfn of dff3 is begin
process(clk) begin
if clk'event and clk='1' then q<=d;
end if;
end process;
end dfn;
SIMULATION OUTPUT: :
RESULT: Positive edge Triggered D-FLIP FLOP using behavioural model is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of D-LATCH with gated enable using behavioural model
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity dl1 is
port(d,en,g:in bit;q:out bit);
end dl1;
architecture beh of dl1 is begin
process(d,en,g) begin
if ((en and g)='1') then q<=d;
end if;
end process;
end beh;
SIMULATION OUTPUT: :
RESULT: D-LATCH with gated enable using behavioural model is simulated and verified.
AIM:
Simulation and verification of JK FLIP FLOP using behavioural model.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
entity jkff1 is
port (s,r,j,k,clk:in bit;q:inout bit;qn:out bit:='1');
end jkff1;
architecture jkff of jkff1 is begin
process(s,r,clk) begin
if r='0' then q<='0' after 10ns;
elsif s='0' then q<='1' after 10ns;
elsif clk='0' and clk' event then
q<=(j and not q) or (not k and q) after 10ns;
end if;
end process;
qn<=not q;
end jkff;
SIMULATION OUTPUT: :
RESULT: JK-FLIP FLOP using behavioural Model is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of 2 To 4 Decoder using NAND gates.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity dec24 is
port(a,b,e:in std_logic; z:out std_logic_vector(0 to 3));
end dec24;
architecture data of dec24 is begin
z(0)<= NOT((not a) AND (not b) AND e);
z(1)<= NOT (B AND (not a) and e);
z(2)<= NOT(a and (not b) and e);
z(3)<= NOT(a and b and e);
end data;
SIMULATION OUTPUT:
RESULT: 2 to 4 Decoder is simulated and verified.
AIM:
Simulation and verification of 3 to 8 decoder using NAND gates.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity dec38 is
port(a,b,c,e:in std_logic; z:out std_logic_vector(0 to 7));
end dec38;
architecture beh of dec38 is begin
z(0)<=not((not a)and(not b)and (not c)and e);
z(1)<=not((not a)and(not b)and c and e);
z(2)<=not((not a)and b and(not c)and e);
z(3)<=not((not a) and b and c and e);
z(4)<=not(a and(not b)and(not c) and e);
z(5)<=not(a and(not b)and c and e);
z(6)<=not(a and b and(not c) and e);
z(7)<=not(a and b and c and e);
end beh;
RESULT: 3 to 8 Decoder is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of 2 to1 Multiplexer.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity mux21 is
port(a,b,s:in bit;f:out bit);
end mux21;
architecture beh of mux21 is begin
f<= (a and (not s)) or (b and s);
end beh;
SIMULATION OUTPUT:
RESULT: 2 to 1 Multiplexer is simulated and verified.
AIM:
Simulation and verification of 3 to 8 Decoder.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity dec38 is
port(a,b,c,e:in std_logic; z:out std_logic_vector(0 to 7));
end dec38;
architecture beh of dec38 is begin
z(0)<=(not a)and(not b)and (not c)and e;
z(1)<=(not a)and(not b)and c and e;
z(2)<=(not a)and b and(not c)and e;
z(3)<=(not a) and b and c and e;
z(4)<=a and(not b)and(not c) and e;
z(5)<=a and(not b)and c and e;
z(6)<=a and b and(not c) and e;
z(7)<=a and b and c and e;
end beh;
SIMULATION OUTPUT:
RESULT: 3 to 8 Decoder is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of 3 to 8 Decoder Using Structural Model.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
use dsce04.all;
entity dec37 is
port(a,b,c,e:in bit; z0,z1,z2,z3,z4,z5,z6,z7:out bit);
end dec37;
architecture struc of dec37 is component and4 is
port(g,h,i,j:in bit; k:out bit);
end component;
component not1 is port(a:in bit; b:out bit);
end component;
signal s1,s2,s3:bit;
begin
x1:not1 port map(a,s1);
x2:not1 port map(b,s2);
x3:not1 port map(c,s3);
x4:and4 port map(s1,s2,s3,e,z0);
x5:and4 port map(s1,s2,c,e,z1);
x6:and4 port map(s1,b,s3,e,z2);
x7:and4 port map(s1,b,c,e,z3);
x8:and4 port map(a,s2,s3,e,z4);
x9:and4 port map(a,s2,c,e,z5);
x10:and4 port map(a,b,s3,e,z6);
x11:and4 port map(a,b,c,e,z7);
end struc;
RESULT: 3 to 8 Decoder Using Structural Model is simulated and verified.
NARASARAOPET ENGINEERING COLLEGE -NARASARAOPET
AIM:
Simulation and verification of 4 Bit Full Adder Using Structural Model.
PROGRAM:
Library ieee;
use ieee.std_logic_1164.all;
use dsce04.all;
entity adder1 is
port(x0,x1,x2,x3,y0,y1,y2,y3:in std_logic;
c:in std_logic;
cout:out std_logic;
s0,s1,s2,s3:out std_logic);
end adder1;
architecture str of adder1 is signal c1,c2,c3:std_logic;
component fa3
port(x,y,c:in std_logic;s,cout:out std_logic);
end component ; begin
n1:fa3 port map(x0,y0,c,s0,c1);
n2:fa3 port map(x1,y1,c1,s1,c2);
n3:fa3 port map(x2,y2,c2,s2,c3);
n4:fa3 port map(cout=>cout,c=>c3,x=>x3,y=>y3,s=>s3);
end str;
SIMULATION OUTPUT: :
4 TO 16 DECODER (STRUCTURAL MODEL)