0% found this document useful (0 votes)
101 views57 pages

ECAD LAB2 (Master Copy)

Download as doc, pdf, or txt
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 57

1.

LOGIC GATES

AIM:

I. To verify the truth table of NOT, NOR, AND , OR, NAND, XOR using
their IC’s.
II. Develop VHDL models for 74LSXX Series Gates.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit
3. AND -- IC 7408.
4. OR -- IC 7432.
5. NOT -- IC 7404
6. NOR -- IC 7402.
7. NAND -- IC 7400.
8. EX-OR -- IC 7486N.
9. Patch Cards.

BLOCK DIAGRAMS:

AND GATE (Quad 2-Input 74LS08)

Connection Diagram

FUNCTION TABLE

AIET – ECAD Lab Manual ……………………………………………………………… 0


OR GATE(Quad 2-Input 74LS32)

Connection Diagram

FUNCTION TABLE

NOT GATE(Quad 2-Input 74LS04)

Connection Diagram

AIET – ECAD Lab Manual ……………………………………………………………… 1


FUNCTION TABLE

NOR GATE(Quad 2-Input 74LS02)

Connection Diagram

FUNCTION TABLE

AIET – ECAD Lab Manual ……………………………………………………………… 2


NAND GATE(Quad 2-Input 74LS00)

Connection Diagram

FUNCTION TABLE

AIET – ECAD Lab Manual ……………………………………………………………… 3


EXOR GATE(Quad 2-Input 74LS86)

Connection Diagram

FUNCTION TABLE

PROCEDURE:

1. Mount the required IC on to the borad.

AIET – ECAD Lab Manual ……………………………………………………………… 4


2. Connect Vcc +5V to 14th pin & ground to 7th pin in every IC.
3. Give the input values as in the truth table & observe output values.
4. Verify truth table for every gate.
5. Note the readings.

VHDL CODE:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity logic gates is

port ( a : in STD_LOGIC;
b : in STD_LOGIC;
y_nota : out STD_LOGIC;
y_and : out STD_LOGIC;
y_or : out STD_LOGIC;
y_nand : out STD_LOGIC;
y_nor : out STD_LOGIC;
y_xor : out STD_LOGIC;
y_xnor : out STD_LOGIC);

end logic gates;

architecture Behavioral of logic gates is

begin
y_nota <= not a;
y_and <= a and b;
y_or <= a or b;
y_nand <= a nand b;
y_nor <= a nor b;
y_xor <= a xor b;
y_xnor <= a xnor b;

end Behavioral;

TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT logicgates
PORT( a : IN std_logic;
b : IN std_logic;

AIET – ECAD Lab Manual ……………………………………………………………… 5


y_nota : OUT std_logic;
y_and : OUT std_logic;
y_or : OUT std_logic;
y_nand : OUT std_logic;
y_nor : OUT std_logic;
y_xor : OUT std_logic;
y_xnor : OUT std_logic
);
END COMPONENT;

--Inputs

SIGNAL a : std_logic := '0';


SIGNAL b : std_logic := '0';

--Outputs

SIGNAL y_nota : std_logic;


SIGNAL y_and : std_logic;
SIGNAL y_or : std_logic;
SIGNAL y_nand : std_logic;
SIGNAL y_nor : std_logic;
SIGNAL y_xor : std_logic;
SIGNAL y_xnor : std_logic;

BEGIN

-- Instantiate the Unit Under Test (UUT)

uut: logicgates PORT MAP(


a => a,
b => b,
y_nota => y_nota,
y_and => y_and,
y_or => y_or,
y_nand => y_nand,
y_nor => y_nor,
y_xor => y_xor,
y_xnor => y_xnor);

a<='0','1' after 20 ns;


b<='0','1' after 10 ns,'0' after 20 ns,'1' after 30ns;

END;

SIMULATION OUTPUT:

AIET – ECAD Lab Manual ……………………………………………………………… 6


RESULT: The truth table of OR,AND,NOR,NAND & EX-OR are verified.

2. 3 To 8 DECODER USING IC-74LS138.


AIM:

I. To verify the operation of 3 to 8 Decoder using IC 74 LS 138.


II. Develop VHDL model for 74LS138 3 x 8 Decoder.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit
3. IC 74 LS138.
4. Patch Cards.

BLOCK DIAGRAM:

Connection Diagram:

AIET – ECAD Lab Manual ……………………………………………………………… 7


FUNCTION TABLE:

PROCEDURE:

1. Connect circuit as shown in figure.


2. Apply Vcc to pin 16 of IC 74 LS 138.
3. Pins 4,5,6 are enable inputs.
4. Connects inputs to pins 1,2,3.
__ __
5. When E1 is high, E2, E3 are low / high then all outputs are high
irrespective.
__ __
6. Similarly when E2 is high ,all outputs are high irrespective of E1 & E2 &
inputs.
__ __
7. When E3 is low, all outputs are high irrespective of E 1, E2 are inputs.
__ __
8. With E1, E2 low and E3 high when all inputs are low, then

AIET – ECAD Lab Manual ……………………………………………………………… 8


__
outputs Qo will be low and other outputs will be high.

9. Similarly by changing two inputs Ao, A1, A2 we get one ouput low
& others high every time.
__
10. When inputs are high , o/p O , will become low and others become
high.

VHDL CODE:

library ieee;
use ieee.std_logic_1164.all;

entity decoder3x8 is

port(G1,G2,C,B,A:in std_logic;
Y:out std_logic_vector(0 to 7));

end decoder3x8;

architecture decoder3x8 of decoder3x8 is

signal S:std_logic_vector(2 downto 0);

begin
S<=C&B&A;

process(G1,G2,S)

