




已阅读5页,还剩175页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
硬件描述语言VHDL及其应用,哈工大微电子中心王进祥,电话:6415979-806,2020/6/6,2,一、目的,了解目前电子设计系统方法及流程了解/掌握综合与验证工具能用VHDL设计复杂功能电路,二、内容,高层次设计概述如何写优化的VHDL代码examplesSoC设计方法学设计工具使用,三、如何学习本课程,带着实际课题学习,多提问题,一起分析、讨论,2020/6/6,3,一、高层次设计概述,EDA工具发展设计方法深亚微米设计问题测试综合(可测性设计)Top-down设计流程硬件描述语言综合VHDL设计小结,2020/6/6,4,1.1EDA工具发展,2020/6/6,5,1.1EDA工具发展(Cont.),CAD:逻辑图输入、逻辑模拟、电路模拟、版图设计和版图验证分别进行,需要对两者结果进行多次比较、修改。设计规模较小,CAE:集逻辑图输入、逻辑模拟、测试码生成、电路模拟、版图设计、版图验证等工具一体,构成一个较完整的IC设计系统,EDA:HDL取代逻辑输入,逻辑网表由综合工具自动产生,可管理性增强,易于维护和数据交换,SoC:采用深亚微米工艺生产技术,基于平台设计和IP复用技术,时序收敛性为首要目标,2020/6/6,6,自顶向下设计方法(Top-down):系统行为设计结构设计逻辑设计电路设计版图设计,1.2设计方法,自底向上设计方法(Bottom-up):系统功能划分单元设计功能模块设计子系统设计系统总成,基于平台设计方法(Platform-based):SoC设计普遍采用的方法,SoC平台和IPIntellectualProperty,其它设计:嵌入式设计方法,层次式设计方法等,2020/6/6,7,1.3深亚微米设计问题,连线延时时序模型器件模型信号完整性电磁干扰功耗设计工具,综合优化工具,布图规划工具,SDF,PDEF,SDF标准数据格式,PDEF物理设计交换格式,2020/6/6,8,1.4测试综合,目的:集成电路的测试简单化嵌入可测试结构,加速可测性设计产品制造前就可评价设计的可测性消除冗余逻辑诊断不可测的逻辑结构,内容:测试嵌入、设计规则检查、测试码生成、故障模拟/诊断和输出测试图样,测试综合包括了使测试成功的每一步骤:如加入带测试因素的电路,对逻辑综合增加约束条件以满足测试要求及对高级语言描述的可测结构的综合等都可归结为测试综合,2020/6/6,9,1.4测试综合(Cont.),方法:FullScanPartialScanBISTBoundaryScan,标准/规范:IEEE1149IEEEP1500VSIARelatedSpec.,SoC可测试设计:IP可测试设计GlueLogic可测试设计测试存取结构,分类:1Pass2Pass,2020/6/6,10,1.5Top-down设计流程,PLANNING,SYNTHESIS,FLOORPLAN,Pxout:outbit8);endcomponent;signalctlN1m1,ctlN1,ctl254,ctl255:std_logic;signalctlobf,synfb:std_logic;signalfbo,dout,synout,lstsfe,bout:bit8;signalcntout:rsInt;signaliffto,syndout:bit8;signalbmfo:rsbit8_vector(0toN2-1);,5,2020/6/6,20,1.8VHDL设计小结(Cont.),beginu1:controlportmap(reset,clk,ctlN1m1,ctlN1,ctl254,ctl255,ctlobf,synfb,cntout);u2:syndromeportmap(reset,clk,decin,synfb,syndout);u3:bmexpandportmap(reset,clk,syndout,cntout,synout,lstsfe,bout);u4:bmfftbufportmap(reset,clk,ctl255,synout,lstsfe,bmfo);u5:ifftportmap(reset,clk,ctlN1m1,ctlN1,ctl254,bmfo,iffto);u6:fftobufportmap(reset,clk,ctlobf,iffto,fbo);u7:decbufportmap(reset,clk,decin,dout);u8:xor8portmap(fbo,dout,decout);endstructural;,6,2020/6/6,21,二、如何写优化的VHDL代码,数据类型并发/顺序赋值语句小结Process语句资源共享其它,2020/6/6,22,2.1数据类型,2020/6/6,23,2.1数据类型(Cont.),2020/6/6,24,2.1.1赋值语句,i/signalt,s:bit;s=1;-s=t;,ii/signalc:bit_vector(0to3);signald:bit_vector(3downto0);c=“1011”;,d=c;-ok?c(0to3)=d(0to3)ok?,d=c;-ok!c(0to3)=d(0to3)No!,2020/6/6,25,iii/signals,t,w,m:bit;signalc:bit_vector(0to3);c1,3-1);-Ok,2.1.1赋值语句(Cont.),2020/6/6,26,iv/signala_vec:bit_vector(0to11);a_vec=B”1100_0011_0011_1100”;a_vec=“1100001100111100”;a_vec=X”C33C”;a_vec=X”C3_3C”;,2.1.1赋值语句(Cont.),2020/6/6,27,二进制B(Binary)八进制O(Octal)十六进制X(Hexadecimal),位串中的进制表示:,2.1.1赋值语句(Cont.),2020/6/6,28,v/signalA,B,C:bit_vector(3downto0);C=AandB;,2.1.1赋值语句(Cont.),2020/6/6,29,vi/sliceofarrayentityVHDLisport(A:inbit_vector(0to7);outp:outbit);endVHDL;architectureE1ofVHDLisbeginoutp=A(5);end;,signalC:bit_vector(0to7);C(4)=1;C(0to3)=“1001”;,2.1.1赋值语句(Cont.),2020/6/6,30,vii/Compositedatatypetypedateisrecordyear:integerrange1980to2030;month:integerrange1to12;day:integerrange1to30;endrecord;subtypebit8isbit_vector(7downto0);,2.1.1赋值语句(Cont.),2020/6/6,31,vii/Compositedatatypesignalweekday,today:date;weekday.year=2003;weekday.monty=2;weekday.day=14;today=weekday;,2.1.1赋值语句(Cont.),2020/6/6,32,2.1.2数据类型转换,强类型语言:VHDL具有丰富的数据类型,不同类型的对象(信号、变量)不能直接赋值,经常转换的数据类型:std_logic,bit,std_ulogic,boolean,signedunsigned,std_logic_vector,bit_vector,数据类型转换三种方法:类型标记转换法、函数转换法和常数转换法,2020/6/6,33,类型标记转换法,std_logicandstd_ulogic,std_logic_vectorandsignedstd_logic_vectorandunsignedintegerandreal等,signalastd_logic_vector(0to7);signalbunsigned(0to7);b=unsigned(a);,2.1.2数据类型转换(Cont.),2020/6/6,34,函数转换法,std_logicandbitstd_ulogicandbit,booleanandbit,std_logic_vectorandbit_vectorintegerandstd_logic_vector/unsigned等,signalastd_logic_vector(0to7);signalbintegerrange0to255;a1,others=0);signals:std_ulogic;signala:bit;a=typeconv(s);,常数转换法,2.1.2数据类型转换(Cont.),2020/6/6,36,Howtotransformbittypetobooleantype?,signalbitty:bit;signalbooly:boolean;booly=,Discussion:Whatistheresultofthefollowingrelationalstatement?,2020/6/6,38,2.1.4算术操作,运算符:+,*,mod,/,rem,操作数类型:std_logic_vector,integer,signed,unsigned,useieee.std_logic_unsigned.all;,2020/6/6,39,2.1.4算术操作(Cont.),signala,b:std_logic_vector(3downto0);q1=unsigned(a)+unsigned(b);q2=unsigned(a)+signed(b);q3=signed(a)+signed(b);q4=a+b;q51,others=0);C=“00000000”;-初始化,C0);,2.1.5连字符和聚集(Cont.),2020/6/6,42,2.2并发/顺序赋值语句,并发赋值语句在architecture的begin和end之间,与书写顺序无关,每一条并发语句均可用一个process语句等价,顺序赋值语句只能在process和子程序的begin和end之间,它除信号赋值语句外,还有变量赋值,2020/6/6,43,2.2.1并发赋值语句,D=A+E;A=B+C;,2020/6/6,44,2.2.1并发赋值语句(Cont.),A=B+A;,并发赋值语句:,C=A;C=B;,组合逻辑环路!,Multi-driver,needresolvedfunction,2020/6/6,45,2.2.2顺序赋值语句,D=A+E;A=B+C;,2020/6/6,46,2.2.2顺序赋值语句(Cont.),C=A;C=B;,A0andI=7generateu2:dffportmap(reset,clk,tv(I1),tv(I);endgenerate;endgenerate;dout=tv(7);endstr;,2020/6/6,49,2.4process,描述电路功能或行为。由于综合后的电路对所有输入信号变化敏感,因此所有被读信号均应包含在敏感表中,否则,综合前的模拟结果与综合后的模拟结果不一致!,2020/6/6,50,2.4.1syntax,process_label:process(sensitivitylist)declarations;beginstatements;-if,loop,case,subprogramcalletcendprocessprocess_label;,2020/6/6,51,2.4.1syntax,P1:process(A,B)BeginD=AorBandC;EndprocessP1;,P1:process(A,B,C)BeginD=AorBandC;EndprocessP1;,2020/6/6,52,2.4.2communicationamongprocess,architectureexample,2020/6/6,53,2.4.3ifthenelse语句综合,i/.引入寄存器,entitydffisport(d:instd_logic;clk:instd_logic;q:outstd_logic);Enddff;,architecturertlofdffisbegininfer_reg:process(d,clk)beginif(clkeventandclk=1)thenq=d;endprocessinfer;endrtl;,2020/6/6,54,2.4.3ifthenelse语句综合(Cont.),ii/.引入锁存器,Infer_latch:process(A,B)beginif(A=1)thenx=B;endprocessinfer_infer_latch;,Infer_latch:process(A,B)Beginx=0;if(A=1)thenx=B;endprocessinfer_infer_latch;,隐含了A=0时x=x;不完全的else,2020/6/6,55,2.4.3ifthenelse语句综合(Cont.),iii/.组合电路,entitycombisport(a,b:inbit;select:inbit;y:outbit);endcomb;,architecturearchofcombisbeginprocess(a,b,select)beginif(select=1)theny=b;elsey=a;endif;endprocess;endarch;,2020/6/6,56,2.4.3ifthenelse语句综合(Cont.),iv/.异步复位,process(reset,clk,d)Beginif(reset=0)thenq=0;elsif(clkeventandclk=1)thenq=d;endif;endprocess;,2020/6/6,57,2.4.3ifthenelse语句综合(Cont.),v/.三态逻辑,signals,sel,data:std_logic;process(sel,data)Beginif(sel=1)thens=data;elses=Z;endif;endprocess;,1,2020/6/6,58,2.4.3ifthenelse语句综合(Cont.),v/.三态逻辑,architecturebehoftribufissignalasel,bsel,a,b,s:std_logic;beginpa:process(asel,a)begins=Z;if(asel=1)thens=a;endif;endprocesspa;,2,pb:process(bsel,b)begins=Z;if(bsel=1)thens=b;endif;endprocesspb;endbeh;,Multidriver!,2020/6/6,59,2.4.3ifthenelse语句综合(Cont.),Discussion,signala,b,use_b:bit;process(a,b,use_b)Beginif(use_b=1)thens=b;elseif(use_b=0)thens=a;endif;endprocess;,1,Latch?,2020/6/6,60,2.4.3ifthenelse语句综合(Cont.),Discussion,signala,b,use_b:std_logic;process(a,b,use_b)Beginif(use_b=1)thens=b;elseif(use_b=0)thens=a;endif;endprocess;,2,Latch?,2020/6/6,61,2.4.3ifthenelse语句综合(Cont.),Discussion,elseassertfalsereport“invaliduse_b”severityerror;endif;endprocess;,3,what?,signala,b,use_b:std_logic;process(a,b,use_b)Beginif(use_b=1)thens=b;elseif(use_b=0)thens=a;,2020/6/6,62,2.4.3ifthenelse语句综合(Cont.),vi/.在一个进程中,一个信号只能对应一个三态驱动,process(b,ub,a,ua)Begindout=Z;if(ub=1)thendout=b;endif;if(ua=1)thendoutstatements;whenvalue1tovalue2=statements;whenothers=statements;endcase;,2020/6/6,66,2.4.4case语句(Cont.),ii/.case语句规则,任意value互不相同,如无others分枝,必须穷尽所有可能的表达式值,如有others分枝,必须至少有一个表达值未列出,任意分枝中的语句可以有多条,2020/6/6,67,2.4.4case语句(Cont.),entitydecoderisport(din:instd_logic_vector(0to2);q:outstd_logic_vector(0to7);enddecoder;architectureexofdecoderisbeginprocess(din)begincase(din)when“000”=qqqqqqqqq=“-”;endcase;endprocess;endex;,2020/6/6,68,2.4.5forloop语句,i/.语法,loop_label:forloop_varinrangeloopsequentialstatements;endlooploop_label;,说明:loop_label可选,loop_var不需声明,综合时,循环语句将unrolled,Whyloopstatement?,2020/6/6,69,2.4.5forloop语句(Cont.),entityparsumisport(word:instd_logic_vector(0to7);par:outstd_logic);endparsum;architectureaddxorofparsumisbeginprocess(word)variablets:std_logic;begints:=0;,forIinwordrangeloopts:=tsxorword(I);endloop;par=ts;endprocess;endaddxor;,Discussion:如果ts为信号,结果是什么?,2020/6/6,70,2.4.6数据对象,constantvariablesignal,i/.constantandvariable,constantmask:std_logic_vector(0to7):=“00000000”;constantled_zero:bit_vector(0to7):=X”7E”;variabletsum:std_logic_vector(3downto0);,2020/6/6,71,2.4.6数据对象(Cont.),ii/.signalandvariable,相同点:值可变,可综合为逻辑或线,不同点:变量赋值有立即性,且只用于process和subprogram中(VHDL-1076-87),而信号除此之外,还可用于并行语句中,应用:简单计算signal复杂计算variable中间结果variable,2020/6/6,72,2.4.6数据对象(Cont.),signala,b,c,x,y:shortprocess(a,b,c)beginc=a;x=c+2;c=b;y=c+4;endprocess;,signala,b,x,y:shortprocess(a,b,c)variablec:short;beginc:=a;x=c+2;c:=b;y=c+4;endprocess;,2020/6/6,73,2.4.6数据对象(Cont.),signal,variable,2020/6/6,74,2.4.6数据对象(Cont.),entitysigvarisport(a,b,c,d:std_logic;q:outstd_logic;endsigvar;architecturesigofsigvarissignalint:std_logic;Beginprocess(a,b,c,d,int)beginint=aandbandc;q=intord;endprocess;endsig;,entitysigvarisport(a,b,c,d:std_logic;q:outstd_logic;endsigvar;architecturesigofsigvarisBeginprocess(a,b,c,d)variablelint:std_logic;beginint:=aandbandc;q=intord;endprocess;endsig;,2020/6/6,75,2.4.7wait语句,waituntil,wait,waiton,waitfor,wait语句表明了信号激活process的条件,在process中,如有wait语句,敏感表必须取消,在process中,如既无wait语句,也无敏感表,则不能正确模拟,综合工具仅支持waituntil语句(引入寄存器)!,2020/6/6,76,2.4.7wait语句(Cont.),libraryieee;Useieee.std_logic_1164.all;entitycount4isport(updown:instd_logic;clk:instd_logic;dout:outintegerrange0to15);endcount4;,architecturebehaveofcount4issignalcnt:integerrange0to15;beginprocessbeginwaituntilclkeventandclk=1;,if(updown=1)thenif(cnt=15)thencnt=0;elsecnt=cnt+1;endif;elseif(cnt=0)thencnt=15;elsecnt=算术运算:+,*,/,每个运算符均要消耗大量的硬件资源,并产生延时!,如何用最小的资源实现相同的功能?,2020/6/6,78,2.5资源共享(Cont.),i/.if(sel_a=1)thenz=a+t;endif;if(sel_a=0)thenz=b+t;endif;,1,2020/6/6,79,2.5资源共享(Cont.),i/.z=a+twhensel_a=1elseb+t;或if(sel_a=1)thenz=a+t;elsez=b+t;endif;,2,2020/6/6,80,2.5资源共享(Cont.),ii/.dout:=0;found:=false;forkin1to4loopif(found=false)thenif(a(k)=1)thendout:=b(k)+c(k);found:=true;endif;endif;endloop;,1,2020/6/6,81,2.5资源共享(Cont.),ii/.t1:=0;t2:=0;found:=false;forkin1to4loopif(found=false)thenif(a(k)=1)thent1:=b(k);t2:=c(k);found:=true;endif;endif;endloop;dout:=t1+t2;,2,2020/6/6,82,2.5资源共享(Cont.),iii/.多进程P1:processbeginwaituntilclkeventandclk=1;if(sel=“00”)thenreg_0=dA+dB;endif;endprocessP1;,1,P2:processbeginwaituntilclkeventandclk=1;if(sel=“01”)thenreg_1=dA-dB;endif;endprocessP2;,2020/6/6,83,2.5资源共享(Cont.),iii/.多进程P3:processbeginwaituntilclkeventandclk=1;if(sel=“10”)thenreg_2=dB-dA;endif;endprocessP1;,2,dout=reg_0whensel=“00”elsereg_1whensel=“01”elsereg_2whensel=“10”else0;,资源:3个加法器/减法器,资源共享不能在多进程间实现!,2020/6/6,84,2.5资源共享(Cont.),iv/.if(addr(31downto20)=“000000000001”)then,资源:两个12位比较器,资源:两个3位比较器+一个9位比较器,2020/6/6,85,2.5资源共享(Cont.),v/.s(0)A1)thens(k)=1;elses(k)=0;endif;endloop;,资源:1个减法器,7个比较器,说明:模拟时间长,因为每进入循环均要计算一次减法;综合时间也会较长,因为综合工具要移去循环中的定值表达式,1,2020/6/6,86,2.5资源共享(Cont.),v/.s(0)tv)thens(k)=1;elses(k)=0;endif;endloop;,资源:1个减法器,7个比较器,说明:模拟、综合时间短,2,2020/6/6,87,2.5资源共享(Cont.),v/.s(0)A)thens(k)=1;elses(k)=0;endif;endloop;,资源:0个减法器,7个比较器,说明:下标运算不产生额外资源消耗,综合工具自动用2to8与A比较;模拟、综合时间短,3,2020/6/6,88,2.5资源共享(Cont.),vi/.sum:=0;forkin0to7loopsum:=sum+A(k);endloop;dout=sum;,1,8个加法器,8级加法器延迟,2020/6/6,89,2.5资源共享(Cont.),vi/.cnt:=8;forlin0to2loopcnt:=cnt/2;forkin0tocnt1loopA(k):=A(k*2)+A(k*2+1);endloop;endloop;dout=A(0);,2,7个加法器,3级加法器延迟,2020/6/6,90,2.6其它,i/.正确使用后到达的信号process(A_late,B,C,D)beginif(A_late+B24)thendout=C;elsedout=D;endif;endprocess;,1,2020/6/6,91,2.6其它(Cont.),i/.正确使用后到达的信号process(A_late,B,C,D)beginif(A_late24-B)thendout=C;elsedout=D;endif;endprocess;,2,2020/6/6,92,2.6其它(Cont.),ii/.仿真与综合结果不匹配processvariablecnt:integerrange0to255;beginwaituntilclkeventandclk=1;cnt:=cnt+1;dout=cnt;endprocess;,1,变量将引入额外的寄存器!,2020/6/6,93,2.6其它(Cont.),ii/.仿真与综合结果不匹配signalcnt:integerrange0to255;processbeginwaituntilclkeventandclk=1;cnt=cnt+1;endprocess;dout=cnt;,2,但是,仿真时,当cnt的值为255时,再一次进入该process时,将报告越界错误!,2020/6/6,94,2.6其它(Cont.),ii/.仿真与综合结果不匹配signalcnt:integerrange0to255;processbeginwaituntilclkeventandclk=1;if(cnt=255)thencnt=0;elsecntcon_A;dout=con_out);,当某一输入端口接固定电平时,必须引入中间信号,且中间信号不能在说明时赋初值!,1,2020/6/6,97,2.6其它(Cont.),iv/.元件例化端口映射问题componentdffport(reset,clk:instd_logic;d:instd_logic;q,qn:outstd_logic);enddff;,当某一输出端悬空时,应连接open关键字!,u1:dffportmap(reset=reset,clk=clk;q=dout,qn=open);,2,2020/6/6,98,2.6其它(Cont.),v/.避免阵列方向错误signaldata8:bit_vector(0to7);signaldout:bit_vector(7downto0);dout=data8(7downto0);,2020/6/6,99,2.6其它(Cont.),vi/.避免低效率语句signal:l1,l2:bit;P1:process(l1,l2,A,B,C,D)begincase(l1,Ok?,No!,1,2020/6/6,100,2.6其它(Cont.),vi/.避免低效率语句,signal:l1,l2:bit;P3:process(l1,l2,A,B,C,D)subtypetwobitsisbit_vector(0to1);begincase(twobits(l1,2,2020/6/6,101,2.6其它(Cont.),vii/.桶移位寄存器,entitybarrel_shifterisport(clk:inbit;din:inbit_vector(0to31);k:inintegerrange0to31;dout:outbit_vector(0to31);endbarrel_shifter;,architecturebehaveofbarrel_shifterisbeginprocessbeginwaituntilclkeventandclk=1;dout=din(kto31),上述模型不可综合,k是031中任意的数,属于不可计算的,但上述模型可仿真!,1,2020/6/6,102,2.6其它(Cont.),vii/.桶移位寄存器,architecturesyn1ofbarrel_shifterisbeginprocessbeginwaituntilclkeventandclk=1;if(k=0)thendout=din;elseforlin1to31loopif(l=k)thendoutdoutdoutdout=din(31),3,2020/6/6,104,2.6其它(Cont.),viii/.三态使能寄存器(或锁存器),architecturertloftrienregisbeginprocess(clk,en,din)beginif(en=0)thendout=Z;elsif(clkeventandclk=1)thendout=din;endif;endprocess;endrtl;,entitytrienregisport(clk:instd_logic;en:instd_logic;din:instd_logic;dout:outstd_logic);endtrienreg;,2020/6/6,105,2.6其它(Cont.),ix/.向量操作与forloop,process(scalar_A,vector_B)beginforkinvector_Brangeloopvector_C(k)qqqqqq=“000”;endcase;endprocess;,向量没有范围,因此,不能指定向量的范围!,2020/6/6,108,2.6其它(Cont.),x/.时钟信号,typenot_single_bitis(X,0,1,Z);signalinvalid_clk:not_signal_bit;waituntilinvalid_clkeventandinvalid_clk=1;-orif(invalid_clkeventandinvalid_clk=1)then,沿触发时钟信号必须是能够用单比特编码的枚举类型,但std_logic类型是一个例外!,illegalusage!,2020/6/6,109,2.6其它(Cont.),xi/.综合结果多样性,entitycombisport(a,b,c:instd_logic;d:outstd_logic);endcomb;architecturertlofcombisbegind=(aandb)orc;endrtl;,2020/6/6,110,2.6其它(Cont.),xii/.使用中间数据项,Sum1=a+b;Sum2=a+b+c;Sum3=a+c;,Sum1=a+b;Sum2=Sum1+c;Sum32)thenx=a;y=b;z=c;elsexzerozerozerozero=-;one=-;twozeroonetwozero=-;one=-;two=-;endcase;endprocess;,2,2020/6/6,114,2.6其它(Cont.),xiv/.有限状态机,1,2020/6/6,115,2.6其它(Cont.),xv/.Clockgating,moduleclkgate(en,data,clk,outp)inputen,clk;input7:0data;output7:0outp;reg7:0outp;Always(posedgeclk)if(en)outp=data;endmodule,2020/6/6,116,三、设计实例,ROMRAMFIFOADDERALUMCU,2020/6/6,117,3.1ROM,libraryieee;useieee.std_logic_1164.all;packageROM_Pissubtypebyteisstd_logic_vector(7downto0);typememoryisarray(0to255)ofbyte;constantrom_data:memory:=(“11010101”),(“01001000”),(“10101010);endROM_P;,2020/6/6,118,3.1ROM(Cont.),libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;usework.ROM_P.all;entityrom_eisport(ren:instd_logic;addr:inbyte;dout:outbyte);endrom_e;,architecturerom_aofrom_eisbeginprocess(ren,addr)beginif(ren=1)thendoutZ);endif;endprocess;endrom_a;,2020/6/6,119,3.2优先编码器,2020/6/6,120,3.2优先编码器(Cont.),libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;usework.ROM_P.all;entityencoderisport(inp:instd_logic_vector(7downto0);y:outstd_logic_vector(2downto0);endrom_e;,2020/6/6,121,3.2优先编码器(Cont.),elsif(inp(4)=0)theny=“011”;elsif(inp(5)=0)theny=“010”;elsif(inp(6)=0)theny=“001”;elsey=“000”;endif;endprocess;endencoder_a;,architectureencoder_aofencoderisbeginprocess(inp)beginif(inp(0)=0)theny=“111”;elsif(inp(1)=0)theny=“110”;elsif(inp(2)=0)theny=“101”;elsif(inp(3)=0)theny=“100”;,2020/6/6,122,3.3RAM,entitysram16x8isgeneric(k:integer:=8;w:integer:=4);port(wr,rd,cs:instd_logic;addr:instd_logic_vector(w1downto0);din:instd_logic_vector(k1downto0);dout:outstd_logic_vector(k1downto0);endsram16x8;,2020/6/6,123,3.3RAM(Cont.),architecturebehavofsram16x8issubtypewordisstd_logic_vector(k1downto0);typememoryisarray(0to2*w1)ofword;signaladdr_tmp:integerrange0to2*w1;signalsram:memory;signaldin_change,wr_rise:TIME:=0ns;beginaddr_tmp=conv_integer(addr);process(wr)beginif(wreventandwr=1)then,2020/6/6,124,3.3RAM(Cont.),if(cs=1andwr=1)thensram(addr_tmp)=800ps)report“setuperrordin(sram)”severityWARNING;-dinsetuptimecheckingendprocess;,2020/6/6,125,3.3RAM(Cont.),process(rd,cs)beginif(cs=1andrd=0)thendout=300ns),report“holderrordin(sram)”severityWARNING;endprocess;endbehav;,2020/6/6,126,3.4FIFO,满、空状态:rp=wp1,满状态的前一状态:rp=wp1,再写则为满状态,空状态的前一状态:rp=wp2,再读则为空状态,2020/6/6,127,3.4FIFO(Cont.),libraryieee;Useieee.std_logic_1164.all;entityfifo8x8isgeneric(w:integer:=8;k:integer:=8);port(clk,reset,wr,rd:instd_logic;din:instd_logic_vector(k1downto0);dout:outstd_logic_vector(k1downto0);full,empty:outstd_logic);endfifo8x8;,wr,rd:低电平有效!该FIFO设计成写当前地址,读下一地址数据,2020/6/6,128,3.4FIFO(Cont.),architecturebehavoffifo8x8istypememoryisarray(0tow1)ofstd_logic_vector(k1downto0);signalram:memory;signalwp,rp:integerrange0tow1;signalin_full,in_empty:std_logic;beginfull=in_full;empty=in_empty;dout=ram(rp);,2020/6/6,129,3.4FIFO(Cont.),process(clk)beginif(clkeventandclk=1)thenif(wr=0andin_full=0)thenram(wp)=din;endif;endif;endprocess;,process(clk,reset)beginif(reset=1)thenwp=0;elsif(clkeventandclk=1)thenif(wr=0andin_full=0)thenif(wp=w1)thenwp=0;elsewp=wp+1;endif;endif;endif;endprocess;,wp修改描述,数据写堆栈,2020/6/6,130,3.4FIFO(Cont.),process(clk,reset)beginif(reset=1)thenrp=w1;elsif(clkeventandclk=1)thenif(rd=0andin_empty=0)thenif(rp=w1)thenrp=0;elserp=rp+1;endif;endif;endif;endprocess;,rp修改描述,2020/6/6,131,3.4FIFO(Cont.),process(clk,reset)beginif(reset=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论