Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Slide 38Verilog Synthesis ExamplesCS/EE 3710Fall 2008Mostly from CMOS VLSI Designby Weste and HarrisBehavioral ModelingUsing continuous assignmentsISE can build you a nice adderEasier than specifying your ownBitwise OperatorsBitwise operations act on vectors (buses)More bitwise operatorsReduction OperatorsApply operator to a single vectorReduce to a single bit answerConditional OperatorClassic muxCan be confusing if you get crazyUsing internal signalsInternal wires and regs can be used inside a moduleUsing internal signalsInternal wires and regs can be used inside a moduleOperator PrecedenceConstantsSpecified in binary, octal, decimal, or hexNote use of underscore in long binary numbersHierarchyInstantiate other modules in your moduleTristatesAssign the value zJust say NO! No on-board tri-states on Spartan3e FPGAsUse MUXs instead!Bit TwiddlingSometimes useful to work on part of a bus, or combine different signals togetherUse bus (vector) notationBit TwiddlingSometimes useful to work on part of a bus, or combine different signals togetherUse concatenation {} operatorRegistersEdge-triggered flip flopsAlways use reset of some sort!RegistersCan also add an enable signalOnly capture new data on clock and enCountersBehavioralCountersStructuralComb Logic with Always blocksAlways blocks are often sequentialBut, if you have all RHS variables in the sensitivity list it can be combinationalRemember that you still must assign to a reg typeComb Logic with Always blocksAlways blocks are often sequentialBut, if you have all RHS variables in the sensitivity list it can be combinationalRemember that you still must assign to a reg typeDecoder example (combinational)Decoder example (combinational)Continuous assignment versionis not as readableSame circuit though…Seven Segment DecoderMemoriesGenerally translates to block RAMs on the Spartan3e FPGAShift Register?Blocking vs. Non-BlockingShift Register?Blocking vs. Non-BlockingShift Register?Finite State MachinesDivide into three sectionsState registerNext state logicoutput logicUse parameters for state encodingsExampleThree states, no inputs, one output, two state bitsExampleMealy vs. MooreMealy exampleOutput is true ifinput is the same as it was on the last two cyclesMealy ExampleParameterized ModulesVerilog Style GuideUse only non-blocking assignments in always blocksDefine combinational logic using assign statements whenever practicalUnless if or case makes things more readableWhen modeling combinational logic with always blocks, if a signal is assigned in one branch of an if or case, it needs to be assigned in all branchesVerilog Style GuideInclude default statements in your case statementsUse parameters to define state names and constantsProperly indent your codeUse comments liberally Use meaningful variable namesDo NOT ignore synthesis warnings unless you know what they mean! (then document!)Verilog Style GuideBe very careful if you use both edges of the clockIt’s much safer to stick with one I.e. @(posedge clock) onlyBe certain not to imply latchesWatch for synthesis warnings about implied latchesProvide a reset on all registersVerilog Style GuideProvide a common clock to all registersAvoid gated clocksUse enables
View Full Document