超大规模集成电路第九次作业2016秋-段成华

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Assignment91.Designan8-bitupanddownsynchronouscounterinVHDLwiththefollowingfeatures:(1)Thesameportsareusedforsignalstobeinputtedandoutputted.Theportsarebi-directionallybuffered(three-state).(2)Thecounteriswithanasynchronousresetthatassignsaspecificinitialvalueforcounting.(3)Thecounteriswithasynchronousdataloadcontrolinputforanewvalueofcountingandanenablecontrolinputforallowingtheupanddowncounting.Theloadcontrolinputhasapriorityovertheenablecontrolinput.Thisimpliesthatwhentheloadoperationisinprocessthecounteroperationisprohibited.(4)Somedatatypes,suchasSTD_LOGIC,UNSIGNED,SIGNEDandINTEGER,maybeused.Synthesizethedesign.Createasetofreasonableinputwaveformsforyourdesignandcompletebothbehavioralandpost-place&routesimulationswithinternalsignalsand/orvariablesincludedinwaveformorlistwindows.Solution:代码如下:libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;----Uncommentthefollowinglibrarydeclarationifinstantiating----anyXilinxprimitivesinthiscode.--libraryUNISIM;--useUNISIM.VComponents.all;entitycount_8_bidirisPort(clk:inSTD_LOGIC;rst:inSTD_LOGIC;load:inSTD_LOGIC;enable:inSTD_LOGIC;cnt:inoutSTD_LOGIC_VECTOR(7downto0));endcount_8_bidir;architectureBehavioralofcount_8_bidirissignalcnt_in:STD_LOGIC_VECTOR(7downto0);signalcnt_out:STD_LOGIC_VECTOR(7downto0);beginpro0:process(oe,cnt_out,cnt)beginif(load='1')thencnt=(others='Z');cnt_in=cnt;elsecnt=cnt_out;endif;endprocess;pro1:process(clk,rst)beginif(rst='1')thencnt_out=(others='0');elsifrising_edge(clk)thenif(load='1')thencnt_out=cnt_in;elsif(enable='1')thencnt_out=cnt_out+1;elsecnt_out=cnt_out-1;endif;endif;endprocess;endBehavioral;解释代码:这里有两个进程,进程0时是用来控制三态门控制的双向端口。当cnt作为输入时(load='1'),把cnt赋给cnt_in(初值装载),然后置cnt为高阻状态;否则,即cnt作为输出时(load='0'),把cnt_out(计数器计数输出值)赋给cnt。进程1的作用是:当复位信号rst='1',计数器输出cnt_out为全0,否则在时钟的上升沿检测cnt端口是作为输入还是作为输出,当作为输入时(load='1'),把cnt_in中的数取进来,然后当up_down='0'时,进行加法运算,否则做减法运算,同时可以和进程0配合当load='0',将数值从cnt_out输出到cnt。TestBench代码:LIBRARYieee;USEieee.std_logic_1164.ALL;USEieee.std_logic_unsigned.all;USEieee.numeric_std.ALL;ENTITYcount_8_bidir_tbISENDcount_8_bidir_tb;ARCHITECTUREbehaviorOFcount_8_bidir_tbIS--ComponentDeclarationfortheUnitUnderTest(UUT)COMPONENTcount_8_bidirPORT(oe:INstd_logic;clk:INstd_logic;rst:INstd_logic;load:INstd_logic;enable:INstd_logic;cnt:INOUTstd_logic_vector(7downto0));ENDCOMPONENT;--Inputssignaloe:std_logic:='0';signalclk:std_logic:='0';signalrst:std_logic:='0';signalload:std_logic:='0';signalenable:std_logic:='0';--BiDirssignalcnt:std_logic_vector(7downto0);--Clockperioddefinitionsconstantclk_period:time:=100ns;BEGIN--InstantiatetheUnitUnderTest(UUT)uut:count_8_bidirPORTMAP(oe=oe,clk=clk,rst=rst,load=load,enable=enable,cnt=cnt);--Clockprocessdefinitionsclk_process:processbeginclk='0';waitforclk_period/2;clk='1';waitforclk_period/2;endprocess;--Stimulusprocessstim_proc:processbeginrst='1';load='0';enable='1';cnt=(others='Z');waitfor100ns;rst='0';waitfor500ns;load='1';cnt=11000000;waitfor200ns;load='0';cnt=(others='Z');waitfor500ns;enable='0';waitfor500ns;rst='1';wait;endprocess;END;根据TestBench的激励可以看出:进入程序之后,首先复位且load='0',这时cnt_out从0开始做加法运算,当计数到5之后,load='1'把cnt变成了输入,并且给其赋了11000000(转化为整数为192),并且在上升沿条件下送到cin_out,此时cin_out=192;在加载该值之后,200ns之后将load='0'将cnt变为输出,此时cnt开始从192向上计数,记了经过500ns记到了197,然后遇到了enable='0',开始做减法,经过500ns,cnt变为192,随后rst='1',将cnt清0,到此结束,功能验证为正确。后仿真波形如上所示,与行为仿真的差别,就是前面几百ps增加了一个Unknown状态(没有初始化的缘故),同时cnt相对于时钟沿有延迟。2.FortheVHDLmodelgivenbelow(CodeListOne),comparetheFIFOsimplementationsonCPLDandFPGA.(1)Synthesizeandverify(simulate)theVHDLdesignoftheFIFOs;综合后的RTLschematic和功能仿真后的结果分别如下图1和图2所示。图1图2(2)ForCPLDimplementation(fit)oftheFIFOs,howmanyMCs(macrocells)andPTs(productterms)areneeded?Whichparameteriscriticaltothemaximuminternalclockworkingfrequency?Trytofindoutthiscriticalparameteranditscorrespondingcircuitpath.设置芯片为CoolRunnerXPLA3CPLDS系XCR3512XL-7-PQ208,速度为-7,综合后报告分析如下图3为CPLD综合报告:从报告中可以知道一共使用了87个MCs,占总体的17%,使用了208个PTs,占总体的14%,选这个型号似乎有点大材小用啊,不过资源很足够,满足设计的需求。图4为CPLD时间报告:由图4可知,时钟的最小周期为8.6ns,受clocktosetup影响最大,故关键路径为tcyc。延时为8.6ns,时钟的工作频率为116.279MHz。图3图4(3)ForFPGAimplementation(placeandroute)oftheFIFOs,howmanyLBs(logicblocks)?Whichparameteriscriticaltothemaximuminternalclockworkingfrequency?Trytofindoutthiscriticalparameteranditscorrespondingcircuitpath.设置芯片为更换芯片型号为Spartan3-xc3s200-5pq208,速度为-5,其综合报告如下图5为FPGA综合报告:图5图6为Spartan3datasheet图6图7由上图知,对于选择的器件,其logiccell为4320,CLB有24X20=480个,每个CLB包含4个slice,而对于我们的程序,一共使用了66个slice,占总数的百分之三(总slice共计1920个),故使用的CLB数为66/4=16.5,即使用了17个。由图7可知,时钟的最小周期为5.078ns,受clocktosetup影响最大,时钟的工作频率为196.927MHz。(4)Trytosynthesizeagainthedesignwithtimingconstraintsandcomparewithitsformercounterparts.Youwillcreatethetimingconstraintfilebyyourselfandaddittoyourproject.PleaserefertothefollowinggraphicinterfaceofISE:图8为timingconstrain设置图;图9为没有设置时序约束时的报告;图10为设置CLK周期约束为5ns时的报告;图11为设置CLK周期约束为4.5ns时的报告;图12设置clk周期约束为4ns时的报告图13设置clk周期约束为3.5ns时的报告图8图9图10图11图12图133.FortheVHDLmodelgivenbelow(CodeListTwo),theremaybesomedesignerrorsinit.Somewarning(s)and/orerror(s

1 / 15
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功