begin
if G2='1' then Y<="11111111";
elsif G1='0' then Y<="11111111";
elsif G1='1' and G2='0' and S="000" then Y<="01111111";
elsif G1='1' and G2='0' and S="001" then Y<="10111111";
elsif G1='1' and G2='0' and S="010" then Y<="11011111";
elsif G1='1' and G2='0' and S="011" then Y<="11101111";
elsif G1='1' and G2='0' and S="100" then Y<="11110111";
elsif G1='1' and G2='0' and S="101" then Y<="11111011";
elsif G1='1' and G2='0' and S="110" then Y<="11111101";
elsif G1='1' and G2='0' and S="111" then Y<="11111110";
else Y<="UUUUUUUU";
end if;

end process;

end architecture decoder3x8;

TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

AIET – ECAD Lab Manual ……………………………………………………………… 9


USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT decoder3x8
PORT(
G1 : IN std_logic;
G2 : IN std_logic;
C : IN std_logic;
B : IN std_logic;
A : IN std_logic;
Y : OUT std_logic_vector(0 to 7)
);
END COMPONENT;

--Inputs

SIGNAL G1 : std_logic := '0';


SIGNAL G2 : std_logic := '0';
SIGNAL C : std_logic := '0';
SIGNAL B : std_logic := '0';
SIGNAL A : std_logic := '0';

--Outputs

SIGNAL Y : std_logic_vector(0 to 7);

BEGIN

-- Instantiate the Unit Under Test (UUT)

uut: decoder3x8 PORT MAP(


G1 => G1,
G2 => G2,
C => C,
B => B,
A => A,
Y => Y
);

G1<='0','1'after 20 ns;
G2<='1','0' after 20 ns;
C<='0','1' after 60ns;
B<='0','1' after 40 ns,'0' after 60 ns,'1' after 80 ns;
A<='0','1' after 30 ns,'0' after 40 ns,'1' after 50 ns,
'0' after 60 ns,'1' after 70 ns,'0' after 80 ns,

AIET – ECAD Lab Manual ……………………………………………………………… 10


'1' after 90 ns;

END;

SIMULATION OUTPUT:

RESULT: operation of 3-8 decoder using IC 74 LS 138 is verified.

3. 8x1 MULTIPLEXER USING IC 74 LS 150

AIM:

I. To verify the operation of 8 x 1 multiplexer using IC 74 LS 150.


II. Develop the model for 74LS150- 8X1 Multiplexer.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit
3. IC 74 LS150.
4. Patch Cards

PROCEDURE:

AIET – ECAD Lab Manual ……………………………………………………………… 11


1. Connections are made as per the circuit diagram.
2. Connect the i/p D0 to D7.
3. Give the data inputs and verify the outputs according to truth table.

BLOCK DIAGRAM:

Connection Diagram

FUNCTION TABLE:

AIET – ECAD Lab Manual ……………………………………………………………… 12


VHDL CODE:

library ieee;
use ieee.std_logic_1164.all;

entity mux8x1 is

port(C,B,A,G_L:in std_logic;
D:in std_logic_vector(7 downto 0);
Y,W:out std_logic);

end mux8x1;

architecture mux8x1 of mux8x1 is

signal s:std_logic_vector(2 downto 0);

begin

s<=C&B&A;

process(S,G_L)

begin

if G_L='1' then Y<='0';W<='1';


AIET – ECAD Lab Manual ……………………………………………………………… 13
elsif S<="000" and G_L='0' then Y<=D(0);W<=not D(0);
elsif S<="001" and G_L='0' then Y<=D(1);W<=not D(1);
elsif S<="010" and G_L='0' then Y<=D(2);W<=not D(2);
elsif S<="011" and G_L='0' then Y<=D(3);W<=not D(3);
elsif S<="100" and G_L='0' then Y<=D(4);W<=not D(4);
elsif S<="101" and G_L='0' then Y<=D(5);W<=not D(5);
elsif S<="110" and G_L='0' then Y<=D(6);W<=not D(6);
elsif S<="111" and G_L='0' then Y<=D(7);W<=not D(7);
else Y<='U';W<='U';
end if;

end process;

end architecture mux8x1;

TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT mux8x1
PORT(
C : IN std_logic;
B : IN std_logic;
A : IN std_logic;
G_L : IN std_logic;
D : IN std_logic_vector(7 downto 0);
Y : OUT std_logic;
W : OUT std_logic
);
END COMPONENT;

--Inputs

SIGNAL C : std_logic := '0';


SIGNAL B : std_logic := '0';
SIGNAL A : std_logic := '0';
SIGNAL G_L : std_logic := '0';
SIGNAL D : std_logic_vector(7 downto 0) := (others=>'0');

--Outputs

SIGNAL Y : std_logic;

AIET – ECAD Lab Manual ……………………………………………………………… 14


SIGNAL W : std_logic;

BEGIN

-- Instantiate the Unit Under Test (UUT)

uut: mux8x1 PORT MAP(


C => C,
B => B,
A => A,
G_L => G_L,
D => D,
Y => Y,
W => W
);

C<='0','1' after 50ns;


B<='0','1' after 30ns,'0' after 50ns,'1' after 70ns;
A<='0','1' after 20ns,'0' after 30ns,'1' after 40ns,'0' after 50ns,'1' after
60ns,'0' after 70ns,'1' after 80ns;
G_L<='1','0' after 10ns;
D<="11101101";

END;

SIMULATION OUTPUT:

RESULT: The operation of 8 X 1 multiplexer using IC 74 LS 150is verified.

AIET – ECAD Lab Manual ……………………………………………………………… 15


4. 4 -BIT COMPARATOR

AIM:

I. Verify the Truth table of 4-bit comparator using 74LS85.


II. Develop the model for 74x85 4-bit comparator.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit
3. IC 74 LS85.
4. Patch Cards.

BLOCK DIAGRAM:

Connection Diagram

PROCEDURE:

