14
1 Welcome to my second year course on Digital Electronics. You will find that the slides are supported by notes embedded with the Powerpoint presentations. All my teaching materials are also available on the course webpage: www.ee.ic.ac.uk/pcheung/teaching/ee2_digital/. The QR code here provides a shortcut to go to the course webpage. I will be updating the notes, the laboratory instructions and tutorial problem sheets each week after the lectures. All my lectures will be recorded with Panopto. The recordings will also be upload as soon as possible after the lectures. The course consists of about 16 hours lectures interleaved with 6 problem solving classes. These will be held on Tuesday 4pm to 6pm and Thursday 12 noon to 1pm starting from 18 th of October. Since I have to be away in the first teaching week on College business, I will also have a catch-up lecture on Friday 21 st of October at 4pm. This course follows on from the first year Digital Electronics I course. Unlike the first year course where all gates and flip-flops are assumed to exhibit ideal behaviour, this course will teach you about real-life circuits. Digital circuits are ubiquitous. For example, there are more electronic modules in cars these days than mechanical systems. A mobile has more transistors than human alive on earth, and most of these transistor are digital, i.e. working as on-off switches. Therefore this second year digital electronics course is fundamental to any EEE or EIE education.

Lecture 2 - Introduction to FPGAs 2... · Xilinx FPGAs also have dedicated switch blocks shown here. Horizontal and vertical wires can be connected through such a switch block with

  • Upload
    buingoc

  • View
    214

  • Download
    1

Embed Size (px)

Citation preview

1

WelcometomysecondyearcourseonDigitalElectronics.YouwillfindthattheslidesaresupportedbynotesembeddedwiththePowerpointpresentations.Allmyteachingmaterialsarealsoavailableonthecoursewebpage:www.ee.ic.ac.uk/pcheung/teaching/ee2_digital/.TheQRcodehereprovidesashortcuttogotothecoursewebpage.Iwillbeupdatingthenotes,thelaboratoryinstructionsandtutorialproblemsheetseachweekafterthelectures.AllmylectureswillberecordedwithPanopto.Therecordingswillalsobeuploadassoonaspossibleafterthelectures.

Thecourseconsistsofabout16hourslecturesinterleavedwith6problemsolvingclasses.ThesewillbeheldonTuesday4pmto6pmandThursday12noonto1pmstartingfrom18th ofOctober.SinceIhavetobeawayinthefirstteachingweekonCollegebusiness,Iwillalsohaveacatch-uplectureonFriday21st ofOctoberat4pm.

ThiscoursefollowsonfromthefirstyearDigitalElectronicsIcourse.Unlikethefirstyearcoursewhereallgatesandflip-flopsareassumedtoexhibitidealbehaviour,thiscoursewillteachyouaboutreal-lifecircuits.

Digitalcircuitsareubiquitous.Forexample,therearemoreelectronicmodulesincarsthesedaysthanmechanicalsystems.Amobilehasmoretransistorsthanhumanaliveonearth,andmostofthesetransistoraredigital,i.e.workingason-offswitches.ThereforethissecondyeardigitalelectronicscourseisfundamentaltoanyEEEorEIEeducation.

2

Lastyearyoulearnedaboutimplementingdigitalcircuitsusinggatessuchastheoneshownhere.YoucanstillbuythischipwithFOURNANDgatesinonepackageandthisisknownasdiscretelogic.Wegenerallydonotusetheseanymore.Itisslow,expensive,consumeslotsofenergyandveryhardtouse.

Nevertheless,itisgoodtolearnaboutNANDandNORgatesbecause,usingDeMorgan’stheorem,youcouldintheorydesignandimplementanInteli7microprocessorusingusetwoinputNANDorNORgatesalone. NANDorNORgatesthereforecouldberegardedasthebuildingblockofalldigitalcircuits.Similarly,youcouldintheorybuildacarusingonlybasicLegoblocks.Unfortunatelysuchacarwouldnotbeverygood.

3

Inearlydaysofintegratedcircuits,designersstartedusingrowsofbasicgates(shownasthedarkstuffherearrangedinrows).Theseareeithercompletelycustomised (full-custom)oritismadewithstandardrowsofgatesbutleavingthegatesunconnected.Foraspecificdesign,thegatesareconnectthroughmetallinesinthewiringchannels.Thereforethecustomisation isonlyinthewiringmetallayersandnotthelayerswithtransistors.Thisisknownas“semi-custom”application-specificintegratedcircuits(ASICs).

4

Ofcourseyoucanalsocustomise everything– eachtransistorandeachwiringconnectedinafull-custommanner.HereisthelayoutofInteli7microprocessor(with4cores).Designingsuchacircuitisveryexpensive,highlyrisky,andoncedesigned,itcannotbechangedeasily.

Mostapplicationsinelectronicindustrycannotaffordtoembarkonsuchadesign.ThisdrivestheriseoftheFieldProgrammableGateArray.

5

