Ecad Lab Manual - Modified
Ecad Lab Manual - Modified
(ECAD Lab)
Simulate the internal structure of the following Digital IC’s using VHDL / VERILOG and
verify the operations of the Digital IC’s (Hardware) in the Laboratory
1. D Flip-Flop 7474
2. Decade counter-7490
3. shift registers-7495 7
5. 4 bit Comparator-7485
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
1
E-CAD LAB
1. LOGIC GATES
7408N
TRUTH TABLE:
x y z
0 0 0
0 1 0
1 0 0
1 1 1
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
entity AND2 is
port(
x : in STD_LOGIC;
y : in STD_LOGIC;
z : out STD_LOGIC
);
end AND2;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
2
E-CAD LAB
--Dataflow model
end behav1;
-- Behavioral model
process (x, y)
begin
end process;
end behav2;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
3
E-CAD LAB
#2-TITLE: OR gate
7432
TRUTH TABLE:
x y z
0 0 0
0 1 1
1 0 1
1 1 1
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
entity OR2 is
port(
x : in STD_LOGIC;
y : in STD_LOGIC;
z : out STD_LOGIC
);
end OR2;
--Dataflow model
architecture behav1 of OR2 is
begin
4
E-CAD LAB
end behav1;
-- Behavioral model
process (x, y)
begin
end process;
end behav2;
OUTPUT WAVEFORM:
7404
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
5
E-CAD LAB
TRUTH TABLE:
x z
0 1
1 0
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
entity not1 is
port(
X: in STD_LOGIC;
Z: out STD_LOGIC
);
end not1;
--Dataflow model
architecture behav1 of not1 is
begin
end behav1;
-- Behavioral model
architecture behav2 of not1 is
begin
process (X)
begin
6
E-CAD LAB
else
Z<= '0';
end if;
end process;
end behav2;
OUTPUT WAVEFORM:
7400
TRUTH TABLE:
x y z
0 0 1
0 1 1
1 0 1
1 1 0
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
7
E-CAD LAB
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
entity nand2 is
port(
x : in STD_LOGIC;
y : in STD_LOGIC;
z : out STD_LOGIC
);
end nand2;
--Dataflow model
end behav1;
-- Behavioral model
Process (x, y)
Begin
end process;
end behav2;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
8
E-CAD LAB
OUTPUT WAVEFORM:
x y z
0 0 1
0 1 0
1 0 0
1 1 0
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
entity nor2 is
Port (
X: in STD_LOGIC;
Y: in STD_LOGIC;
Z: out STD_LOGIC
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
9
E-CAD LAB
);
end nor2;
--Dataflow model
end behav1;
-- Behavioral model
process (x, y)
begin
end process;
end behav2;
OUTPUT WAVEFORM:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
10
E-CAD LAB
x y z
0 0 0
0 1 1
1 0 1
1 1 0
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
entity xor2 is
Port (
X: in STD_LOGIC;
Y: in STD_LOGIC;
Z: out STD_LOGIC
);
end xor2;
--Dataflow model
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
11
E-CAD LAB
end behav1;
-- Behavioral model
process (x, y)
begin
end process;
end behav2;
OUTPUT WAVEFORM:
74135
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
12
E-CAD LAB
TRUTH TABLE:
x y z
0 0 1
0 1 0
1 0 0
1 1 1
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
entity xnor2 is
Port (
X: in STD_LOGIC;
Y: in STD_LOGIC;
Z: out STD_LOGIC
);
end xnor2;
--Dataflow model
end behav1;
-- Behavioral model
process (x, y)
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
13
E-CAD LAB
begin
end process;
end behav2;
OUTPUT WAVEFORM:
VIVA QUESTIONS:
1. Implement the following function using VHDL coding. (Try to minimize if you can).
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
14
E-CAD LAB
AIM: Write a VHDL code for IC7474—a positive edge triggering D flip flop.
CIRCUIT DIAGRAM:
TRUTH TABLE:
0 0 X X 1 1
0 1 X X 0 1
1 0 X X 1 0
1 1 0 0 1
1 1 1 1 0
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
15
E-CAD LAB
VHDL CODE:
library IEEE;
use ieee.std_logic_1164.all;
entity dff is
port (
pr_l: in STD_LOGIC; -- active low preset input
clr_l:in STD_LOGIC; -- active low clear input
clk :in STD_LOGIC; -- clock input
d :in STD_LOGIC; -- D input
q :inout STD_LOGIC; -- output of D flip flop
qn :inout STD_LOGIC -- inverted output
);
end dff;
architecture dff of dff is
signal e,f,g,h:std_logic;
component nand3
port (
a,b,c: in STD_LOGIC;
d : out STD_LOGIC
);
end component;
begin
g1:nand3 port map(pr_l,h,f,e); -- creates g1 gate
g2:nand3 port map(clr_l,e,clk,f); -- creates g2 gate
g3:nand3 port map(f,clk,h,g); -- creates g3 gate
g4:nand3 port map(g,clr_l,d,h); -- creates g4 gate
g5:nand3 port map(pr_l,f,qn,q); -- creates g5 gate
g6:nand3 port map(q,g,clr_l,qn); -- creates g6 gate
end dff;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
16
E-CAD LAB
WAVEFORMS:
D FLIPFLOP
NAND GATE
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
17
E-CAD LAB
VIVA QUESTIONS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
18
E-CAD LAB
TRUTH TABLE:
OUTPUT
Q(0) Q(3) Q(2) Q(1)
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
19
E-CAD LAB
VHDL CODE:
entity count is
port (
S0, s1, r0, r1: in STD_LOGIC; --set and reset i/ps for mod2 and
-- Mod5 counters
Clk0: in STD_LOGIC; --Clock signal for mod2 counter
port (
jk : in STD_LOGIC_VECTOR(1 downto 0);
clk,pr_l,clr_l : in STD_LOGIC;
q,nq : inout STD_LOGIC
);
end component;
preset <= s0 nand s1; -- common preset inputs for mod2 and mod5 counters
clear <=r0 nand r1; -- common reset inputs for mod2 and mod5 counters
S<=q(2) and q(1); -- to set the last flip flop
q3bar <= not q(3); -- complemented output of q(3)
clk1<=q(0); --to work as asynchronous mod10 counter
20
E-CAD LAB
pr_l=>preset,
clr_l=>clear,
q=>q(1),
nq=>open); -- jk1.jk2,jk3,jk4 create four JK flip flops
jk3:jk_ff port map("11",q(1),preset,clear,q(2),open);
jk4:jk_ff port map(jk(0)=>q(3),
jk(1)=>s,
clk=>clk1,
pr_l=>preset,
clr_l=>clear,
q=>q(3),
nq=> q3bar);
end count;
WAVEFORMS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
21
E-CAD LAB
library IEEE;
use IEEE.std_logic_1164.all;
entity jk_ff is
port (
jk : in STD_LOGIC_VECTOR(1 downto 0);
--jk(1)=J;jk(0)=K;
clk,pr_l,clr_l : in STD_LOGIC;
q,nq : inout STD_LOGIC
);
end jk_ff;
architecture jk of jk_ff is
begin
process(clk,pr_l,clr_l,jk)
variable temp:std_logic:='0';
begin
q<='0';nq<='1';
if (pr_l='1' and clr_l='0') then
q<='0';nq<='1';
elsif (pr_l='0' and clr_l ='1') then
q<='1';nq<='0';
elsif (pr_l='1' and clr_l='1') then
if (clk 'event and clk='0') then --performs during the falling edge of clock
case jk is
when "00"=>temp:=temp;
when "01"=>temp:='0';
when "10"=>temp:='1';
when "11"=>temp:=not temp;
when others=>null;
end case;
end if;
q<=temp;
nq<= not temp;
end if;
end process;
end jk;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
22
E-CAD LAB
WAVEFORMS:
VIVA QUESTIONS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
23
E-CAD LAB
AIM: To write the VHDL code for IC 74x93 – 4 -bit binary counter.
TRUTH TABLE:
OUTPUT
Q(3) Q(2) Q(1) Q(0)
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
24
E-CAD LAB
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity cnt is
port (
clk0: in STD_LOGIC;
mr0: in STD_LOGIC;
mr1: in STD_LOGIC;
clk1: inout STD_LOGIC;
Q:inout STD_LOGIC_VECTOR(3 downto 0)
);
end cnt;
);
end component;
signal clear : std_logic;
begin
clear<= mr0 nand mr1; -- common reset inputs for mod2 and mod8
--counters
CLK1<=q(0); --to work as asynchronous mod16 counter
t1:tff port map('1',clk0,clear,Q(0),open);--t1,t2,t3,t4 create four T-flip flops
t2:tff port map('1',clk1,clear,Q(1), open);
t3:tff port map('1',Q(1),clear,Q(2), open);
t4:tff port map('1',Q(2),clear,Q(3), open);
end cnt;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
25
E-CAD LAB
WAVEFORMS:
library IEEE;
use IEEE.std_logic_1164.all;
entity tff is
port (
t : in STD_LOGIC;--input to the T-flip flop
clk : in STD_LOGIC;--Clock signal for T-flip flop
clr_l : in STD_LOGIC;--active low clear input
q,nq : out STD_LOGIC--actual and complemented outputs of T-flip flop
);
end tff;
26
E-CAD LAB
elsif ((clr_l='1') and (clk'event and clk='0')) then--perfoms during falling edge
if ( t='0') then
temp:=temp;
else temp:= not temp;
end if;
end if;
q<= temp;
nq<= not temp;
end process;
end tff;
WAVEFORMS:
VIVA QUESTIONS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
27
E-CAD LAB
TRUTH TABLE:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
28
E-CAD LAB
VHDL CODE:
--Structural model
--Program for shift register
library IEEE;
use IEEE.std_logic_1164.all;
entity shift_reg is
port (
a,b,c,d: in STD_LOGIC; --four parallel inputs
si : in STD_LOGIC; --one serial input
m : in STD_LOGIC; --mode control
clk0 :in STD_LOGIC; --clock for serial input
clk1 :in STD_LOGIC; --clock for parallel input
q :inout STD_LOGIC_VECTOR (3 downto 0)--4-bit output
);
end shift_reg;
29
E-CAD LAB
WAVEFORMS:
library IEEE;
use IEEE.std_logic_1164.all;
entity dff is
port (
d,clk: in STD_LOGIC;
q : out STD_LOGIC
);
end dff;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
30
E-CAD LAB
WAVEFORMS:
library ieee;
use ieee.std_logic_1164.all;
entity mux is
port (
a,b,c,d: in STD_LOGIC;
z : out STD_LOGIC
);
end mux;
WAVEFORMS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
31
E-CAD LAB
VIVA QUESTIONS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
32
E-CAD LAB
AIM: To write the VHDL code for IC 74x194 –universal shift register.
BLOCK DIAGRAM:
TRUTH TABLE:
1 0 0 no change
shift right
1 0 1 ( dsr to q(0))
shift left
1 1 0 ( dsl to q(3))
1 1 1 load data
(parallel shifting)
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
33
E-CAD LAB
VHDL code:
library IEEE;
use IEEE.std_logic_1164.all;
entity shift194 is
port (
clk : in STD_LOGIC;--Clock signal
dsr,dsl : in STD_LOGIC;--serial input for right shift and left shift
--operation
clr_l : in STD_LOGIC;--active low clear input
S:in STD_LOGIC_VECTOR(1 downto 0);--mode control bits
d: in STD_LOGIC_VECTOR (3 downto 0);--four parallel input bits
q: inout STD_LOGIC_VECTOR (3 downto 0) --4-bit output
);
end shift194;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
34
E-CAD LAB
WAVEFORMS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
35
E-CAD LAB
7. 3x8 DECODER
BLOCK DIAGRAM:
TRUTH TABLE:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
36
E-CAD LAB
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity decoder3X8 is
port (
g1 : in STD_LOGIC;--g1, g2a_l, g2b_l cascade i/ps
g2a_l : in STD_LOGIC;
g2b_l : in STD_LOGIC;
a : in STD_LOGIC_VECTOR (2 downto 0);
y_l : out STD_LOGIC_VECTOR (0 to 7)
);
end decoder3X8;
end deco38;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
37
E-CAD LAB
WAVEFORMS:
VIVA QUESTIONS
:
1. Write the behavioral code for the IC 74x138.
2. Write the VHDL code for the IC 74x138 using CASE statement.
3. Write the VHDL code for the IC 74x138 using WITH statement.
4. Write the VHDL code for the IC 74x138 using WHEN--ELSE statement.
5. Write the structural program for IC 74x138.
6. What does priority encoder mean?
7. How many decoders are needed to construct 4X16 decoder?
8. What is the difference between decoder and encoder?
9. Write the syntax for exit statement?
10. Explain briefly about next statement?
11. How to specify the delay in VHDL program?
12. Write the syntax for component declaration.
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
38
E-CAD LAB
BLOCK DIAGRAM:
TRUTH TABLE:
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity comp is
port (
altbin: in STD_LOGIC;
aeqbin: in STD_LOGIC;
agtbin: in STD_LOGIC;
a: in STD_LOGIC_VECTOR (3 downto 0);
b: in STD_LOGIC_VECTOR (3 downto 0);
agtbout: out STD_LOGIC;
aeqbout: out STD_LOGIC;
altbout: out STD_LOGIC
);
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
39
E-CAD LAB
end comp;
WAVEFORMS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
40
E-CAD LAB
VIVA QUESTIONS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
41
E-CAD LAB
9.8x1 MULTIPLEXER
BLOCK DIAGRAM:
TRUTH TABLE:
2 0 0 0 1 I(1)
3 0 0 1 0 I(2)
4 0 0 1 1 I(3)
5 0 1 0 0 I(4)
6 0 1 0 1 I(5)
7 0 1 1 0 I(6)
8 0 1 1 1 I(7)
9 1 X X X 0
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
42
E-CAD LAB
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity mux151 is
port (
I :in STD_LOGIC_VECTOR (7 downto 0); --8 i/p lines
S :in STD_LOGIC_VECTOR (2 downto 0); --3 data select lines
en_l:in STD_LOGIC; --active low enable i/p
y :out STD_LOGIC --output line
);
end mux151;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
43
E-CAD LAB
WAVEFORMS:
VIVA QUESTIONS
:
1. Write the behavioral code for the IC 74x151.
2. Write the VHDL code for the IC 74x151 using IF statement.
3. Write the VHDL code for the IC 74x151 using WITH statement.
4. Write the VHDL code for the IC 74x151 using WHEN--ELSE statement.
5. Write the structural program for IC 74x151.
6. What is meant by multiplexer?
7. What does demultiplexer mean?
8. How many 8X1 multiplexers are needed to construct 16X1 multiplexer?
9. Compare decoder with demultiplexer?
10. Design a full adder using 8X1 multiplexer?
11. What are the two kinds of subprograms?
12. What are the difference between function and procedure?
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
44
E-CAD LAB
10.16X1 MULTIPLEXER
BLOCK DIAGRAM:
TRUTH TABLE:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
45
E-CAD LAB
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity mux16 is
port(
strobe : in STD_LOGIC; --active low enable i/p
D : in STD_LOGIC_VECTOR(15 downto 0); --16 i/p lines
Sel : in STD_LOGIC_VECTOR(3 downto 0); --4 data select lines
Y : out STD_LOGIC --output line
);
end mux16;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
46
E-CAD LAB
WAVEFORMS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
47
E-CAD LAB
VIVA QUESTIONS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
48
E-CAD LAB
AIM: To write the VHDL code for IC 74X189—read and write operations of RAM.
BLOCK DIAGRAM:
TRUTH TABLE:
en_l rw operation
0 0 Write
1 X Inhibit
VHDL code:
library IEEE;
use IEEE.std_logic_1164.all;
entity ram is
port (
rw : in STD_LOGIC;--read or write enable pin
en_l: in STD_LOGIC; --active low enable pin
datain: in STD_LOGIC_VECTOR (3 downto 0);--4-bit input data line
addr: in STD_LOGIC_VECTOR (3 downto 0); --4-bit address line
dataout: out STD_LOGIC_VECTOR (3 downto 0) --4-bit input data line
);
end ram;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
49
E-CAD LAB
begin
process(en_l,rw,addr)
begin
if(en_l='0') then
if (rw ='0') then --performs write operation
memory(conv_integer(addr))<= datain;--stores the data in the
dataout<="ZZZZ"; -- corresponding memory
elsif (rw ='1') then -- the output performs read operation
dataout<=not memory(conv_integer(addr));--places the data on
end if; -- the given address line
else
dataout<=(others=>'Z'); --output is in inhibit state when en_l=’1’(i.e.Hi-
-- impedence)
end if;
end process;
end ram;
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
50
E-CAD LAB
WAVEFORMS:
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
51
E-CAD LAB
VIVA QUESTIONS:
1. Write the behavioral code for IC 74x189 without declaring the function.
2. Explain about different types of RAMs?
3. How to specify the memory size?
4. Explain read and write operations?
5. What are the differences between RAM and RAM?
6. Explain the steps of a compilation process of a VHDL program?
7. Explain the types of design units?
8. Why configurations are needed?
9. What is binding?
10. What is subprogram in vhdl
Prepared By
Y. David Solomon Raju
Associate Professor
Dept. of ECE,
HITS COE
52