1. Connections are made as per circuit diagram.


2. Give the inputs A [ A3 ,A2 ,A1 ,A0 ] , B [ B3 ,B2 , B1 , B0 ] according to the
function table and gives corresponding inputs IA>B , IA<B, IA=B and verify
the output.
3. Tabulate the inputs and outputs according to the function table.

AIET – ECAD Lab Manual ……………………………………………………………… 16


VHDL CODE:

library ieee;
use ieee.std_logic_1164.all;

entity comparator4bit is

port(A,B:in std_logic_vector(3 downto 0);


AeqB,AlsB,AgrB:out std_logic);

end comparator4bit;

architecture comparator4bit of comparator4bit is

begin

process(A,B)

begin
if A(3)>B(3) then AgrB<='1';AeqB<='0';AlsB<='0';
elsif A(3)=B(3) and A(2)>B(2) then AgrB<='1';AeqB<='0';AlsB<='0';
elsif A(3)=B(3) and A(2)<B(2) then AgrB<='0';AeqB<='0';AlsB<='1';
elsif A(3)=B(3) and A(2)=B(2) and A(1)>B(1) then
AgrB<='1';AeqB<='0';AlsB<='0';
elsif A(3)=B(3) and A(2)=B(2) and A(1)<B(1) then
AgrB<='0';AeqB<='0';AlsB<='1';
elsif A(3)=B(3) and A(2)=B(2) and A(1)=B(1) and A(0)>B(0) then
AgrB<='1';AeqB<='0';AlsB<='0';
elsif A(3)=B(3) and A(2)=B(2) and A(1)=B(1) and A(0)<B(0) then
AgrB<='0';AeqB<='0';AlsB<='1';
else AgrB<='0';AeqB<='1';AlsB<='0';
end if;

AIET – ECAD Lab Manual ……………………………………………………………… 17


end process;

end comparator4bit;

TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT comparator4bit
PORT(
A : IN std_logic_vector(3 downto 0);
B : IN std_logic_vector(3 downto 0);
AeqB : OUT std_logic;
AlsB : OUT std_logic;
AgrB : OUT std_logic
);
END COMPONENT;

--Inputs

SIGNAL A : std_logic_vector(3 downto 0) := (others=>'0');


SIGNAL B : std_logic_vector(3 downto 0) := (others=>'0');

--Outputs

SIGNAL AeqB : std_logic;


SIGNAL AlsB : std_logic;
SIGNAL AgrB : std_logic;

BEGIN

-- Instantiate the Unit Under Test (UUT)

uut: comparator4bit PORT MAP(


A => A,
B => B,
AeqB => AeqB,
AlsB => AlsB,
AgrB => AgrB
);

AIET – ECAD Lab Manual ……………………………………………………………… 18


A<="1100","1010" after 20ns,"0101" after 40ns;
B<="1001","1101" after 20ns,"0101" after 40ns;

END;

SIMULATION OUTPUT:

RESULT: The operation of 4 – bit comparator using IC 74 LS 85 is verified.

5. D FLIP-FLOP USING IC-7474


AIET – ECAD Lab Manual ……………………………………………………………… 19
AIM:

I. To verify the truth table of D – Flip –Flop using IC 7474.


II . Develop VHDL model for 74LS74 D-Flip-Flop.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit
3. IC 74 LS 74.
4. Patch Cards.

BLOCK DIAGRAMS:

PROCEDURE:

AIET – ECAD Lab Manual ……………………………………………………………… 20


1. Connections are made as per circuit.
2. Connect the preset terminal to logic -1 & then clear the circuit by
connecting the clear terminal to logic – 0 & observe Q, Q .
3. Connect the preset terminal to logic -0 & then clear the circuit by
connecting the clear terminal to logic – 1 & observe Q, Q .
4 .Now apply +ve edge tiggered CLK & change values of ‘D’ to 0 &1
And verify the change values of Q & Q.
5. All values are noted in truth table.

VHDL CODE:

library ieee;
use ieee.std_logic_1164.all;

entity dflipflop is
port(PR,CLR,CLK,D:in std_logic;
Q,Q_L:out std_logic);

end dflipflop;

architecture dflipflop of dflipflop is

signal tq,tqb:std_logic;

begin

process(PR,CLR,CLK)

begin

if PR='0' and CLR='1' then tq<='1';tqb<='0';


elsif PR='1' and CLR='0' then tq<='0';tqb<='1';
elsif PR='0' and CLR='0' then tq<='1';tqb<='1';
elsif PR='1' and CLR='1' and CLK'event and CLK='1' then
tq<=D;tqb<=not D;
elsif PR='1' and CLR='1' and CLK='0' then tq<=tq;tqb<=tqb;
end if;

end process;

Q<=tq;
Q_L<=tqb;

end architecture dflipflop;

TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

AIET – ECAD Lab Manual ……………………………………………………………… 21


ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT dflipflop
PORT(
PR : IN std_logic;
CLR : IN std_logic;
CLK : IN std_logic;
D : IN std_logic;
Q : OUT std_logic;
Q_L : OUT std_logic
);
END COMPONENT;

--Inputs

SIGNAL PR : std_logic := '0';


SIGNAL CLR : std_logic := '0';
SIGNAL CLK : std_logic := '0';
SIGNAL D : std_logic := '0';

--Outputs

SIGNAL Q : std_logic;
SIGNAL Q_L : std_logic;

BEGIN

-- Instantiate the Unit Under Test (UUT)

uut: dflipflop PORT MAP(


PR => PR,
CLR => CLR,
CLK => CLK,
D => D,
Q => Q,
Q_L => Q_L
);

PR<='0','1' after 10ns;


CLR<='1','0' after 10ns,'1' after 20ns;
D<='0','1' after 20ns,'0' after 30ns;

process
begin
CLK<='1';
wait for 5ns;

