《VHDL实验新及答案》PPT课件.ppt_第1页
《VHDL实验新及答案》PPT课件.ppt_第2页
《VHDL实验新及答案》PPT课件.ppt_第3页
《VHDL实验新及答案》PPT课件.ppt_第4页
《VHDL实验新及答案》PPT课件.ppt_第5页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验1熟悉实验环境,完成下述实验内容:2输入与门、2输入或门、2输入异或门及非门的设计。D触发器的设计。带有异步清零、异步置位功能的边沿JK触发器的设计。,1-1代码,非门LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYNOTISPORT(A:INSTD_LOGIC;Y:OUTSTD_LOGIC);ENDENTITYNOT;ARCHITECTUREARTOFNOTISBEGINY=NOTA;ENDARCHITECTUREART;,1-1代码,异或门LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYXOR2ISPORT(A,B:INSTD_LOGIC;Y:OUTSTD_LOGIC);ENDENTITYXOR2;ARCHITECTUREARTOFXOR2ISBEGINY=AXORB;ENDARCHITECTUREART;,1-2代码,D触发器的设计libraryieee;useieee.std_logic_1164.all;entityd_chufaisport(clk,d:instd_logic;q:outstd_logic);endd_chufa;architecturebehavofd_chufaisbeginprocess(clk)isbeginif(clkeventandclk=1)thenq=d;endif;endprocess;endbehav;,1-3代码,异步清零、异步置位功能的边沿JK触发器libraryieee;useieee.std_logic_1164.all;entityjkisport(pset,clr,clk,j,k:instd_logic;q,qb:outstd_logic);endentity;architecturebehavofjkissignalq_s,qb_s:std_logic;beginprocess(pset,clr,clk,j,k)beginif(pset=0)and(clr=1)thenq_s=1;qb_s=0;elsif(pset=1)and(clr=0)thenq_s=0;qb_s=1;elsif(clkeventandclk=1)thenif(j=0)and(k=1)thenq_s=0;qb_s=1;elsif(j=1)and(k=0)thenq_s=1;qb_s=0;elsif(j=1)and(k=1)thenq_s=notq_s;qb_s=notqb_s;endif;endif;q=q_s;qb=qb_s;endprocess;endbehav;,实验21,实验内容:完成下述模块的设计,实现真值表中的半加与半减的功能。提示信息:将加法与减法区分成两个功能模块,使用BLOCK语句将构造体分为两大部分。,输入值,半加法器(A+B),半减法器(A-B),A,B,Sum,Car,Difference,Borrow,0,0,0,1,1,0,1,1,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,0,2-1代码,libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityhalfisport(a,b:instd_logic;sum,car,dif,bor:outstd_logic);endhalf;architecturebehavofhalfisbeging1:blockbeginsum=axorb;car=axorb;endblockg1;g2:blockbegindif=axorb;bor=(nota)andb;endblockg2;endbehav;,实验22,实验内容:设计一个4位加减法器.要求:a,b:数据输入;sub:控制端,高电平实现加法功能,低电平实现减法功能;s:和与差的输出;co:进位与借位的输出。,2-2代码,libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitysubaddisport(sub:instd_logic;a,b:instd_logic_vector(3downto0);s:outstd_logic_vector(3downto0);co:outstd_logic);endentitysubadd;architecturebehavofsubaddissignaltemp:std_logic_vector(4downto0);beginprocess(sub,a,b)beginifsub=1thentemp=a+b;elsetemp=a-b;endif;endprocess;s=temp(3downto0);co=temp(4);endbehav;,实验31,实验内容:如下表所示为4位双向通用移位寄存器74LS194的真值表,编写程序描述该逻辑,仿真其功能。,3-1代码,libraryieee;useieee.std_logic_1164.all;entityls194isport(clr,s0,s1,clk,l,r:instd_logic;p:instd_logic_vector(3downto0);q:outstd_logic_vector(3downto0);endls194;architecturebehavofls194issignalqs:std_logic_vector(3downto0);beginprocess(clr,s0,s1,clk,l,r)isbeginif(clr=0)thenqs=0000;elsif(clkeventandclk=1)thenif(s1=1)and(s0=1)thenqs=p;elsif(s1=0)and(s0=1)thenif(r=1)thenqs(3)=1;qs(2downto0)=qs(3downto1);elsif(r=0)thenqs(3)=0;qs(2downto0)=qs(3downto1);endif;elsif(s1=1)and(s0=0)thenif(l=1)thenqs(0)=1;qs(3downto1)=qs(2downto0);elsif(l=0)thenqs(0)=0;qs(3downto1)=qs(2downto0);endif;endif;endif;q=qs;endprocess;endbehav;,实验32,实验内容:38译码器的设计(要求用WITHSELECT语句完成)(图形见下页)。提示信息:常见的38译码器的真值表如右:,A0A1A2,000,001,010,011,100,101,110,111,Y0Y1Y2Y3Y4Y5Y6Y7,10000000,01000000,00100000,00010000,00001000,00000100,00000010,00000001,当EN1时,译码器正常工作;当EN=0时,译码器不动作。,A0,A1,A2,EN,Y0,Y7,3-2代码,libraryieee;useieee.std_logic_1164.all;entitydecode3to8isport(a:instd_logic_vector(2downto0);en:instd_logic;y:outstd_logic_vector(7downto0);enddecode3to8;architecturebehavofdecode3to8issignalsel:std_logic_vector(3downto0);beginseldoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout=0000000;endcase;endprocess;endbehav;,实验42,实验内容:设计完成一个7位的偶同位产生器。提示信息:同位共分为两种形式:奇同位:数据位与奇同位的1的个数为奇数。偶同位:数据位与偶同位的1的个数为偶数。n位的偶同位产生器的输入信号为n位,输出信号为n+1位,其中前n位为输入信号,最后一位为偶同位位,且保证输出的n+1位信息中1的个数为偶数个。(奇同位产生器工作原理类似),4-2代码,libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entitytongweiisport(a:instd_logic_vector(6downto0);c:outstd_logic_vector(7downto0);endentity;architecturebehavoftongweiissignaltemp:std_logic;begintemp=a(0)xora(1)xora(2)xora(3)xora(4)xora(5)xora(6);c=a,实验51,实验内容:完成1位全加器的设计。提示信息:输入为A,B,C,其中A、B为输入数据,C为输入的进位标志位;输出为Sum和Car,其中Sum为本次运算结果位,Car为本次进位标志位。,5-1代码_,libraryieee;useieee.std_logic_1164.all;entityfulladdisport(a,b,c:instd_logic;car,s:outstd_logic);endentityfulladd;architecturebehavoffulladdisbegins=axorbxorc;car=(aandb)or(bandc)or(canda);endbehav;,实验52,实验内容:完成4位全加法器的设计。提示信息:一个4位的全加法器可以由4个1位的全加法器级联而成。,A(0),B(0),S(0),C(1),C(2),C(3),Co,A(1),B(1),S(1),S(2),S(3),A(2),B(2),A(3),B(3),5-2代码_,libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entityfulladd4isport(a,b:instd_logic_vector(3downto0);c0:outstd_logic;s:outstd_logic_vector(3downto0);endfulladd4;architecturestroffulladd4issignalc1,c2,c3:std_logic;signalt:std_logic;componentfulladdport(a,b,c:instd_logic;car,sum:outstd_logic);endcomponent;begint=0;u1:fulladdportmap(a(0),b(0),t,c1,s(0);u2:fulladdportmap(a(1),b(1),c1,c2,s(1);u3:fulladdportmap(a(2),b(2),c2,c3,s(2);u4:fulladdportmap(a(3),b(3),c3,c0,s(3);endarchitecturestr;,实验61,实验内容:设计一个3bits的可逆计数器。提示信息:由名称可以知道,它的计数方式可以加(检测到CLK时钟的上升沿,计数器加1),也可以减(检测到CLK时钟的上升沿,计数器减1)。使用一个控制信号DIR决定计数器是作加法或减法的动作。,6-1代码_,updncount_3isport(clk,clr,updn:instd_logic;qa,qb,qc:outstd_logic);endlibraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityupdncount_3;architecturertlofupdncount_3issignalcount_3:std_logic_vector(2downto0);beginqa0);elsif(clkeventandclk=1)thenif(updn=1)thencount_3=count_3+1;elsecount_3=count_3-1;endif;endif;endprocess;endrtl,实验62,实验内容:分频器设计。要求:(1)设计一个占空比为50%的6分频器;(2)设计一个占空比为1:2的6分频器。提示信息:占空比为时钟周期中高电平与低电平之比。,6-2代码(_),libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityfdivisgeneric(N:integer:=6);port(clkin:instd_logic;clkout:outstd_logic);endfdiv;architectureaoffdivissignalcnt:integerrange0ton/2-1;n=6signaltemp:std_logic;beginprocess(clkin)beginif(clkineventandclkin=1)thenif(cnt=n/2-1)thencnt=0;temp=nottemp;elsecnt=cnt+1;endif;endif;endprocess;clkout=temp;enda;,6-2代码,占空比1:2(_),LIBRARYIEEE;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entityshiyan62isport(clkin:instd_logic;rest:instd_logic;clk6fen:outstd_logic);end;architecturertlofshiyan62issignalcounter:std_logic_vector(0to2);beginprocess(clkin,counter,rest)beginifrest=0thencounter=000;elsifclkineventandclkin=1thenifcounter5thencounter=counter+1;ifcounter3thenclk6fen=1;elseclk6fen=0;endif;elsecounter=000;endif;endif;endprocess;endarchitecturertl;,实验71,实验内容:设计完成一10进制加法计数器。该计数器具有同步置数、同步清零的功能。输入信号为:clk,clr,en,datain输出信号为:dataout,co当输入信号clr1时,计数器清零;当置数信号en=1时,计数器装入输入datain为计数初值重新计数;其它情况下,计数器进行10进制加法计数,每计数到9时,输出co1,表示进位。,7-1代码(_),libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycount10isport(clr,clk,en:instd_logic;datain:instd_logic_vector(3downto0);co:outstd_logic;dataout:outstd_logic_vector(3downto0);endcount10;architecturebehavofcount10issignaltmp:std_logic_vector(3downto0);beginprocess(clk)beginif(clkeventandclk=1)thenif(clr=1)thentmp=0000;elsif(en=1)thentmp=datain;elsif(tmp=1001)thentmp=0000;co=1;elsetmp=tmp+1;co=0;endif;endif;endprocess;dataout=tmp;endbehav;,实验72,实验内容:设计完成100进制加法计数器。要求:采用构造体结构化描述方式由2个10进制计数器级联而成,7-2代码_,顶层文件:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycount100isport(clk:instd_logic;co:outstd_logic;dout1,dout2:outstd_logic_vector(3downto0);endco

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论