You are on page 1of 73

K.Sridhar Raju www.engglabs.blogspot.

com
Department of
Electronics & Communication
Engineering
Manual and Obseration !oo"
Electronic Design and #utomation $ab
!%
K.Sridhar Raju
www.engglabs.blogspot.com
1
K.Sridhar Raju www.engglabs.blogspot.com
Department of
Electronics & Communication Engineering
Electronic Design and #utomation $ab
&ame of the student ' (((((((((((((((((((((((((((((((((((((((((((
Class ' ((((((((((((((((((((((((((((((((((((((((((((
Roll &o' ' ((((((((((((((((((((((((((((((((((((((((((((
Semester ' ((((((((((((((((((((((((((((((((((((((((((((
#cad %ear ' ((((((((((((((((((((((((((((((((((((((((((((
2
K.Sridhar Raju www.engglabs.blogspot.com
3
K.Sridhar Raju www.engglabs.blogspot.com
)#R*+#
$,S* O- )RO.R#MS /S,&. 0ER,$O.
1. ARITHMETIC UIT!"ADDER!#!U$TRACT%R!&
2. MU'TI('E)ER!# DE*MU'TI('E)ER!
3. EC%DER!# DEC%DER!#(RI%RIT+ EC%DER AD C%M(ARAT%R
,. - *$IT (ARA''E' U!I. ,*$IT TA!/! AD 0UCTI%!
1. ARITHMETIC '%.IC UIT 2ITH - I!TRUCTI%!.
3. 0'I(* 0'%(!
4. RE.I!TER!5C%UTER!
-. !E6UECE DETECT%R U!I. MEA'+ AD M%%RE T+(E !TATE
MACHIE!
(ART*$
7. $asic 'ogic .ates8 In9erter# AD an: %R.

,
K.Sridhar Raju www.engglabs.blogspot.com
Department of
Electronics & Communication Engineering
Electronic Design and #utomation $ab
ame of t;e stu:ent8
Class $.E8
Roll o8 Aca: +ear8
,&DE1
Sl
&o
&ame of the E2periment Date
Conducted
,nitials of staff
1
K.Sridhar Raju www.engglabs.blogspot.com
3
K.Sridhar Raju www.engglabs.blogspot.com
Department of
Electronics & Communication Engineering
Electronic Design and #utomation $ab
ame of t;e stu:ent8
Class $.E8
Roll o8 Aca: +ear8
,&DE1
Sl
&o
&ame of the E2periment Date
Conducted
,nitials of staff
4
K.Sridhar Raju www.engglabs.blogspot.com
-
K.Sridhar Raju www.engglabs.blogspot.com
0ER,$O.
$,S* O- )RO.R#MS /S,&. 0ER,$O.
1. $A!IC '%.IC .ATE!
2. 0U''*ADDER
3. ,*$IT ADDER
,. MU'TI('E)ER
1. DE*MU'TI('E)ER
3. EC%DER
4. 3)- DEC%DER
-. D*0'I( 0'%(
7. T*0'I( 0'%(
1<. =/ 0'I( 0'%(
11. RI(('E CARR+ C%UTER
12. UI>ER!A' !HI0T RE.I!TER
13. REA'I?ATI% %0 A , >ARIA$'E 0UCTI%
1,. U(5D%2 !+CHR%%U! C%UTER
11. 0IITE !TATE MACHIE DE!I.
7
K.Sridhar Raju www.engglabs.blogspot.com
0ER,$O.
1<
K.Sridhar Raju www.engglabs.blogspot.com
11
K.Sridhar Raju www.engglabs.blogspot.com
12
K.Sridhar Raju www.engglabs.blogspot.com
13
K.Sridhar Raju www.engglabs.blogspot.com
1,
K.Sridhar Raju www.engglabs.blogspot.com
11
K.Sridhar Raju www.engglabs.blogspot.com
13
K.Sridhar Raju www.engglabs.blogspot.com
14
K.Sridhar Raju www.engglabs.blogspot.com
1-
K.Sridhar Raju www.engglabs.blogspot.com
17
K.Sridhar Raju www.engglabs.blogspot.com
2<
K.Sridhar Raju www.engglabs.blogspot.com
21
K.Sridhar Raju www.engglabs.blogspot.com
22
K.Sridhar Raju www.engglabs.blogspot.com
23
K.Sridhar Raju www.engglabs.blogspot.com
2,
K.Sridhar Raju www.engglabs.blogspot.com
21
K.Sridhar Raju www.engglabs.blogspot.com
23
K.Sridhar Raju www.engglabs.blogspot.com
24
K.Sridhar Raju www.engglabs.blogspot.com
2-
K.Sridhar Raju www.engglabs.blogspot.com
27
K.Sridhar Raju www.engglabs.blogspot.com
3<
K.Sridhar Raju www.engglabs.blogspot.com
31
K.Sridhar Raju www.engglabs.blogspot.com
32
K.Sridhar Raju www.engglabs.blogspot.com
!#S,C .#*ES
@timescale 1ns 5 1ps
mo:ule Aasicgate"a#A#p#B#r#s&C
input a#AC
output p#B#r#sC
assign p D a & AC
assign B D a E AC
assign r D a F AC
assign s DG"a & A&C
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule AasictestH9C
55 Inputs
reg aC
reg AC
55 %utputs
Iire pC
Iire BC
Iire rC
Iire sC
55 Instantiate t;e Unit Un:er Test "UUT&
Aasicgate uut "a#A#p#B#r#s&C
initial Aegin
55 InitialiJe Inputs
a D <C
A D <C
55 2ait 1<< ns for gloAal reset to finis;
55 A:: stimulus ;ere
K1<CAD1C
K1<CaD1CAD<C
K1<CAD1C
K1<C
en:
initial
Lmonitor"MaDNA ADNA pDNA BDNA rDNA sDNA timeDN<:M#a#A#p#B#r#s#Ltime&C

En:mo:ule
33
K.Sridhar Raju www.engglabs.blogspot.com
Program 1 :
3#$- #DDER /S,&. D#*# -$O4'
mo:ule ;a:ata"s# c# a# A&C
output sC
output cC
input aC
input AC
assign cDa&AC
assign sDaFAC

en:mo:ule
*ES* !E&C3'
mo:ule tAH;a:ataH9C
55 Inputs
reg aC
reg AC
55 %utputs
Iire sC
Iire cC
55 Instantiate t;e Unit Un:er Test "UUT&
;a:ata uut "
.s"s&#
.c"c&#
.a"a&#
.A"A&
&C
initial Aegin
55 InitialiJe Inputs
a D <C
A D <C
55 2ait 1<< ns for gloAal reset to finis;
K1< AD1C
K1< aD1CAD<C
K1< AD1C

3,
K.Sridhar Raju www.engglabs.blogspot.com
55 A:: stimulus ;ere
en:

en:mo:ule
3#$- #DDER /S,&. .#*E $E0E$'
mo:ule ;agate"s# c# a# A&C
output sC
output cC
input aC
input AC
Oor"s#a#A&C
an:"c#a#A&C
en:mo:ule
*ES* !E&C3'
mo:ule tAH;agateH9C
55 Inputs
reg aC
reg AC
55 %utputs
Iire sC
Iire cC
55 Instantiate t;e Unit Un:er Test "UUT&
;agate uut "
.s"s&#
.c"c&#
.a"a&#
.A"A&
&C
initial Aegin
55 InitialiJe Inputs
a D <C
A D <C
55 2ait 1<< ns for gloAal reset to finis;
31
K.Sridhar Raju www.engglabs.blogspot.com
K1< AD1C
K1< aD1CAD<C
K1< AD1C

55 A:: stimulus ;ere
en:

en:mo:ule
-ull adder using .ate leel modelling
@timescale 1ns 5 1ps
mo:ule fulla::er "sum#cout#a#A#cin&C
output sum#coutC
input a#A#cinC
Iire s1#c1#c2C
Oor "s1#a#A&C
an: "c1#a#A&C
Oor "sum#s1#cin&C
an: "c2#s1#cin&C
Oor "cout#c2#c1&C
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule fulla::testH9C
reg a#A#cinC
Iire sum#coutC
fulla::er fa1 "sum#cout#a#A#cin&C
initial
Aegin
aD<CAD<CcinD<C
K1<
K1< aD<CAD1C
K1< aD1CAD<C
K1< aD1CAD1C
33
K.Sridhar Raju www.engglabs.blogspot.com
K1< aD<CAD<CcinD1C
K1< aD<CAD1C
K1< aD1CAD<C
K1< aD1CAD1C
K1<C
en:
initial
Lmonitor"MaDNA#ADNA#cinDNA#sumDNA#coutDNAM#a#A#cin#sum#cout&C
en:mo:ule
3#$- S/!*R#C*OR /S,&. D#*# -$O4'
mo:ule ;s:ata":# Ao# a# A&C
output :C
output AoC
input aC
input AC
assign :DaFAC
assign AoD"Ga&&AC

en:mo:ule
TE!T $ECH8
mo:ule tAH;s:ataH9C
55 Inputs
reg aC
reg AC
55 %utputs
Iire :C
Iire AoC
55 Instantiate t;e Unit Un:er Test "UUT&
;s:ata uut "
.:":&#
.Ao"Ao&#
.a"a&#
.A"A&
&C
34
K.Sridhar Raju www.engglabs.blogspot.com
initial Aegin
55 InitialiJe Inputs
a D <C
A D <C
55 2ait 1<< ns for gloAal reset to finis;
K1< AD1C
K1< aD1CAD<C
K1< AD1C

55 A:: stimulus ;ere
en:

en:mo:ule
0U'' !U$TRACT%R U!I. .ATE 'E>E'8
mo:ule fsgate":# Ao# a# A# cin&C
output :C
output AoC
input aC
input AC
input cinC
Iire I1#I2#I3#I,C
Oor O1":#a#A#cin&C

not "I1#a&C
an: a1"I2#I1#A&C
an: a2"I,#I1#cin&C
an: a3"I3#A#cin&C
or"Ao#I2#I3#I,&C
en:mo:ule
TE!T $ECH8
mo:ule tAHfsgateH9C
55 Inputs
reg aC
reg AC
reg cinC
3-
K.Sridhar Raju www.engglabs.blogspot.com
55 %utputs
Iire :C
Iire AoC
55 Instantiate t;e Unit Un:er Test "UUT&
fsgate uut "
.:":&#
.Ao"Ao&#
.a"a&#
.A"A&#
.cin"cin&
&C
initial Aegin
55 InitialiJe Inputs
a D <C
A D <C
cin D <C
55 2ait 1<< ns for gloAal reset to finis;
K1< cinD1C
K1< AD1CcinD<C
K1< cinD1C
K1< aD1CAD<CcinD<C
K1< cinD1C
K1< AD1CcinD<C
K1< cinD1C

55 A:: stimulus ;ere
en:

en:mo:ule
5 bit adder
@timescale 1ns 5 1ps
mo:ule fourAa::er"sum#cout#a#A#cin&C
output P38<Q sumC
output coutC
37
K.Sridhar Raju www.engglabs.blogspot.com
input cinC
input P38<Q a#AC
Iire c1#c2#c3C
fulla::er fa< "sumP<Q#c1#aP<Q#AP<Q#cin&C
fulla::er fa1 "sumP1Q#c2#aP1Q#AP1Q#c1&C
fulla::er fa2 "sumP2Q#c3#aP2Q#AP2Q#c2&C
fulla::er fa3 "sumP3Q#cout#aP3Q#AP3Q#c3&C
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule foutAtestH9C
reg P38<Q a#AC
reg cinC
Iire P38<Q sumC
Iire coutC
fourAa::er fr1 "sum#cout#a#A#cin&C
initial
Aegin
aD,R:<CAD,R:<CcinD1C
K1< aD,R:3CAD,R:,C
K1< aD,R:2CAD,R:-C
K1< aD,R:7CAD,R:7C
K1< aD,R:1<CAD,R:11C
K1<
Lmonitor "MaDNA#ADNA#cinDNA #..cout DNA#sum DNA..SnM#a#A#cin#cout#sum&C
en:
en:mo:ule
0%UR $IT $IAR+ !U$TRACT%R8
mo:ule As,fs":# Ao# a# A# cin&C
output P38<Q :C
output AoC
input P38<Q aC
input P38<Q AC
input cinC
Iire A<#A1#A2C
fsgate f1":P<Q#A<#aP<Q#AP<Q#cin&C
,<
K.Sridhar Raju www.engglabs.blogspot.com
fsgate f2":P1Q#A1#aP1Q#AP1Q#A<&C
fsgate f3":P2Q#A2#aP2Q#AP2Q#A1&C
fsgate f,":P3Q#Ao#aP3Q#AP3Q#A2&C
en:mo:ule
*ES* !E&C3'
mo:ule tAHAs,fsH9C
55 Inputs
reg P38<Q aC
reg P38<Q AC
reg cinC
55 %utputs
Iire P38<Q :C
Iire AoC
55 Instantiate t;e Unit Un:er Test "UUT&
As,fs uut "
.:":&#
.Ao"Ao&#
.a"a&#
.A"A&#
.cin"cin&
&C
initial Aegin
55 InitialiJe Inputs
a D ,RA<<<<C
A D ,RA<<<<C
cin D <C
55 2ait 1<< ns for gloAal reset to finis;
K1< aD,RA<<11CAD,RA<<<1C
K1< aD,RA<111CAD,RA<<<1CcinD1C
K3<< Lfinis;C
55 A:: stimulus ;ere
en:

en:mo:ule
,1
K.Sridhar Raju www.engglabs.blogspot.com
)RO.R#M 6
517 Multiple2er
@timescale 1ns 5 1ps
mo:ule muO"J#a#A#c#:#s1#s<&C
output JC
input s1#s<#a#A#c#:C
Iire s1Aar#s<Aar#i<#i1#i2#i3C
not not1 "s1Aar#s1&C
not not2 "s<Aar#s<&C
an: an:1 "i<#s1Aar#s<Aar#a&C
an: an:2 "i1#s1Aar#s<#A&C
an: an:3 "i2#s1#s<Aar#c&C
an: an:, "i3#s1#s<#:&C
or or1 "J#i<#i1#i2#i3&C
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule muOtestH9C
reg a#A#c#:#s1#s<C
Iire JC
muO m1 "J#a#A#c#:#s1#s<&C
initial
Aegin
a D <CA D 1Cc D 1C: D <C
s1D<Cs<D<C
K1< s1D<Cs<D1C
K1< s1D1Cs<D<C
K1< s1D1Cs<D1C
K1< a D 1CA D <Cc D <C: D 1C
s1D<Cs<D<C
K1< s1D<Cs<D1C
K1< s1D1Cs<D<C
K1< s1D1Cs<D1C
K1<C
en:
en:mo:ule
,2
K.Sridhar Raju www.engglabs.blogspot.com
Demultiple2er
@timescale 1ns 5 1ps
mo:ule :emuO"s#i#o&C
input P28<Q sC
input iC
output P48<Q oC
IireP28<Q sAC
assign sAP<Q DGsP<QC
assign sAP1QD GsP1QC
assign sAP2QD GsP2QC
assign oP<Q D i& sAP2Q & sAP1Q & sAP<QC 55 <<<
assign oP1Q D i& sAP2Q & sAP1Q & sP<QC 55 <<1
assign oP2Q D i& sAP2Q & sP1Q & sAP<QC 55 <1<
assign oP3Q D i& sAP2Q & sP1Q & sP<QC 55 <11
assign oP,Q D i& sP2Q & sAP1Q & sAP<QC 55 1<<
assign oP1Q D i& sP2Q & sAP1Q & sP<QC 55 1<1
assign oP3Q D i& sP2Q & sP1Q & sAP<QC 55 11<
assign oP4Q D i& sP2Q & sP1Q & sP<QC 55 111
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule :emuOtestH9C
reg P28<Q sC
reg iC
Iire P48<Q oC
:emuO :m1 "s#i#o&C
initial
Aegin
iD1CsD3RA<<<C
K1< sD3RA<<1C
K1< sD3RA<1<C
K1< sD3RA<11C
K1< sD3RA1<<C
K1< sD3RA1<1C
K1< sD3RA11<C
K1< sD3RA111C
K1<C
en:
initial
Lmonitor"MiDNA#sDN:#oDN:M#i#s#o&C
En:mo:ule
,3
K.Sridhar Raju www.engglabs.blogspot.com
)RO.R#M 8 ' Encoders9 Decoders9 )riorit: Encoder and Comparator
Encoder
@timescale 1ns 5 1ps
mo:ule enco:er "D#J&C
input P48<Q DC
output P28<Q JC
assign JP2Q D DP,QE DP1QE DP3QE DP4QC
assign JP1Q D DP2QE DP3QE DP3QE DP4QC
assign JP<Q D DP1QE DP3QE DP1QE DP4QC
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule enco:etestH9C
reg P48<Q DC
Iire P28<Q JC
enco:er en1 "D#J&C
initial
Aegin
DD-R:<C
K1<< DD-R:1C
K1<< DD-R:2C
K1<< DD-R:,C
K1<< DD-R:-C
K1<< DD-R:13C
K1<< DD-R:32C
K1<< DD-R:3,C
K1<< DD-R:12-C
K1<< C
en:
initial
Lmonitor"MDDN:# JDN:M#D#J&C
en:mo:ule
,,
K.Sridhar Raju www.engglabs.blogspot.com
81; Decoder
@timescale 1ns 5 1ps
mo:ule :ec3-"i#o&C
input P28<QiC
output P48<QoC
reg P48<QoC
integer nC
alIaTs U"i&
Aegin
for"nD<CnVD4CnDnW1&
Aegin
if"iDDn&
oPnQD1C
else
oPnQD<C
en:
en:
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule :ectestH9C
reg P28<Q iC
Iire P48<Q oC
:ec3- :1 "i#o&C
initial
Aegin
K1< iD3RA<C
K1< iD3RA<<1C
K1< iD3RA<1<C
K1< iD3RA<11C
K1< iD3RA1<<C
K1< iD3RA1<1C
K1< iD3RA11<C
K1< iD3RA111C
K1< iD3RA<C
K1< iDMOOOMC
K1<C
Lmonitor"MiDNA oDNA timeDN<:M#i#o#Ltime&C
en:
en:mo:ule
,1
K.Sridhar Raju www.engglabs.blogspot.com
)R,OR,*% E&CODER'
mo:ule prioritTenco:er"out# :ontcare# in# en&C
output reg P28<Q outC
output reg :ontcareC
input P48<Q inC
input enC
alIaTsU"X&
Aegin
:ontcareD1C
if "enDD1&
case"in&
-RA<<<<<<<18outD3RA<<<C
-RA<<<<<<1O8outD3RA<<1C
-RA<<<<<1OO8outD3RA<1<C
-RA<<<<1OOO8outD3RA<11C
-RA<<<1OOOO8outD3RA1<<C
-RA<<1OOOOO8outD3RA1<1C
-RA<1OOOOOO8outD3RA11<C
-RA1OOOOOOO8outD3RA111C
:efault8Aegin
:ontcareD<C
outD3RAOOOC
en:
en:case
else
L:isplaT"MEnco:er DisaAle:M&C
en:

en:mo:ule
*ES* !E&C3'
mo:ule tAHprioritTenco:erH9C
55 Inputs
reg P48<Q inC
reg enC
55 %utputs
Iire P28<Q outC
Iire :ontcareC
55 Instantiate t;e Unit Un:er Test "UUT&
prioritTenco:er uut "
.out"out&#
,3
K.Sridhar Raju www.engglabs.blogspot.com
.:ontcare":ontcare&#
.in"in&#
.en"en&
&C
initial Aegin
55 InitialiJe Inputs
in D -RA<<<<<<<1C
en D 1C
55 2ait 1<< ns for gloAal reset to finis;
K1< inD-RA<<<<<<1OC
K1< inD-RA<<<<<1OOC

55 A:: stimulus ;ere
en:

en:mo:ule
5 !,* COM)#R#*OR'
mo:ule comparator"aeBA# altA# agtA# a# A&C
output reg aeBAC
output reg altAC
output reg agtAC
input P38<Q aC
input P38<Q AC
alIaTsU"a#A&
if"aDDA&
Aegin
aeBAD1RA1C
altAD1RA<C
agtAD1RA<C
en:
else if"aVA&
Aegin
aeBAD1RA<C
altAD1RA1C
agtAD1RA<C
en:
else
Aegin
aeBAD1RA<C
altAD1RA<C
,4
K.Sridhar Raju www.engglabs.blogspot.com
agtAD1RA1C
en:

en:mo:ule
*ES* !E&C3'
mo:ule tAHcomparatorH9C
55 Inputs
reg P38<Q aC
reg P38<Q AC
55 %utputs
Iire aeBAC
Iire altAC
Iire agtAC
55 Instantiate t;e Unit Un:er Test "UUT&
comparator uut "
.aeBA"aeBA&#
.altA"altA&#
.agtA"agtA&#
.a"a&#
.A"A&
&C
initial Aegin
55 InitialiJe Inputs
a D ,RA<<<<C
A D ,RA<<<<C
55 2ait 1<< ns for gloAal reset to finis;
K1< aD,RA<<<1CAD,RA<<11C
K1< aD,RA<111C

55 A:: stimulus ;ere
en:

en:mo:ule
,-
K.Sridhar Raju www.engglabs.blogspot.com
)RO.R#M 5' )arallel #dder using *as"s and -unctions
; !,* )#R#$$E$ #DDER /S,&. *#SK'
mo:ule Aita::er1"sum# carrTout# O# T# carrTin&C
output reg P48<Q sumC
output reg carrToutC
input P48<Q OC
input P48<Q TC
input carrTinC
reg c1C
alIaTsU"O#T#carrTin&
Aegin
fulla::, "sumP38<Q#c1#OP38<Q#TP38<Q#carrTin&C
fulla::, "sumP48,Q#carrTout#OP48,Q#TP48,Q#c1&C
en:
tasY automatic fulla::,C
output P38<QsC
output coutC
input P38<QaC
input P38<QAC
input cinC
Aegin
Zcout#s[Da W A W cinC
en:
en:tasY
en:mo:ule
,7
K.Sridhar Raju www.engglabs.blogspot.com
*ES* !E&C3'
mo:ule tAHAita::erH9C
55 Inputs
reg P48<Q OC
reg P48<Q TC
reg carrTinC
55 %utputs
Iire P48<Q sumC
Iire carrToutC
55 Instantiate t;e Unit Un:er Test "UUT&
Aita::er1 uut "
.sum"sum&#
.carrTout"carrTout&#
.O"O&#
.T"T&#
.carrTin"carrTin&
&C
initial Aegin
55 InitialiJe Inputs
O D <C
T D <C
carrTin D <C
55 2ait 1<< ns for gloAal reset to finis;
K1< OD-RA<<<<<1<<CTD-RA<<<<<<11C
K1< OD-RA<<<<<<<1CTD-RA<<<<<<<1C
K1< OD-RA<<<<<1<<CTD-RA<<<<<<11CcarrTinD1C
K1< OD-RA<<<<<1<<CTD-RA<<<<<<11CcarrTinD<C
55 A:: stimulus ;ere
en:

en:mo:ule
1<
K.Sridhar Raju www.engglabs.blogspot.com
; !,* )#R#$$E$ #DDER /S,&. -/&C*,O&'
mo:ule pausingfnc"sum# carrTout# O# T# carrTin&C
output reg P48<Q sumC
output reg carrToutC
input P48<Q OC
input P48<Q TC
input carrTinC
reg c1C
alIaTs U"O#T#carrTin&
Aegin
Zc1#sumP38<Q[Dfulla::,"OP38<Q#TP38<Q#carrTin&C
ZcarrTout#sumP48,Q[Dfulla::,"OP48,Q#TP48,Q#c1&C
en:
function automatic P38<Qfulla::,C
input P38<Qa#AC
input cinC
reg P38<QsC
reg coutC
Aegin
fulla::,DaWAWcinC
en:
en:function
en:mo:ule
11
K.Sridhar Raju www.engglabs.blogspot.com
*ES* !E&C3'
mo:ule tAHpausingfncH9C
55 Inputs
reg P48<Q OC
reg P48<Q TC
reg carrTinC
55 %utputs
Iire P48<Q sumC
Iire carrToutC
55 Instantiate t;e Unit Un:er Test "UUT&
pausingfnc uut "
.sum"sum&#
.carrTout"carrTout&#
.O"O&#
.T"T&#
.carrTin"carrTin&
&C
initial Aegin
55 InitialiJe Inputs
O D <C
T D <C
carrTin D <C
55 2ait 1<< ns for gloAal reset to finis;
K1< OD-RA<<<<<1<<CTD-RA<<<<<<11C
K1< carrTinD1C
K1< OD-RA<<<<1<<<CTD-RA<<<<<111CcarrTinD<C
55 A:: stimulus ;ere
en:

en:mo:ule
12
K.Sridhar Raju www.engglabs.blogspot.com
)rogram <' #rithmetic and $ogical unit with minimum of Eight ,nstructions
#$/'
mo:ule alu"f# s# a# A&C
output reg P38<Q fC
input P28<Q sC
input P38<Q aC
input P38<Q AC
alIaTsU"s#a#A&
case"s&
3RA<<<8fDaWAC
3RA<<18fDa*AC
3RA<1<8fDaXAC
3RA<118fDaW1C
3RA1<<8fDa*1C
3RA1<18fDaFAC
3RA11<8fDaEAC
3RA1118fDa&AC
:efault8L:isplaT"Min9ali: :isplaTM&C
en:case
en:mo:ule
*ES* !E&C3'
mo:ule tAHaluH9C
55 Inputs
reg P28<Q sC
reg P38<Q aC
reg P38<Q AC
55 %utputs
Iire P38<Q fC
55 Instantiate t;e Unit Un:er Test "UUT&
alu uut "
.f"f&#
.s"s&#
.a"a&#
.A"A&
&C
initial Aegin
55 InitialiJe Inputs
13
K.Sridhar Raju www.engglabs.blogspot.com
s D 3RA<<<C
a D ,RA<<1<C
A D ,RA<<1<C
55 2ait 1<< ns for gloAal reset to finis;
K1< sD3RA<<1C
K1< sD3RA<11C
K1< sD3RA111C

55 A:: stimulus ;ere
en:

en:mo:ule
1,
K.Sridhar Raju www.engglabs.blogspot.com
)RO.R#M =' -lip+flops
D -lip flop
@timescale 1ns 5 1ps
mo:ule DH00"B# :# clY# reset&C
output BC
input :# clY# resetC
reg BC
alIaTs U"pose:ge reset or nege:ge clY&
if "reset&
B VD 1RA<C
else
B VD :C
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule :fftestH9C
reg :#clY#resetC
Iire BC
DH00 :1"B# :# clY# reset&C
initial
clY D 1RA<C
alIaTs
K1 clY D GclYC
initial
: D 1RA1C
alIaTs
K2< : D G:C
initial
Aegin
reset D 1RA1C
K11 reset D 1RA<C
K1-< reset D 1RA1C
K,< reset D 1RA<C
K2< Lfinis;C
en:
initial
Lmonitor"Ltime# M %utput B D N:M# B&C
en:mo:ule
11
K.Sridhar Raju www.engglabs.blogspot.com
* -lip flop
@timescale 1ns 5 1ps
mo:ule TH00"B# clY# reset&C
output BC
input clY# resetC
Iire :C
DH00 :ff<"B# :# clY# reset&C
not n1":# B&C
en:mo:ule
*est !ench'
@timescale 1ns 5 1ps
mo:ule tfftestH9C
reg clY#resetC
Iire BC
TH00 t1"B# clY# reset&C
initial
clY D 1RA<C
alIaTs
K1 clY D GclYC
initial
Aegin
reset D 1RA1C
K11 reset D 1RA<C
K1-< reset D 1RA1C
K,< reset D 1RA<C
K2< Lfinis;C
en:
initial
Lmonitor"Ltime# M %utput B D N:M# B&C
en:mo:ule
13
K.Sridhar Raju www.engglabs.blogspot.com
>K -lip flop
@timescale 1ns 5 1ps
mo:ule \Yff"\#Y#clY#B&C
output BC
input \#Y#clYC
reg BC
alIaTs U"pose:ge clY or nege:ge clY&
case"Z\#Y[&
2RA<<8 B D BC
2RA<18 B D 1RA<C
2RA1<8 B D 1RA1C
2RA118 B D GBC
en:case
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule \YtestH9C
reg \#Y#clYC
Iire BC
\Yff \Y1 "\#Y#clY#B&C
initial
clY D <C
alIaTs
K1< clY D GclYC
initial
Aegin
Z\#Y[D2RA<<C
K1< Z\#Y[D2RA<1C
K1< Z\#Y[D2RA1<C
K1< Z\#Y[D2RA11C
en:
initial
Lmonitor"MtimeDN<: clYDN<: BDNA \DNA YDNAM#Ltime#clY#B#\#Y&C
en:mo:ule
14
K.Sridhar Raju www.engglabs.blogspot.com
)rogram ?' Registers@Counters
Ripple carr: counter
@timescale 1ns 5 1ps
mo:ule ripplecounter"B#clY#reset&C
outputP38<Q BC
input clY#resetC
TH00 tff<"BP<Q#clY# reset&C
TH00 tff1"BP1Q#BP<Q# reset&C
TH00 tff2"BP2Q#BP1Q# reset&C
TH00 tff3"BP3Q#BP2Q# reset&C
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule ripptestH9C
reg clY#resetC
IireP38<Q BC
ripplecounter r1"B# clY# reset&C
initial
clY D 1RA<C
alIaTs
K1 clY D GclYC
initial
Aegin
reset D 1RA1C
K11 reset D 1RA<C
K1-< reset D 1RA1C
K1< reset D 1RA<C
K2< Lfinis;C
en:
initial
Lmonitor"Ltime# M %utput B D N:M# B&C
en:mo:ule
1-
K.Sridhar Raju www.engglabs.blogspot.com
/niersal shift register
@timescale 1ns 5 1ps
mo:ule unis;ift"B#p:#clr#s#lsin#rsin#clY&C
output P38<QBC
input P38<Qp:C
input P18<QsC
input clr#lsin#rsin#clYC
reg P38<Q BC
alIaTs U"pose:ge clY or nege:ge clY or nege:ge clr or pose:ge clr&
Aegin
if"clr&
BD,RA<<<<C
else
case"s&
2RA<<8C
2RA<18BDZBP28<Q#rsin[C
2RA1<8BDZlsin#BP381Q[C
2RA118BDp:C
en:case
en:
en:mo:ule
*est bench'
@timescale 1ns 5 1ps
mo:ule s;ifttestH9C
reg P38<Q p:C
reg P18<Q sC
reg clr#lsin#rsin#clYC
Iire P38<Q BC
unis;ift s;i1 "B#p:#clr#s#lsin#rsin#clY&C
initial
clYD<C
alIaTs
K1< clY D GclYC
17
K.Sridhar Raju www.engglabs.blogspot.com
initial clrD<C
alIaTs
K1< clr D GclrC
initial
Aegin
p: D ,RA<<11C
clr D <C
s D 2RA<<C
lsin D 1C
rsin D 1C
K1< sD2RA<1C
K1< sD2RA1<C
K1< sD2RA11C
K1<C
en:
initial
Lmonitor"MtimeDN<: clYDNA clrDNA sDNA BDNAM#Ltime#clY#clr#s#B&C

en:mo:ule
/p@down s:nchronous counter
@timescale 1ns 5 1ps
mo:ule sTncount"B#p:#loa:#up:oIn#clY&C
input loa:#clY#up:oInC
input P38<Qp:C
output P38<QBC
reg P38<QBC
alIaTs U"pose:ge clY&
Aegin
if"loa:&
BDp:C
else if"up:oIn&
BDBW1C
else
BDB*1C
en:
en:mo:ule
3<
K.Sridhar Raju www.engglabs.blogspot.com
*est bench'
@timescale 1ns 5 1ps
mo:ule tAsTncH9C
reg P38<Q p:C
reg loa:C
reg up:oInC
reg clYC
Iire P38<Q BC
sTncount s1"B#p:#loa:#up:oIn#clY&C
initial
clY D <C
alIaTs
K1< clY D GclYC
initial
p: D ,RA<1<1C
initial
Aegin
K1 loa:D1C
K1< loa:D<C
en:
initial
Aegin
up:oInD1C
K1<< up:oInD<C
K1< up:oInD1C
K1<< Lfinis;C
en:
initial
Lmonitor"MtimeDN<: p:DNA up:oInDNA clYDNA loa:DNA
BDNAM#Ltime#p:#up:oIn#clY#loa:#B&C

en:mo:ule
31
K.Sridhar Raju www.engglabs.blogspot.com
Program 8 : Sequence Detector using Moore /Mealy
MOORE*%)E 777 SEA/E&CE DE*EC*OR'
mo:ule mooretTpe111"T#O#clY#rst&C
output TC
input OC
input clYC
input rstC
parameter state<D2RA<<C
parameter state1D2RA<1C
parameter state2D2RA1<C
parameter state3D2RA11C
regP18<Q presentHstate#neOtHstateC
alIaTs U"pose:ge clY or nege:ge rst&
Aegin
if"rstDD1RA<&
presentHstateVDstate<C
else
presentHstateVDneOtHstateC
en:
alIaTs U"O or presentHstate&
Aegin
case"presentHstate&
state<8if"ODD1RA1&
neOtHstateVDstate1C
else if"ODD1RA<&
neOtHstateVDstate<C
state18if"ODD1RA1&
neOtHstateVDstate2C
else if"ODD1RA<&
neOtHstateVDstate<C
state28if"ODD1RA1&
neOtHstateVDstate3C
else if"ODD1RA<&
neOtHstateVDstate<C
state38if"ODD1RA1&
neOtHstateVDstate1C
else if"ODD1RA<&
neOtHstateVDstate<C
en:case
en:
assign TD"neOtHstateDDstate3&C
en:mo:ule
32
K.Sridhar Raju www.engglabs.blogspot.com
*ES* !E&C3'
mo:ule tAHmooretTpe111H9C
55 Inputs
reg OC
reg clYC
reg rstC
55 %utputs
Iire TC
55 Instantiate t;e Unit Un:er Test "UUT&
mooretTpe111 uut "
.T"T&#
.O"O&#
.clY"clY&#
.rst"rst&
&C
initial Aegin
55 InitialiJe Inputs
O D <C
clY D <C
rst D <C
55 2ait 1<< ns for gloAal reset to finis;
K11 rstD1C

55 A:: stimulus ;ere
en:
alIaTs Aegin
K,1 OD1C
K,1 OD1C
K,1 OD1C
K,1 OD<C
en:
alIaTs K11 clYDGclYC

en:mo:ule
33
K.Sridhar Raju www.engglabs.blogspot.com
ME#$% *%)E'
mo:ule mealTtTpe"T# O# clY# rst&C
output reg TC
input OC
input clYC
input rstC
parameter state<D2RA<<C
parameter state1D2RA<1C
parameter state2D2RA1<C
parameter state3D2RA11C
regP18<Q presentHstate#neOtHstateC
alIaTs U"pose:ge clY or nege:ge rst&
Aegin
if"rstDD1RA<&
presentHstateVDstate<C
else
presentHstateVDneOtHstateC
en:
alIaTs U"O or presentHstate&
Aegin
case"presentHstate&
state<8if"ODD1RA1&
neOtHstateVDstate1C
TVD1RA<C
en:
else if"ODD1RA<&
Aegin
neOtHstateVDstate<C
TVD1RA<C
en:
state18if"ODD1RA1&
Aegin
neOtHstateVDstate2C
TVD1RA<C
en:
else if"ODD1RA<&
Aegin
neOtHstateVDstate<C
TVD1RA<C
en:
state28if"ODD1RA1&
Aegin
neOtHstateVDstate3C
TVD1RA<C
3,
K.Sridhar Raju www.engglabs.blogspot.com
en:
else if"ODD1RA<&
Aegin
neOtHstateVDstate<C
TVD1RA<C
en:
state38if"ODD1RA1&
Aegin
neOtHstateVDstate1C
TVD1RA<C
en:
else if"ODD1RA<&
Aegin
neOtHstateVDstate<C
TVD1RA<C
en:
en:case
en:
assign TD"neOtHstateDDstate3&C
en:mo:ule
*ES* !E&C3'
mo:ule tAHmealTtTpeH9C
55 Inputs
reg OC
reg clYC
reg rstC
55 %utputs
Iire TC
55 Instantiate t;e Unit Un:er Test "UUT&
mealTtTpe uut "
.T"T&#
.O"O&#
.clY"clY&#
.rst"rst&
&C
initial Aegin
55 InitialiJe Inputs
O D <C
clY D <C
31
K.Sridhar Raju www.engglabs.blogspot.com
rst D <C
55 2ait 1<< ns for gloAal reset to finis;
K11 rstD1C

55 A:: stimulus ;ere
en:
alIaTs Aegin
K,1 OD1C
K,1 OD1C
K,1 OD1C
K,1 OD<C
en:
alIaTs K11 clYDGclYC

en:mo:ule
33
K.Sridhar Raju www.engglabs.blogspot.com
(ART*$
$asic 'ogic .ates8 In9erter# AD an: %R.
AIM 8 To simulate t;e CM%! In9erter circuit using CADECE an: oAser9e its input an: output
2a9eforms.
A((ARATU! 8 Ca:ence Tool
!c;ematic8
34
K.Sridhar Raju www.engglabs.blogspot.com
EOpecte: 2a9eforms 8 Transient Response8
Result8 T;e response of CM%! in9erter is oAser9e: for t;e gi9en input Ia9eform.
3-
K.Sridhar Raju www.engglabs.blogspot.com
AIM 8 To simulate t;e CM%! AD .ate using CADECE an: oAser9e its input an: output
2a9eforms.
A((ARATU! 8 Ca:ence Tool
!c;ematic8
EOpecte: 2a9eforms 8 Transient Response8
37
K.Sridhar Raju www.engglabs.blogspot.com
Result 8 T;e response of CM%! AD .ATE is oAser9e: for t;e gi9en input Ia9eform.
4<
K.Sridhar Raju www.engglabs.blogspot.com
AIM 8 To simulate t;e CM%! AD .ate using CADECE an: oAser9e its input an: output
2a9eforms.
A((ARATU! 8 Ca:ence Tool
!c;ematic8
41
K.Sridhar Raju www.engglabs.blogspot.com
EOpecte: 2a9eforms 8 Transient Response8
Result 8 T;e response of CM%! %R .ATE is oAser9e: for t;e gi9en input Ia9eform.
42
K.Sridhar Raju www.engglabs.blogspot.com
43

You might also like