AIET – ECAD Lab Manual ……………………………………………………………… 22


CLK<='0';
wait for 5ns;
end process;

END;

SIMULATION OUTPUT:

RESULT: The truth table of D -Flip – Flop using IC 7474 was verified.

6. DECADE COUNTER USING IC-7490


AIET – ECAD Lab Manual ……………………………………………………………… 23
AIM:

I. To study the operation of Decade Counter using IC 7490.


II . Develop VHDL model for 74LS90 Decade Counter.

APPARATUS:

1. Xilinx VHDL Simulator tool


2.Bread Board Trainer.
3..IC 74 LS 90.
4.Patch Cards.

BLOCK DIAGRAM:

FUNCTION TABLE(74LS90)

BCD Count Sequence


Note: Output QA is connected to input B for BCD Count

PROCEDURE:

AIET – ECAD Lab Manual ……………………………………………………………… 24


1. Connect the circuit as shown in the figure.
2. Clock pluse given to pin 14 of IC 7490.
3. Vcc supply given to pin 5 of 7490.
4. Pins 12 and 1 are shorted.
5. Pins 2 and 3 are master reset inputs and pins 6 and 7 are master inputs.
6. Pins 13 and 4 has no connection.
7. Pins 2,3,6 and 7 are inputs and always ‘0’.
8. Pins 12,9,8,11 are outputs.
9. Feed MR with ‘1’ and master set terminals with ‘0’ and
apply clock then output varies between 0 &9.

VHDLCODE:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity decadecounter is

port(CLK,R,S:in std_logic;
Q:out std_logic_vector(3 downto 0));

end decadecounter;

architecture decadecounter of decadecounter is

signal count:std_logic_vector(3 downto 0);

begin

process(CLK,R,S)

begin

if R='1' then count<="0000";


elsif CLK'event and CLK='1' and R='0' then
if count="1001" and S='1' then count<="1001";
elsif count="1001" and S='0' then count<="0000";
else count<=count+"0001";
end if;
end if;

end process;

Q<=count;

end decadecounter;

AIET – ECAD Lab Manual ……………………………………………………………… 25


TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT decadecounter
PORT(
CLK : IN std_logic;
R : IN std_logic;
S : IN std_logic;
Q : OUT std_logic_vector(3 downto 0)
);
END COMPONENT;

--Inputs

SIGNAL CLK : std_logic := '0';


SIGNAL R : std_logic := '0';
SIGNAL S : std_logic := '0';

--Outputs

SIGNAL Q : std_logic_vector(3 downto 0);

BEGIN

-- Instantiate the Unit Under Test (UUT)

uut: decadecounter PORT MAP(


CLK => CLK,
R => R,
S => S,
Q => Q
);

R<='1','0' after 10ns;


S<='0','1' after 150ns;
process
begin
CLK<='1';
wait for 5ns;
CLK<='0';
wait for 5ns;

AIET – ECAD Lab Manual ……………………………………………………………… 26


end process;

END;

SIMULATION OUTPUT:

RESULT: The Working of Decade Counter using IC 7490 is studied.

7. 4-BIT COUNTER USING IC-7493

AIET – ECAD Lab Manual ……………………………………………………………… 27


AIM:

I. To study the operation of 4 – bit counter using IC 7493.


II . Develop VHDL model for 74LS93 Binary Counter.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Bread Board Trainer.
3. IC 74 LS 93.
4. Patch Cards.

BLOCK DIAGRAM:

