VHDL实验新及答案.ppt_第1页
VHDL实验新及答案.ppt_第2页
VHDL实验新及答案.ppt_第3页
VHDL实验新及答案.ppt_第4页
VHDL实验新及答案.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 clk eventandclk 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 clk eventandclk 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 实验2 1 实验内容 完成下述模块的设计 实现真值表中的半加与半减的功能 提示信息 将加法与减法区分成两个功能模块 使用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 实验2 2 实验内容 设计一个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 1 thentemp a b elsetemp a b endif endprocess s temp 3downto0 co temp 4 endbehav 实验3 1 实验内容 如下表所示为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 clk eventandclk 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 实验3 2 实验内容 3 8译码器的设计 要求用WITH SELECT语句完成 图形见下页 提示信息 常见的3 8译码器的真值表如右 A0A1A2 000 001 010 011 100 101 110 111 Y0Y1Y2Y3Y4Y5Y6Y7 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 当EN 1时 译码器正常工作 当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 beginsel a 实验4 1功能要求 4位数据输入 可表示0 F十六个数值 将其译码为共阴极7段LED的显示码 LED的每段和dout的连接关系见下图 模块名 LEDDECODER输入端口 i 数据输入 4位 输出端口 dout 译码输出 7位 4 1代码 libraryieee useieee std logic 1164 all entityleddecoderisport i instd logic vector 3downto0 dout outstd logic vector 0to6 endleddecoder architecturebehavofleddecoderisbeginprocess i begincaseiiswhen 0000 doutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout 0000000 endcase endprocess endbehav 实验4 2 实验内容 设计完成一个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 实验5 1 实验内容 完成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 实验5 2 实验内容 完成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 实验6 1 实验内容 设计一个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 beginqa 0 elsif clk eventandclk 1 thenif updn 1 thencount 3 count 3 1 elsecount 3 count 3 1 endif endif endprocess endrtl 实验6 2 实验内容 分频器设计 要求 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 clkin eventandclkin 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 0 thencounter 000 elsifclkin eventandclkin 1 thenifcounter 5thencounter counter 1 ifcounter 3thenclk6fen 1 elseclk6fen 0 endif elsecounter 000 endif endif endprocess endarchitecturertl 实验7 1 实验内容 设计完成一10进制加法计数器 该计数器具有同步置数 同步清零的功能 输入信号为 clk clr en datain输出信号为 dataout co当输入信号clr 1 时 计数器清零 当置数信号en 1 时 计数器装入输入datain为计数初值重新计数 其它情况下 计数器进行10进制加法计数 每计数到9时 输出co 1 表示进位 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 clk eventandclk 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 实验7 2 实验内容 设计完成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 ou

温馨提示

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

评论

0/150

提交评论