SowhatisanFPGA?YoucameacrosstheideaofProgrammableLogicDeviceinthefirstyear,wheretheusercanprogramwhatthelogicgatedoes(beitaNANDorNORorsomeformofSUM-of-PRODUCTimplementation)oranadder,youasauser,can“program” thechiptoperformthatlogicfunction.Nowwecanaddanotherlayerofuserprogrammability– youcanprogramhowtheselogicgatesareconnectedtogether!Inthatway,wehaveageneralprogrammablelogicchip.Unlikethemicroprocessorwheretheprogramisjusttheinstructiontofixdigitalhardware,hereyoucanprogramthehardwareitself!

ThefirstFPGAwasintroducedbyXilinxin1985.Ithasarraysoflogicblockswhichareprogrammable.ItissurroundedbyPROGRAMMABLEROUTINGRESOURCES,whichallowstheusertodefinetheinterconnectionsbetweenthelogicblocks.Italsohaslotsofveryflexibleinputandoutputcircuits(programmableforTTL,CMOSandotherinterfacestandards).

Nowadays,therearetwomajorplayersintheFPGAdomain:XilinxandAltera(nowpartofIntel).Thesetwocompanydominate90%oftheFPGAmarketwithroughlyequalshare.

6

LetuslookinsideanFPGA.Considerthelogicblockshowninblueinthelastslide(AlteracallstheirlogicblockaLogicElement(LE)).TypicallyanLEconsistsofa4-inputLook-upTable(LUT)andaD-flipflop.LetusfornowNOTtoworryabouthowthe4-LUTisimplementedinternally.Justtreatthisasa4-inputcombinatorialcircuitwhichproducesoneoutputsignalasshownhere.TheIMPORTANTcharacteristicisthatthe4-LUTcanbeuserdefined(orprogrammable)toimplementANY4-inputBooleanfunction.Aswewillseelater,thelookuptableisactuallyimplementedwithabunchofmultiplexers.

7

TheLogicElementsaresurroundedbylotsofroutingwiresandinterconnectionswitches.TypicallyasignalwiretotheLogicBlockorLogicElementcanbeconnectedtoanyofthesewiringchannelsthroughaprogrammableconnection(essentiallyadigitalswitch).XilinxFPGAsalsohavededicatedswitchblocksshownhere.Horizontalandverticalwirescanbeconnectedthroughsuchaswitchblockwithprogrammableswitches(fornow,don’tworryhowthat’sdone).

FPGAshavehugeamountoftheseprogrammableresourcesandswitches.Typicallyaverysmallpercentageofthesearebeingconnected(i.e.ON)foragivenapplication.

ThemainadvantageandattractionofFPGAcomesfromtheprogrammableinterconnect– moresothantheprogrammablelogic.

8

ProgramminganFPGAiscalled“configuration”.Inprogrammingacomputerormicroprocessor,wesendtothecomputerinstructioncodesas‘1’sand‘0’s.Theseareinterpreted(ordecoded)bythecomputerwhichwillfollowtheinstructiontoperformtasks.Themicroprocessorneedstobefedtheseprogramcodescontinuouslyforittofunction.

InFPGAs,youonlyneedtoconfigure thechipONCEonpower-up.YoudownloadtothechipaBITSTREAM (alsobitsin‘1’sand‘0’s),whichdeterminesthelogicfunctionsperformedbytheLogicElements,andtheinterconnectingswitchesinordertoconnectthedifferentLEstogethertomakeupyourcircuit.Oncethebitstream isreceived,theFPGAnolongerneedstoreadthe1’sand0’sagain,veryunlikeamicroprocessorwhichhastocontinuallydecodingthemachineinstructions.That’swhywesaythatweconfigure anFPGA(insteadofprogramminganFPGA,althoughthetwowordsareusedinterchangeably).

WhathappenswhenyouconfigureanFPGA?Letusconsiderthe4-inputLUTscircuit.Thisistypicallyimplementusingatreeoffourlayersof2-inputto1-outputmultiplexers.Theentirecircuitisbehavinglikea16-to-1multiplexerusingthe4inputsABCDasthecontroloftheMUXtree.Forexample,ifABCD=0000,thenthetop-mostinputoftheMUXisroutedtoYoutput.

Inthisway,ABCDformstheinputcolumnsofatruthtable.For4-inputs,thetruthtablehas16entries.TheoutputYforeachofthetruthtableentrycorrespondstotheinputoftheMUX.Configurationinvolvesfixingtheinputstothe16-to-1MUXbystoring‘1’ or‘0’ intheregistersR.Changingthe16valuesstored,youcanchangetotruth-tabletoanythingyouwant.

9

Toconfiguretheprogrammablerouting,letuslookathowtheroutingcircuitworks.TakeXilinxSWITCHBLOCKcircuit(greenblocksinslide7).Thisblockcontrolstheconnectionsbetweenfourhorizontalchannelsandfourverticalchannels.Thediamondshapedblockisapotentialinterconnectsite.Insidetheswitchblockcircuit,thereare6transistorswitcheswhichareinitiallyallOFF(oropencircuit).

