Lecture5簡(jiǎn)單數(shù)字電路設(shè)計(jì)-組合電路.ppt
《Lecture5簡(jiǎn)單數(shù)字電路設(shè)計(jì)-組合電路.ppt》由會(huì)員分享,可在線(xiàn)閱讀,更多相關(guān)《Lecture5簡(jiǎn)單數(shù)字電路設(shè)計(jì)-組合電路.ppt(26頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
VerilogHDL語(yǔ)言,華中科技大學(xué)計(jì)算機(jī)科學(xué)與技術(shù)學(xué)院,主講:胡迪青Email:hudq024@QQ:121374333,2,簡(jiǎn)單數(shù)字電路設(shè)計(jì),3,設(shè)計(jì)驗(yàn)證與仿真,VerilogHDL不僅提供描述設(shè)計(jì)的能力,而且提供對(duì)激勵(lì)、控制、存儲(chǔ)響應(yīng)和設(shè)計(jì)驗(yàn)證的建模能力。激勵(lì)和控制可用初始化語(yǔ)句產(chǎn)生。驗(yàn)證運(yùn)行過(guò)程中的響應(yīng)可以作為“變化時(shí)保存”或作為選通的數(shù)據(jù)存儲(chǔ)。最后,設(shè)計(jì)驗(yàn)證可以通過(guò)在初始化語(yǔ)句中寫(xiě)入相應(yīng)的語(yǔ)句自動(dòng)與期望的響應(yīng)值比較完成。要測(cè)試一個(gè)設(shè)計(jì)塊是否正確,就要用Verilog再寫(xiě)一個(gè)測(cè)試模塊。這個(gè)測(cè)試模塊應(yīng)包括以下三個(gè)方面的內(nèi)容:測(cè)試模塊中要調(diào)用到設(shè)計(jì)塊,只有這樣才能對(duì)它進(jìn)行測(cè)試;測(cè)試模塊中應(yīng)包含測(cè)試的激勵(lì)信號(hào)源;測(cè)試模塊能夠?qū)嵤?duì)輸出信號(hào)的檢測(cè),并報(bào)告檢測(cè)結(jié)果。,4,Simulating/ValidatingHDL,Thesadtruth…10%design,90%validationIfyoudoitrightyouwillspend9Xmoretimetesting/validatingadesignthandesigningit.,5,TestbenchExample(contrivedbutvalid),moduletest_and;integerfile,i,code;rega,b,expect,clock;wireout;parametercycle=20;and#4a0(out,a,b);//Circuitundertestinitialbegin:file_blockclock=0;file=$fopen("compare.txt",“r”);for(i=0;i<4;i=i+1)begin@(posedgeclock)//Readstimulusonrisingclockcode=$fscanf(file,"%b%b%b\n",a,b,expect);#(cycle-1)//Comparejustbeforeendofcycleif(expect!==out)$strobe("%d%b%b%b%b",$time,a,b,expect,out);end//for$fclose(file);$stop;end//initialalways#(cycle/2)clock=~clock;//Clockgeneratorendmodule,6,組合邏輯設(shè)計(jì),組合邏輯電路可以有若個(gè)輸入變量和若干個(gè)輸出變量,其每個(gè)輸出變量是其輸入的邏輯函數(shù),其每個(gè)時(shí)刻的輸出變量的狀態(tài)僅與當(dāng)時(shí)的輸入變量的狀態(tài)有關(guān),與本輸出的原來(lái)狀態(tài)及輸入的原狀態(tài)無(wú)關(guān),也就是輸入狀態(tài)的變化立即反映在輸出狀態(tài)的變化。邏輯電路的各種運(yùn)算可以用布爾代數(shù)來(lái)描述狄摩根定律利用狄摩根(DeMorgan)定律可以將積之和形式的電路轉(zhuǎn)換為和之積形式的電路,或反之。,7,組合邏輯的三種通用表示方法結(jié)構(gòu)化(即門(mén)級(jí))原理圖真值表布爾方程式實(shí)例:半加器,,8,CombinationalCircuitsComponentInstantiations,Circuit–Aconnectionofmodules,–Alsoknownasstructure–Acircuitisasecondwaytodescribea,module,?vs.usinganalwaysprocedure,asearlier,Instance–Anoccurrenceofamoduleinacircuit?Maybemultipleinstancesofamodule,?e.g.,Carsmodules:tires,engine,windows,etc.,with4tireinstances,1engineinstance,6windowinstances,etc.,9,CombinationalCircuitsModuleInstantiations,10,CombinationalCircuitsModuleInstantiations,11,CombinationalCircuitsModuleInstantiations,12,CombinationalCircuitStructureSimulatinggtheCircuit,SametestbenchformatforBeltWarnmoduleasforearlierAnd2module,?,13,CombinationalCircuitStructureSimulatinggtheCircuit,14,CombinationalCircuitStructureSimulatinggtheCircuit,?,`timescale1ns/1nsmoduleTestbench();regK_s,P_s,S_s;wireW_s;BeltWarnCompToTest(K_s,P_s,S_s,W_s);initialbegin,Moreontestbenches–Notethatasinglemoduleinstantiationstatementused–regandwiredeclarations(K_s,P_s,S_s,W_s)usedbecauseprocedurecannotaccessinstantiatedmodules,<=0;S_sP_s<=1;P_s<=1;P_s<=1;,<=0;S_s<=0;S_s<=0;S_s<=1;,K_s<=0;P_s#10K_s<=0;#10K_s<=1;#10K_s<=1;endendmodule,portsdirectly?Inputsdeclaredasregssocanassignvalues(whichareheldbetweenassignments)–Notemoduleinstantiationstatement,andprocedurecanbothappearinonemodule,15,CombinationalBehaviortoStructure,16,CombinationalBehaviortoStructureAlwaysProcedureswithAssignmentStatements,17,CombinationalBehaviortoStructureProcedureswithAssignmentStatements,,,,,?,Proceduralassignmentstatement–Assignsvaluetovariable–Rightsidemaybeexpressionofoperators,`timescale1ns/1nsmoduleBeltWarn(K,P,S,W);inputK,P,S;outputW;regW;,?Built-inbitoperatorsinclude,end,18,CombinationalBehaviortoStructureProcedureswithAssignmentStatements,?,Proceduremayhavemultipleassignmentstatements,`timescale1ns/1nsmoduleTwoOutputEx(A,B,C,F,G);,inputA,B,C;outputFF,G;regF,G;always@(A,B,C)beginF<=(Bendendmodule,19,CombinationalBehaviortoStructureProcedureswithIf-ElseStatements,,,,,?,Processmayuseif-elsestatements(a.k.a.conditionalstatements),–if(expression)?Ifexpressionistrue(evaluatestononzerovalue),executecorrespondingstatement(s)?Iffalse(evaluatesto0),executeelse’ssstatement(elsepartisoptional)?Exampleshowsuseofoperator==,`timescale1ns/1nsmoduleBeltWarn(K,P,S,W);inputK,P,S;outputW;regW;always@(K,P,S)beginif((Kelse,W<=0;,logicalequality,returnstrue/false(actually,returns1or0),endendmodule,?Trueisnonzerovalue,falseiszero,20,CombinationalBehaviortoStructureProcedureswithIf-ElseStatements,,,,,?,Morethantwopossibilities,–Handledbystringingif-elsestatementstogether?Knownasif-else-ifconstruct,?,Example:4x1muxbehavior,`timescale1ns/1nsmoduleMux4(I3,I2,I1,I0,S1,S0,D);inputI3,I2,I1,I0;,inputS1,S0;outputD;,SupposeS1S0changeto01,–SupposeS1S0changeto01?if’sexpressionisfalse?elsesstatementexecutes,whichisanifstatementwhoseexpressionistrue,regD;always@(I3,I2,I1,I0,S1,S0)beginif(S1==0,elseif(S1==1,Note:Thefollowingindentationshowsifstatementnesting,butisunconventional:if(S1==0else,if(S1==0else,,values,returnstrue/false),21,CombinationalBehaviortoStructureProcedureswithIf-ElseStatements,22,CombinationalBehaviortoStructure,23,CombinationalBehaviortoStructureCommonPitfall–MissingInputsfromEventControlExpression,24,CombinationalBehaviortoStructureCommonPitfall–MissingInputsfromEventControlExpression,?,Verilogprovidesmechanismtohelpavoidthispitfall,–@*–impliciteventcontrolexpression?Automaticallyaddsallnetsandvariablesthatarereadbythecontrolledstatementorstatementgroup?Thus,@*inexampleisequivalentto@(S1,S0,I0,I1,I2,I3),`timescale1ns/1nsmoduleMux4(I3,I2,I1,I0,S1,S0,D);inputI3,I2,I1,I0;inputS1,S0;outputD;regD;,?@(*)alsoequivalentalways@*beginif(S1==0endendmodule,25,CombinationalBehaviortoStructureCommonPitfall–OutputnotAssignedonEveryPass,26,CombinationalBehaviortoStructureCommonPitfall–OutputnotAssignedonEveryPass,?,Samepitfalloftenoccursduetonotconsideringallpossibleinputcombinationsif(I1==0endelseif(I1==1D2<=1;,D1<=0;D0<=0;,Last"else"missing,sonotall,end,inputcombinationsarecovered(i.e.,I1I0=11notcovered),- 1.請(qǐng)仔細(xì)閱讀文檔,確保文檔完整性,對(duì)于不預(yù)覽、不比對(duì)內(nèi)容而直接下載帶來(lái)的問(wèn)題本站不予受理。
- 2.下載的文檔,不會(huì)出現(xiàn)我們的網(wǎng)址水印。
- 3、該文檔所得收入(下載+內(nèi)容+預(yù)覽)歸上傳者、原創(chuàng)作者;如果您是本文檔原作者,請(qǐng)點(diǎn)此認(rèn)領(lǐng)!既往收益都?xì)w您。
下載文檔到電腦,查找使用更方便
9.9 積分
下載 |
- 配套講稿:
如PPT文件的首頁(yè)顯示word圖標(biāo),表示該P(yáng)PT已包含配套word講稿。雙擊word圖標(biāo)可打開(kāi)word文檔。
- 特殊限制:
部分文檔作品中含有的國(guó)旗、國(guó)徽等圖片,僅作為作品整體效果示例展示,禁止商用。設(shè)計(jì)者僅對(duì)作品中獨(dú)創(chuàng)性部分享有著作權(quán)。
- 關(guān) 鍵 詞:
- Lecture5 簡(jiǎn)單 數(shù)字 電路設(shè)計(jì) 組合 電路
鏈接地址:http://appdesigncorp.com/p-11497287.html