Table Of ContentBrock J. LaMeres
Introduction to
Logic Circuits
& Logic Design
with Verilog
Second Edition
I L C &
NTRODUCTION TO OGIC IRCUITS
L D V
OGIC ESIGN WITH ERILOG
I L C &
NTRODUCTION TO OGIC IRCUITS
L D V
OGIC ESIGN WITH ERILOG
2ND EDITION
Brock J. LaMeres
BrockJ.LaMeres
DepartmentofElectrical&ComputerEngineering
MontanaStateUniversity
Bozeman,MT,USA
ISBN978-3-030-13604-8 ISBN978-3-030-13605-5(eBook)
https://doi.org/10.1007/978-3-030-13605-5
LibraryofCongressControlNumber:2019934718
#SpringerNatureSwitzerlandAG2019
Thisworkissubjecttocopyright.AllrightsarereservedbythePublisher,whetherthewholeorpartofthematerialis
concerned,specificallytherightsoftranslation,reprinting,reuseofillustrations,recitation,broadcasting,reproduction
on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic
adaptation,computersoftware,orbysimilarordissimilarmethodologynowknownorhereafterdeveloped.
Theuseofgeneraldescriptivenames,registerednames,trademarks,servicemarks,etc.inthispublicationdoesnot
imply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromtherelevantprotectivelawsand
regulationsandthereforefreeforgeneraluse.
Thepublisher,theauthors,andtheeditorsaresafetoassumethattheadviceandinformationinthisbookarebelieved
tobetrueandaccurateatthedateofpublication.Neitherthepublishernortheauthorsortheeditorsgiveawarranty,
expressorimplied,withrespecttothematerialcontainedhereinorforanyerrorsoromissionsthatmayhavebeen
made.Thepublisherremainsneutralwithregardtojurisdictionalclaimsinpublishedmapsandinstitutionalaffiliations.
ThisSpringerimprintispublishedbytheregisteredcompanySpringerNatureSwitzerlandAG
Theregisteredcompanyaddressis:Gewerbestrasse11,6330Cham,Switzerland
Preface
Theoverallgoalofthisbookistofillavoidthathasappearedintheinstructionofdigitalcircuitsover
thepastdecadedueto therapidabstractionof systemdesign. Upuntilthemid-1980s,digital circuits
were designed using classical techniques. Classical techniques relied heavily on manual design
practicesforthesynthesis,minimization,andinterfacingofdigitalsystems.Correspondingtothisdesign
style,academictextbooksweredevelopedthattaughtclassicaldigitaldesigntechniques.Around1990,
large-scale digital systems began being designed using hardware description languages (HDL) and
automatedsynthesistools.Broad-scaleadoptionofthismoderndesign approachspreadthroughthe
industry during this decade. Around 2000, hardware description languages and the modern digital
design approach began to be taught in universities, mainly at the senior and graduate level. There
wereavarietyofreasonsthatthemoderndigitaldesignapproachdidnotpenetratethelowerlevelsof
academiaduringthistime.First,thedesignandsimulationtoolsweredifficulttouseandoverwhelmed
freshmanandsophomorestudents.Second,theabilitytoimplementthedesignsinalaboratorysetting
wasinfeasible.Themoderndesigntoolsatthetimeweretargetedatcustomintegratedcircuits,which
are cost- and time-prohibitive to implement in a university setting. Between 2000 and 2005, rapid
advances in programmable logic and design tools allowed the modern digital design approach to be
implemented in a university setting, even in lower-level courses. This allowed students to learn the
modern design approach based on HDLs and prototype their designs in real hardware, mainly field-
programmablegatearrays(FPGAs).Thisspurredanabundanceoftextbookstobeauthored,teaching
hardwaredescriptionlanguagesandhigherlevelsofdesignabstraction.Thistrendhascontinueduntil
today.Whileabstractionisacriticaltoolforengineeringdesign,therapidmovementtowardteachingonly
themoderndigitaldesigntechniqueshasleftavoidforfreshman-andsophomore-levelcoursesindigital
circuitry. Legacy textbooks that teach the classical design approach are outdated and do not contain
sufficientcoverageofHDLstopreparethestudentsforfollow-onclasses.Newertextbooksthatteach
themoderndigitaldesignapproachmoveimmediatelyintohigh-levelbehavioralmodelingwithminimal
ornocoverageoftheunderlyinghardwareusedtoimplementthesystems.Asaresult,studentsarenot
being provided the resources to understand the fundamental hardware theory that lies beneath the
modern abstraction such as interfacing, gate-level implementation, and technology optimization.
Students moving too rapidly into high levels of abstraction have little understanding of what is going
onwhentheyclickthe“compileandsynthesize”buttonoftheirdesigntool.Thisleadstograduateswho
can model a breadth of different systems in an HDL but have no depth into how the system is
implementedinhardware.Thisbecomesproblematicwhenanissuearisesinarealdesignandthere
isnofoundationalknowledgeforthestudentstofallbackoninordertodebugtheproblem.
Thisnewbookaddressesthelower-levelfoundationalvoidbyprovidingacomprehensive,bottoms-
up,coverageofdigital systems. Thebookbeginswith adescriptionoflower-levelhardware including
binary representations, gate-level implementation, interfacing, and simple combinational logic design.
Only after a foundation has been laid in the underlying hardware theory is the Verilog language
introduced. The Verilog introduction gives only the basic concepts of the language in order to model,
simulate, and synthesize combinational logic. This allows the students to gain familiarity with the
language and the modern design approach without getting overwhelmed by the full capability of the
language.Thebookthencoverssequentiallogicandfinite-statemachinesatthestructurallevel.Once
thissecondaryfoundationhasbeenlaid,theremainingcapabilitiesofVerilogarepresentedthatallow
sophisticated,synchronoussystemstobemodeled.Anentirechapteristhendedicatedtoexamplesof
sequential system modeling, which allows the students to learn by example. The second part of the
textbookintroducesthedetailsofprogrammablelogic,semiconductormemory,andarithmeticcircuits.
The book culminates with a discussion of computer system design, which incorporates all of the
v
vi (cid:129) Preface
knowledgegainedinthepreviouschapters.Eachcomponentofacomputersystemisdescribedwithan
accompanyingVerilogimplementation,allwhilecontinuallyreinforcingtheunderlyinghardwarebeneath
theHDLabstraction.
Written the Way It Is Taught
Theorganizationofthisbookisdesignedtofollowthewayinwhichthematerialisactuallylearned.
Topics are presented only once sufficient background has been provided by earlier chapters to fully
understandthematerial.Anexampleofthislearning-orientedorganizationishowtheVeriloglanguageis
brokenintotwochapters.Chapter5presentsanintroductiontoVerilogandthebasicconstructstomodel
combinational logic. This is an ideal location to introduce the language because the reader has just
learnedaboutcombinationallogictheoryinChap.4.Thisallowsthestudenttobegingainingexperience
usingtheVerilogsimulationtoolsonbasiccombinationallogiccircuits.Themoreadvancedconstructsof
Verilog,suchassequentialmodelingandtestbenches,arepresentedinChap.8onlyafterathorough
background in sequential logic is presented in Chap. 7. Another example of this learning-oriented
approach is how arithmetic circuits are not introduced until Chap. 12. While technically the arithmetic
circuitsinChap.12arecombinationallogiccircuitsandcouldbepresentedinChap.4,thestudentdoes
not have the necessary background in Chap. 4 to fully understand the operation of the arithmetic
circuitry,soitsintroductionispostponed.
Thisincremental,just-in-timepresentationofmaterialallowsthebooktofollowthewaythematerial
isactuallytaughtintheclassroom.Thisdesignalsoavoidstheneedfortheinstructortoassignsections
thatmovebackandforththroughthetext.Thisnotonlyreducescoursedesigneffortfortheinstructorbut
allowsthestudenttoknowwheretheyareinthesequenceoflearning.Atanypoint,thestudentshould
know the material in prior chapters and be moving toward understanding the material in
subsequentones.
Anadditionaladvantageofthisbook’sorganizationisthatitsupportsgivingthestudenthands-on
experience with digital circuitry for courses with an accompanying laboratory component. The flow is
designedtosupportlabexercisesthatbeginusingdiscretelogicgatesonabreadboardandthenmove
intoHDL-baseddesignsimplementedonoff-the-shelfFPGAboards.Usingthisapproachtoalaboratory
experiencegivesthestudentexperiencewiththebasicelectricaloperationofdigitalcircuits,interfacing,
andHDL-baseddesigns.
Learning Outcomes
Eachchapterbeginswithanexplanationofitslearningobjectivefollowedbyabriefpreviewofthe
chaptertopics.Thespecificlearningoutcomesarethenpresentedforthechapterintheformofconcise
statementsaboutthemeasurableknowledgeand/orskillsthestudentwillbeabletodemonstratebythe
endofthechapter.Eachsectionaddressesasingle,specificlearningoutcome.Thiseasestheprocess
ofassessmentandgivesspecificdetailsonstudentperformance.Thereareover1000assessmenttools
intheformofexerciseproblemsandconceptcheckquestionsthataretieddirectlytospecificlearning
outcomesforbothformativeandsummativeassessment.
Teaching by Example
Withnearly250workedexamples,conceptchecksforeachsection,200+supportingfigures,and
1000+assessmentproblems,studentsareprovidedwithmultiplewaystolearn.Eachtopicisdescribed
in a clear, concise written form with accompanying figures as necessary. This is then followed by
annotatedworkedexamplesthatmatchtheformoftheexerciseproblemsattheendofeachchapter.
Additionally,conceptcheckquestionsareplacedattheendofeachsectioninthebooktomeasurethe
Preface (cid:129) vii
student’s general understanding of the material using a concept inventory assessment style. These
features provide the student multiple ways to learn the material and build an understanding of digital
circuitry.
Course Design
Thebookcanbeusedinmultipleways.Thefirstistousethebooktocovertwo,semester-based
collegecoursesindigitallogic.Thefirstcourseinthissequenceisanintroductiontologiccircuitsand
covers Chaps.1, 2, 3, 4, 5, 6, and7.This introductory course,which isfound in nearlyall accredited
electricalandcomputerengineeringprograms,givesstudentsabasicfoundationindigitalhardwareand
interfacing.Chapters1,2,3,4,5,6,and7onlycoverrelevanttopicsindigitalcircuitstomakeroomfora
thorough introduction to Verilog. At the end of this course, students have a solid foundation in digital
circuitsandareabletodesignandsimulateVerilogmodelsofconcurrentandhierarchicalsystems.The
secondcourseinthissequencecoverslogicdesignusingChaps.8,9,10,11,12,and13.Inthissecond
course, students learn the advanced features of Verilog such as procedural assignments, sequential
behavioralmodeling,systemtasks,andtestbenches.Thisprovidesthebasisforbuildinglargerdigital
systems such as registers, finite-state machines, and arithmetic circuits. Chapter 13 brings all of the
concepts together through the design of a simple 8-bit computer system that can be simulated and
implementedusingmanyoff-the-shelfFPGAboards.
Thisbookcanalsobeusedinamoreaccelerateddigitallogiccoursethatreachesahigherlevelof
abstractioninasinglesemester.Thisisaccomplishedbyskippingsomechaptersandmovingquickly
through others. In this use model, it is likely that Chap. 2 on number systems and Chap. 3 on digital
circuitswouldbequicklyreferencedbutnotcoveredindetail.Chapters4and7couldalsobecovered
quickly in order to move rapidly into Verilog modeling without spending significant time looking at the
underlyinghardwareimplementation.Thisapproachallowsahigherlevelofabstractiontobetaughtbut
providesthestudentwiththereferencematerialsothattheycandelveintothedetailsofthehardware
implementationifinterested.
AllexerciseandconceptproblemsthatdonotinvolveaVerilogmodelaredesignedsothattheycan
be implemented as a multiple-choice or numeric entry question in a standard course management
system. This allows the questions to be automatically graded. For the Verilog design questions, it is
expected that the students will upload their Verilog source files and screenshots of their simulation
waveformstothecoursemanagementsystemformanualgradingbytheinstructororteachingassistant.
Instructor Resources
Instructorsadoptingthisbookcanaccessagrowingcollectionofsupplementarylearningresources
includingYouTubevideoscreatedbytheauthor,asolutionsmanual,alaboratorymanual,andVerilog
testbenchesforallproblems.Additionalresourcesaremadeavailableasdemandgrows.Thegrowing
library of YouTube videos can provide supplementary learning materials for students or facilitate fully
online or flipped delivery of this material. The videos are found at https://www.youtube.com/c/
DigitalLogicProgramming_LaMeres.Thesolutionsmanualcontainsagraphic-richdescriptionofselect
exerciseproblems.Acomplementarylabmanualhasalsobeendevelopedtoprovideadditionallearning
activitiesbasedonboththe74HCdiscretelogicfamilyandanoff-the-shelfFPGAboard.Thismanualis
providedseparatelyfromthebookinordertosupporttheever-changingtechnologyoptionsavailablefor
laboratoryexercises.
viii (cid:129) Preface
What’s New in the Second Edition
The most common request from adopters of the first edition of this book was more assessment
problemsand accompanyingvideos.Asaresult,thesecondeditionnowcontainsover1000assess-
mentquestionsandagrowinglibraryofYouTubevideos.Additionally,moreworkedexampleshavebeen
added so that every section has abundant examples of how to apply the content to designing and
analyzingdigitalcircuits.
Bozeman,MT,USA BrockJ.LaMeres
Acknowledgment
For JoAnn, Alexis, and Kylie. Thank you for your endless support of this project. You are my
inspiration.
ix
Contents
1:INTRODUCTION:ANALOGVERSUSDIGITAL.................................................... 1
1.1 DIFFERENCESBETWEENANALOGANDDIGITALSYSTEMS................................................ 1
1.2 ADVANTAGESOFDIGITALSYSTEMSOVERANALOGSYSTEMS........................................... 3
2:NUMBERSYSTEMS.............................................................................................. 7
2.1 POSITIONALNUMBERSYSTEMS................................................................................... 7
2.1.1 GenericStructure.......................................................................................... 8
2.1.2 DecimalNumberSystem(Base10).............................................................. 9
2.1.3 BinaryNumberSystem(Base2).................................................................. 9
2.1.4 OctalNumberSystem(Base8).................................................................... 10
2.1.5 HexadecimalNumberSystem(Base16)...................................................... 10
2.2 BASECONVERSION................................................................................................... 11
2.2.1 ConvertingtoDecimal................................................................................... 11
2.2.2 ConvertingfromDecimal............................................................................... 14
2.2.3 ConvertingBetween2nBases...................................................................... 18
2.3 BINARYARITHMETIC.................................................................................................. 22
2.3.1 Addition(Carries)........................................................................................... 22
2.3.2 Subtraction(Borrows).................................................................................... 23
2.4 UNSIGNEDANDSIGNEDNUMBERS............................................................................... 25
2.4.1 UnsignedNumbers........................................................................................ 25
2.4.2 SignedNumbers............................................................................................ 26
3:DIGITALCIRCUITRYANDINTERFACING............................................................ 43
3.1 BASICGATES........................................................................................................... 43
3.1.1 DescribingtheOperationofaLogicCircuit.................................................. 43
3.1.2 TheBuffer...................................................................................................... 45
3.1.3 TheInverter................................................................................................... 46
3.1.4 TheANDGate............................................................................................... 46
3.1.5 TheNANDGate............................................................................................ 47
3.1.6 TheORGate................................................................................................. 47
3.1.7 TheNORGate............................................................................................... 47
3.1.8 TheXORGate............................................................................................... 48
3.1.9 TheXNORGate............................................................................................ 49
3.2 DIGITALCIRCUITOPERATION...................................................................................... 50
3.2.1 LogicLevels................................................................................................... 51
3.2.2 OutputDCSpecifications.............................................................................. 51
3.2.3 InputDCSpecifications................................................................................. 53
3.2.4 NoiseMargins................................................................................................ 53
3.2.5 PowerSupplies............................................................................................. 54
3.2.6 SwitchingCharacteristics.............................................................................. 56
3.2.7 DataSheets................................................................................................... 57
xi