ThegateinputofEACHswitchiscontrolledbytheoutputofa1-bitregister(e.g.a1-bitD-FF).Iftheregisterstoresa‘1’,theroutingtransistorwillhaveitsgatedrivenhigh.SincethetransistorisannMOS transistor,itwillbecomeconducting.Inthisway,configuringtheroutingresourcessimplymeansthatthecorrect‘1’sand‘0’sarestoredintheregistersthatcontroltheseroutingtransistors.

Asyouwouldexpect,typicallyanFPGAwouldhavehundredsofthousandsoftheseroutingswitches,mostoftheseareOFF.Onceprogrammed,theinterconnectionsaremade.Theboldlinesinthediagramabove(afterprogramming)showstheprogrammedconnections.

Bitsteam informationusedforconfigurationpurposeareusuallystoredonaflashmemorychip,whichisdownloadtotheFPGAduringpower-up– similarto“bootingupacomputer”.Oncethisisdone,theFPGAisprogammed toperformaspecificuserfunction(e.g.yourdesignintheVERIexperiment).

Alternativelyyoucansendthebitstream totheFPGAviaacomputerconnectiontothechip.OntheDE1-SOCboard,itdoesboth.Powerup DE1willconfiguretheCycloneVFPGAchiptoa“waiting”mode,whichmakestheDE1boardtalktothecomputerviatheUSBportwhileflashingthelightsONandOFF.Youthensendtotheboardabitstream ofyourdesignviatheUSBport.

10

LetusnowlookattheFPGAthatyouwilluseforthiscourse.TheAlteraCycloneVFPGAhasamoreadvancedprogrammablelogicelementthanthesimple4-inputLUTthatwehaveconsidereduptonow.ThecallthisaAdaptiveLogicModuleorALM.

AnALMcantakeupto8Booleaninputsignalsandproducesfouroutputswithorwithoutaregister.Additionally,eachALMalsocanperformthefunctionofa2-bitbinaryfulladder.

AsauseroftheCycloneVFPGA,youdon’tactuallyneedtoworrytoomuchaboutexactlyhowtheALMisconfiguredtoimplementyourdesign.TheCADsoftwarewilltakecareofthemappingbetweenyourdesignandthephysicalimplementationusingtheALMs.Itishoweverusefultoknowthatasthetechnologyevolves,moreandmorecomplicatedprogrammablelogicelementsarebeingdevelopedbythemanufacturersinordertoimprovetheareautilizationoftheFPGAs.

TheCycloneVontheDE1-SOCboardhas32,000ALMs,whichcouldbeestimatedtobeequivalentto85K+theoldstyleLEs.Puttingthisincontext,youcouldputontothisonechip2,00032-bitbinaryaddercircuits!

11

TheCycloneVismuchmorethanjustanFPGAwithabunchofLogicElements(orALMs).OurchipintheDE1boardhas32,000ALMs,whichisaround85Koldstyle4-inputLUTLEs.Ontopofthat,italsohasover4Mbitofembeddedmemory,87DSPblocks(todomultiply-accumulateoperationsneededforsignalprocessing),andevenadual-coreARMmicroprocessor!

Ithashard-logictoimplementPCIe interface(tofastperipherals)andexternalmemoryinterfacetoconnecttoexternalmemory.Itisatrulypowerfulchipontowhichonecouldimplementanentiredigitalelectronicsystem.ThereforeAlteracallthisCycloneVSystem-on-Chip(SoC).

12

Forthiscourse,youwillbedesigningcircuitsusingthefreeversionofthedesignsuiteknownasQuartus PrimeLitefromAltera.Youcandownloadyourowncopyontoyournotebookmachine,oryoucanusetheversionsthatareinstalledinanyPCslocatedanywhereinthedepartment.

ThisverypowerfuldesigntoolcontainseverythingyouneedtodesignacomplexdigitalsystemONYOUROWNCOMPUTER!However,thesoftwareonlyrunsoneitheraMSWindowsoraLinuxoperatingsystem.IfyouareusingaMac,youwouldneedtorunaVirtualMachineapplications(suchasVirtualBox)andinstallWindowsorLinuxbeforeinstallingQuartus software.

Bewarethatthesoftwareisverylarge– youneedtohaveseveralGBoffreediskspace.TheminimumrequiredRAMis4GB,and8GBisrecommended.

Ifyourlaptopissuitable,dodownloadthissoftwareandplaywithitathome.

13

ThisslideshowsyouthefunctionalblocksoftheDE1-SoCboard.Thishaseverythingyouneedtestbasicdesignsinvolvingswitches,7-segmentdisplaysandevenaVGAoutput.

14

Ialsoprovideapurpose-builtADC/DACboardtosupportthelabexperiment.Thisadd-onboardinonlyneededinweek3onwardsduringthelaboratorysessions.Sofornow,youcanignoreit.