FUNCTION TABLES(74LS93

AIET – ECAD Lab Manual ……………………………………………………………… 28


Note: Output QA is connected to input B

PROCEDURE:

1. Connect the circuit as shown in the figure.


2. The clock pulse is given to pin 14 of IC 7493.
3. The Vcc supply is given to pin 5 of IC 7493.
4. pin 12 and pin 1 are to be shorted.
5. pin 2, pin 3, are master reset inputs.
6. pins 12,9,8,11 are outputs.
7. Feed the MR terminals with ‘0’ and apply clock and then the
output varies let the value 0 to 15.

VHDL CODE:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity binarycounter is

port(CLK,R:in std_logic;
Q:out std_logic_vector(3 downto 0));

end binarycounter;

architecture binarycounter of binarycounter is

signal count:std_logic_vector(3 downto 0);

AIET – ECAD Lab Manual ……………………………………………………………… 29


begin

process(R,CLK)

begin

if R='1' then count<="0000";


elsif CLK'event and CLK='1' and R='0' then
if count="1111" then count<="0000";
else count<=count+"0001";
end if;
end if;

end process;

Q<=count;

end binarycounter;

TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS


-- Component Declaration for the Unit Under Test (UUT)

COMPONENT binarycounter
PORT(
CLK : IN std_logic;
R : IN std_logic;
Q : OUT std_logic_vector(3 downto 0)
);
END COMPONENT;

--Inputs

SIGNAL CLK : std_logic := '0';


SIGNAL R : std_logic := '0';

--Outputs

SIGNAL Q : std_logic_vector(3 downto 0);

BEGIN

AIET – ECAD Lab Manual ……………………………………………………………… 30


-- Instantiate the Unit Under Test (UUT)

uut: binarycounter PORT MAP(


CLK => CLK,
R => R,
Q => Q
);

R<='1','0' after 10ns;


process
begin
CLK<='1';
wait for 5ns;
CLK<='0';
wait for 5ns;
end process;

END;

SIMULATION OUTPUT:

RESULT: Thus the operation of 4 – bit counter using IC 7493 was studied.

8. SHIFT REGISTER USING IC-74LS95

AIET – ECAD Lab Manual ……………………………………………………………… 31


AIM:

I. To verify the following function of Shift Register using IC 7495.

1. Clearing the Register.


2. Serial I/P / Parallel O/P.
3. Parallel I/P / Parallel O/P.
4. Parallel I/P / Serial O/P.

II. Develop VHDL model for 74LS95 register.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit
3. IC 74 LS95.
4. Patch Cards.

BLOCK DIAGRAM

AIET – ECAD Lab Manual ……………………………………………………………… 32


PROCEDURE:

1. Mount IC 7495A on logic trainer and make required connections.


Pins 2,3,4,5 are connected to logic switches SW1, SW2, SW3, SW4
for applying high and logic at these inputs.
2. Serial input is given to pin 1 and mode CTRL to pin6.
3. pins 8,9 shorted, given to clock.
4. Connect Vcc to 5v to pin and 7th pin grounded.

1.Clearing function:

1. set mode CTRL switch to low.


2. set serial input switch to low.
3. set parallel inputs A,B,C,D to logic ‘0’.
4. To clear the register apply clock pulses till the output is 0000.
2.serial input / parallel output:

1.After register has cleared any 4 bit serial no. can be loaded
into the register.
2. set mode CTRL switch to low.
3.set serial input switch to high.
4.Apply clock pulse which shift serial input 1 into reg Qn will be 1.
5.we can load any 4 bit number into reg.
3.Parallel I/P / Parallel O/P:

1.set mode CTRL switch to high.


2.Apply input 1011 to A,B,C,D.
3.It we apply clock pulse the word is loaded in to the reg.

AIET – ECAD Lab Manual ……………………………………………………………… 33


4.Parallel I/P / Serial O/P:

1.set mode CTRL switch to low.


2.set serial input pin 1 to low.
3. As you apply CLK pulses the word will be shifted out serially from
Qo after 4 CLK pulses the register will be cleared.

VHDL CODE:

library ieee;
use ieee.std_logic_1164.all;

entity shif_95r is
port( CLK,MODE, SER : in std_logic;
PALL : in std_logic_vector(3 downto 0);
Q_A,Q_B,Q_C,Q_D : inout std_logic
);

end entity shif_95r;

architecture bhe of shif_95r is

begin

process(CLK,MODE,SER,PALL)

variable O : std_logic_vector(3 downto 0);


variable P : std_logic_vector(3 downto 0);

begin

p := Q_A & Q_B & Q_C & Q_D;

if( CLK = '1' and clk'event) then


if( MODE ='1') then O := PALL;
elsif( MODE ='0' ) then O := SER & Q_A & Q_B & Q_C;

else O:="UUUU";
end if;

end if;

Q_A <= O(3);


Q_B <= O(2);
Q_C <= O(1);
Q_D <= O(0);

end process;

end architecture bhe;

AIET – ECAD Lab Manual ……………………………………………………………… 34


TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

ENTITY tb_vhd IS
END tb_vhd;

ARCHITECTURE behavior OF tb_vhd IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT shif_95r
PORT(
CLK : IN std_logic;
MODE : IN std_logic;
SER : IN std_logic;
PALL : IN std_logic_vector(3 downto 0);
Q_A : INOUT std_logic;
Q_B : INOUT std_logic;
Q_C : INOUT std_logic;
Q_D : INOUT std_logic
);
END COMPONENT;

--Inputs

SIGNAL CLK : std_logic := '0';


SIGNAL MODE : std_logic := '0';
SIGNAL SER : std_logic := '0';
SIGNAL PALL : std_logic_vector(3 downto 0) := (others=>'0');

--BiDirs

SIGNAL Q_A : std_logic;


SIGNAL Q_B : std_logic;
SIGNAL Q_C : std_logic;
SIGNAL Q_D : std_logic;

BEGIN

-- Instantiate the Unit Under Test (UUT)

uut: shif_95r PORT MAP(


CLK => CLK,
MODE => MODE,
SER => SER,
PALL => PALL,
Q_A => Q_A,
Q_B => Q_B,

AIET – ECAD Lab Manual ……………………………………………………………… 35


Q_C => Q_C,
Q_D => Q_D
);

PALL <= "0000";

process
begin
CLK <='1';
wait for 10 ns;
CLK <='0';
wait for 10 ns;
end process;

MODE <= '1','0' after 20 ns;

SER <= '1','0' after 100 ns;

END;

SIMULATION OUTPUT:

RESULT: The functions of shift register using IC 7495 is verified

AIET – ECAD Lab Manual ……………………………………………………………… 36


9. UNIVERSAL SHIFT REGISTER USING IC 74 LS 194

AIM:

I. To verify the varies functions of 74 LS 194 universal shift register.


II. Develop VHDL model for 74LS94 Universal Shift register.

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit
3. IC 74 LS194.
4. Patch Cards.

BLOCK DIAGRAM:

Note: SR-> Shift Right


SL-> Shift Left

AIET – ECAD Lab Manual ……………………………………………………………… 37


PROCEDURE:

1.Connections are made as per circuit diagram.


2.Connect Vcc +5v to 10th pin & ground the 8th pin.
3.Connect mode control I/p’s S1, S0 to pins 9,10.
4. Connect pin 11 to +ve edge pulse.
5. Connect register shift pin to 2 & use pin 7 for left shift operation.
6.Apply mode control I/P’s and verify the result according to truth table.

VHDL MODEL:

library ieee;
use ieee.std_logic_1164.all;

entity univ_sreg is
port( CLR,CLK,S_L,S_R : in std_logic;
A,B,C,D : in std_logic ;
S : in std_logic_vector(1 downto 0);
Q_A,Q_B,Q_C,Q_D : inout std_logic
);
end entity univ_sreg;

architecture behv of univ_sreg is


begin
process(CLR,CLK,S_L,S_R,A,B,C,D,S)
variable P : std_logic_vector(0 to 3);
variable O : std_logic_vector(0 to 3);
variable S_A : std_logic_vector(0 to 3);
begin
P := Q_A & Q_B & Q_C & Q_D;
S_A := S & S_L & S_R;
if ( CLR = '0') then
O := "0000";
elsif ( CLR = '1') then
if( CLK ='0') then
O := P;

AIET – ECAD Lab Manual ……………………………………………………………… 38


elsif( CLK ='1' and clk'event) then
if( S ="11") then O :=A & B& C & D;
elsif ( S="01" and S_R ='1') then O := '1' & Q_A & Q_B & Q_C;
elsif ( S="01" and S_R ='0') then O := '0' & Q_A & Q_B & Q_C;
elsif ( S="10" and S_L ='1') then O := Q_B & Q_C & Q_D & '1';
elsif ( S="10" and S_L ='0') then O := Q_B & Q_C & Q_D & '0';
elsif( S="00") then O :=P;
end if;
end if;
end if;
Q_A <= O(0);
Q_B <= O(1);
Q_C <= O(2);
Q_D <= O(3);
end process;
end architecture behv;

TEST BENCH:

library ieee;
use ieee.std_logic_1164.all;
entity test is
end entity test;

architecture test_sftreg of test is

component univ_sreg
port( CLR,CLK,S_L,S_R : in std_logic;
A,B,C,D : in std_logic ;
S : in std_logic_vector(1 downto 0);
Q_A,Q_B,Q_C,Q_D : inout std_logic
);
end component;
signal CLR,CLK,S_L,S_R,A,B,C,D,Q_A,Q_B,Q_C,Q_D : std_logic;
signal S : std_logic_vector(1 downto 0);
begin
U0:univ_sreg port map(CLR,CLK,S_L,S_R,A,B,C,D,S,Q_A,Q_B,Q_C,Q_D);
CLR <= '0','1' after 20 ns;
A <= '1';
B <= '1';
C <= '1';
D <= '1';
process
begin
clk<='1';
wait for 10 ns;
clk<= '0';
wait for 10 ns;
end process;
s<= "11",
"01" after 50 ns,
"10" after 90 ns,

AIET – ECAD Lab Manual ……………………………………………………………… 39


"00" after 130 ns;
s_l<= '1','0' after 110 ns;
s_r<= '1','0' after 70 ns;

end architecture test_sftreg;

SIMULATION OUTPUT:

RESULT: The functions of IC 74 LS 194 universal shift register is verified

AIET – ECAD Lab Manual ……………………………………………………………… 40


10. RAM(16X4) – 74189(Read and Write Operations).

AIM:

I. To verify the operation of 16 x 4 Ram using IC 74 LS 189.


II. Develop the model for 74LS189- 16 x 4 Ram

APPARATUS:

1. Xilinx VHDL Simulator tool


2. Electronic Circuit Designer Kit s
3. IC 74 LS189.
4. Patch Cards

BLOCK DIGRAM:

FUNCTION TABLE:

AIET – ECAD Lab Manual ……………………………………………………………… 41


PROCEDURE:

1.Connect the inputs to a binary counter 7493IC


2.Connect the four data inputs to toggle swithes
3. Connect the data outputs to four 7404 inverters
4. Provide four more for the outputs of the inverters.
5. Connect input CE to ground and RW to a pulser
6. Store a few words into the memory and then read them to verify
that the write and read operations are functioning properly
7. To store the word in memory , flip the RW switch to write position
And then return it to the read position.

VHDL CODE:

library ieee;
use ieee.std_logic_1164.all;

entity ram is
port(CLK,RST,CE,WR,RD : in std_logic;
ADD : in integer range 0 to 15;
DATA_IN : in std_logic_vector(3 downto 0);
DATA_OUT : out std_logic_vector(3 downto 0)
);
end ram;

architecture ram of ram is


type vector_array is array(0 to 15) of std_logic_vector(3 downto 0);
signal mem : vector_array;
begin
process
begin
wait until clk'event and CLK ='1';
if(CE='1') then
if(RST='1') then DATA_OUT <="0000";

AIET – ECAD Lab Manual ……………………………………………………………… 42


else
if(RD='1') then DATA_OUT <= mem(ADD);
elsif(WR='1') then mem(ADD) <= DATA_IN;
DATA_OUT <= "UUUU";
end if;
end if;
end if;
end process;
end ram;

TEST BENCH:

library ieee;
use ieee.std_logic_1164.all;

entity test_ram is
end entity test_ram;

architecture test of test_ram is


component ram
port(CLK,RST,CE,WR,RD : in std_logic;
ADD : in integer range 0 to 15;
DATA_IN : in std_logic_vector(3 downto 0);
DATA_OUT : out std_logic_vector(3 downto 0)
);
end component;
signal CLK,RST,CE,WR,RD : std_logic;
signal ADD : integer range 0 to 15;
signal DATA_IN,DATA_OUT : std_logic_vector(3 downto 0);
begin
U0: ram port map(CLK,RST,CE,WR,RD,ADD,DATA_IN,DATA_OUT);
process
begin
CLK <= '1';
wait for 10 ns;
CLK <= '0';
wait for 10 ns;
end process;
CE <= '1';
RST <= '1',
'0' after 20 ns;
DATA_IN <= "0000",
"1000" after 40 ns,
"1001" after 60 ns,
"1010" after 80 ns,
"1111" after 180 ns,
"0111" after 200 ns,
"0110" after 220 ns,
"0101" after 240 ns;
ADD <= 0,
1 after 40 ns,
2 after 60 ns,

AIET – ECAD Lab Manual ……………………………………………………………… 43


3 after 80 ns,
0 after 100 ns,
1 after 120 ns,
2 after 140 ns,
3 after 160 ns,
0 after 180 ns,
1 after 200 ns,
2 after 220 ns,
3 after 240 ns;
WR <= '1',
'0' after 100 ns,
'1' after 180 ns;
RD <= '0',
'1' after 100 ns,
'0' after 180 ns;
end architecture test;

SIMULATION OUTPUT:

RESULT: RAM 16X4 has been verified.

AIET – ECAD Lab Manual ……………………………………………………………… 44


11. Stack and Queue implementation using RAM.

AIM:

I. Develop the model for 4 x 8 Ram to implement stack and queue

APPARATUS:

1. Xilinx VHDL Simulator tool

VHDL CODE:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity fifo is
generic (RAMsize: integer :=4);
port ( data_in: in std_logic_vector (7 downto 0);
clk,nrst: in std_logic;
readReq: in std_logic;
writeReq: in std_logic;
data_out: out std_logic_vector(7 downto 0);
empty: out std_logic;
full: out std_logic;
error: out std_logic);
end fifo;

architecture Behavioral of fifo is


type memory_type is array (0 to RAMsize-1) of std_logic_vector(7 downto 0);
signal memory : memory_type :=(others => (others => '0'));

begin
process(clk,nrst)
variable read_ptr, write_ptr : std_logic_vector(7 downto 0) :="00000000"; -- read and write
pointers
variable isempty , isfull : std_logic :='0';
begin
if nrst='0' then
memory <= (others => (others => '0'));
empty <='1';
full <='0';
data_out <= "00000000";
read_ptr := "00000000";
write_ptr := "00000000";
isempty :='1';
isfull :='0';
error <='0';
AIET – ECAD Lab Manual ……………………………………………………………… 45
elsif clk'event and clk='1' then
if readReq='0' and writeReq='0' then
error <='0';
end if;
if readReq='1' then
if isempty='1' then
error <= '1';
else
data_out <= memory(conv_integer(read_ptr));
isfull :='0';
full <='0';
error <='0';
if read_ptr=conv_std_logic_vector(RAMsize-1,8) then
read_ptr := "00000000";
else
read_ptr := read_ptr + '1';
end if;
if read_ptr=write_ptr then
isempty:='1';
empty <='1';
end if;
end if;
end if;
if writeReq='1' then
if isfull='1' then
error <='1';
else
memory(conv_integer(write_ptr)) <= data_in;
error <='0';
isempty :='0';
empty <='0';
if write_ptr=conv_std_logic_vector(RAMsize-1,8) then
write_ptr := "00000000";
else
write_ptr := write_ptr + '1';
end if;
if write_ptr=read_ptr then
isfull :='1';
full <='1';
end if;
end if;
end if;
end if;
end process;

end Behavioral;

AIET – ECAD Lab Manual ……………………………………………………………… 46


TEST BENCH:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity fifo_tb is end fifo_tb;


architecture fifo_tb of fifo_tb is
component fifo is
generic (RAMsize: integer );
port ( data_in: in std_logic_vector (7 downto 0);
clk,nrst: in std_logic;
readReq: in std_logic;
writeReq: in std_logic;
data_out: out std_logic_vector(7 downto 0);
empty: out std_logic;
full: out std_logic;
error: out std_logic);
end component;
signal data_in_t: std_logic_vector (7 downto 0);
signal clk_t,nrst_t: std_logic :='0';
signal readReq_t: std_logic;
signal writeReq_t: std_logic;
signal data_out_t: std_logic_vector(7 downto 0);
signal empty_t: std_logic;
signal full_t: std_logic;
signal error_t: std_logic;

begin
u1: fifo generic map (4) port map
(data_in_t,clk_t,nrst_t,readReq_t,writeReq_t,data_out_t,empty_t,full_t,error_t);

nrst <= '0' , '1' after 15 ns;


clk <= not clk after 2 ns;
readReq <= '1' after 21 ns , '0' after 23 ns, '1' after 41 ns, '0' after 45 ns , '1' after 53
ns;
writeReq <= '1' after 28 ns, '0' after 31 ns , '1' after 33 ns , '0' after 35 ns, '1' after 37
ns, '1' after 45 ns, '0' after 47 ns , '1' after 49 ns, '0' after 51 ns;
data_in <= "11111111" after 29 ns, "11111110" after 33 ns , "11111100" after 37 ns,
"11111000" after 45 ns, "11110000" after 49 ns;

end fifo_tb;

AIET – ECAD Lab Manual ……………………………………………………………… 47


SIMULATION OUTPUT:

RESULT: Queue of 4X8 has been verified,

AIET – ECAD Lab Manual ……………………………………………………………… 48


12. ALU

AIM:

I. To verify the operation of 16 x 4 Ram using IC 74 LS 189.


II. Develop the model for 74LS189- 16 x 4 Ram

APPARATUS:

1. Modelsim VHDL Simulator tool

VHDL CODE:

entity Alu is
port( Clk : in Std_Logic;
MODE,EN: in Std_Logic;
A,B : in Std_Logic_Vector(7 downto 0);
OPCODE : in Std_Logic_Vector(3 downto 0);
Y : out Std_Logic_Vector(7 downto 0));
end Alu;

architecture Alu_a of Alu is

signal C_s : Unsigned(7 downto 0);


begin
process (A, B,OPCODE,mode)
variable A_v : Unsigned(7 downto 0);
variable B_v : Unsigned(7 downto 0);
begin
A_v := Unsigned(A);
B_v := Unsigned(B);
if(EN='0')then
C_s<=(others=>'Z');
if(mode='0')then
case OPCODE is
when "0000" => C_s <= A_v + B_v;
when "0001" => C_s <= A_v - B_v;
when "0010" => C_s <= A_v(3 downto 0) * B_v(3 downto 0);
when others => C_s <= (others => '0');
end case;
else
case opcode is
when "0011" => C_s <= not A_v;
when "0100" => C_s <= not B_v;
when "0101" => C_s <= A_v and B_v;
when "0110" => C_s <= A_v nand B_v;
when "0111" => C_s <= A_v or B_v;
when "1000" => C_s <= A_v nor B_v;
when "1001" => C_s <= A_v xor B_v;
when "1010" => C_s <= A_v xnor B_v;

AIET – ECAD Lab Manual ……………………………………………………………… 49


when others => C_s <= (others => '0');
end case;
end if;
end if;
end process;
process
begin
wait until Clk'event and Clk = '1';
y <= Std_Logic_Vector(C_s);
end process ;
end Alu_a;

AIET – ECAD Lab Manual ……………………………………………………………… 50


Additional Experiments

1. J-K flip-flop
AIM:

I. To verify the operation of using IC 74LS76 J-K flipflop.


II. Develop the model for 74LS76 J-K flipflop

APPARATUS:

1. Modelsim VHDL Simulator tool


2. Electronic Circuit Designer Kit s
3. 74LS76 J-K flipflop.
4. Patch Cards

BLOCK DIGRAM:

AIET – ECAD Lab Manual ……………………………………………………………… 51


PROCEDURE:

1. Connections are made as per circuit.


2. Connect the preset terminal to logic -1 & then clear the circuit by
connecting the clear terminal to logic – 0 & observe Q, Q .
3. Connect the preset terminal to logic -0 & then clear the circuit by
connecting the clear terminal to logic – 1 & observe Q, Q .
4 .Now apply +ve edge tiggered CLK & change values of ‘J’ and ‘K’ to 0
&1 combinations. And verify the change values of Q & Q.
5. All values are noted in truth table.

VHDL CODE:

library ieee;
use ieee. std_logic_1164.all;
use ieee. std_logic_arith.all;
use ieee. std_logic_unsigned.all;

entity JKFF is
PORT( J,K,CLK,PRST,CLR: in std_logic;
Q, QB: out std_logic);
end JKFF;

Architecture behavioral of JKFF is


begin
PROCESS(CLK,CLR,PRST)
variable x: std_logic;

AIET – ECAD Lab Manual ……………………………………………………………… 52


begin
if(CLR='0') then
x:='0';

elsif(PRST='0')then
x:='1';

elsif(CLK='1' and CLK'EVENT) then


if(J='0' and K='0')then
x:=x;
elsif(J='1' and K='1')then
x:= not x;

elsif(J='0' and K='1')then


x:='0';
else
x:='1';

end if;
end if;
Q<=x;
QB<=not x;
end PROCESS;
end behavioral;

TEST BENCH:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

ENTITY jfkejfijeijk_vhd IS
END jfkejfijeijk_vhd;

ARCHITECTURE behavior OF jfkejfijeijk_vhd IS

-- Component Declaration for the Unit Under Test (UUT)


COMPONENT JKFF
PORT(
J : IN std_logic;
K : IN std_logic;
CLK : IN std_logic;
PRST : IN std_logic;
CLR : IN std_logic;
Q : OUT std_logic;
QB : OUT std_logic
);
END COMPONENT;

AIET – ECAD Lab Manual ……………………………………………………………… 53


--Inputs
SIGNAL J : std_logic := '0';
SIGNAL K : std_logic := '0';
SIGNAL CLK : std_logic := '0';
SIGNAL PRST : std_logic := '0';
SIGNAL CLR : std_logic := '0';

--Outputs
SIGNAL Q : std_logic;
SIGNAL QB : std_logic;

BEGIN

-- Instantiate the Unit Under Test (UUT)


uut: JKFF PORT MAP(
J => J,
K => K,
CLK => CLK,
PRST => PRST,
CLR => CLR,
Q => Q,
QB => QB
);

process
begin
clk<='0';
wait for 5 ns;
clk<='1';
wait for 5 ns;
end process;

j<='0','1' after 60 ns;


k<='0','1' after 40 ns,'0' after 60 ns,'1' after 80 ns;
prst<='0','1' after 15 ns;
clr<='1','0' after 15 ns,'1' after 30 ns;

END;

SIMULATION OUTPUT:

AIET – ECAD Lab Manual ……………………………………………………………… 54


1. ENCODER
AIM:

I. Develop the model for 4x2 encoder

APPARATUS:

1. Xilinx VHDL Simulator tool

VHDL CODE:

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity encoder is
port(
d0 : in STD_LOGIC;
d1 : in STD_LOGIC;
d2 : in STD_LOGIC;
d3 : in STD_LOGIC;
a : out STD_LOGIC;
b : out STD_LOGIC
);
end encoder;

architecture encoder of encoder is


begin
a<= d2 or d3;
b<= d1 or d3;

end encoder;

TESTBENCH

library ieee;
use ieee.std_logic_1164.all;

entity encoder_tb is
end encoder_tb;

architecture TB_ARCHITECTURE of encoder_tb is

component encoder
port(
d0 : in std_logic;
d1 : in std_logic;
d2 : in std_logic;
d3 : in std_logic;

AIET – ECAD Lab Manual ……………………………………………………………… 55


a : out std_logic;
b : out std_logic );
end component;

signal d0 : std_logic;
signal d1 : std_logic;
signal d2 : std_logic;
signal d3 : std_logic;
signal a : std_logic;
signal b : std_logic;

begin

UUT : encoder
port map (
d0 => d0,
d1 => d1,
d2 => d2,
d3 => d3,
a => a,
b => b
);

d0<='1'; d1<='0';d2<='0';d3<='0'; wait for 5 ns;


d0<='0'; d1<='1';d2<='0';d3<='0'; wait for 5 ns;
d0<='0'; d1<='0';d2<='1';d3<='0'; wait for 5 ns;
d0<='0'; d1<='0';d2<='0';d3<='1'; wait for 5 ns;

end TB_ARCHITECTURE;

SIMULATION OUTPUT:

AIET – ECAD Lab Manual ……………………………………………………………… 56

You might also like