已阅读5页,还剩43页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1.用verilog中case语句设计一个3-8译码器答案:module decode3-8(G1,Y,G2,A,G3);input G1,G2,G3;wire G1,G2,G3;input 2:0 A;wire 2:0A;output 7:0Y;reg 7:0Y;alway(A,G1,G2,G3) begin S=G2!G3; if(G1=0) Yy) xgy=1; else xgy=0; if(xy) xsy=1; else xsy=0; endendmodule5. 用Verilog HDL来描述乘法器 答案: module mult(x,y,product); input 3:0 x,y; output 7:0 product; assign product=x*y; endmodule6.自己设计一款数据锁存器(8位输入端Q,8位输出端D)编写完整程序。module shujusuocunqi(Q,D,OE,G);output 7:0Q;reg7:0Q;input 7:0D;input OE,G;always(*) (-) (-) (-) (-) (-) (-) (-) endmodule答案: if(OE) Q=bz; else if(G) Q=D; else Q=Q;7.自己设计一款数据选择器(输入端分别是D0D7,输出端为Y)module shujuxuanzeqi(A,G,D0,D1,D2,D3,D4,D5,D6,D7,Y);input 2:0A;wire 2:0A;input G;wire G;input D0;wire D0;input D1;wire D1;input D2;wire D2;input D3;wire D3;input D4;wire D4;input D5;wire D5;input D6;wire D6;input D7;wire D7;output Y;reg Y;always(*) begin if(G=1) case(A) (-) (-) (-) (-) (-) (-) (-) (-) endcase else Y=0; endendmodule答案:3b000:Y=D0; 3b001:Y=D1; 3b010:Y=D2; 3b011:Y=D3; 3b100:Y=D4; 3b101:Y=D5; 3b110:Y=D6; 3b111:Y=D7;8.自己设计一款数据寄存器(输入端为8位输入端Q,输出端为8位输出端D) module jicunqi(D,Q,clk,rst);input7:0D;input rst,clk;output7:0Q;wire 7:0D; reg7:0Q;always (posedge clk or negedge rst ) (-) (-) (-) (-) Endmodule答案:if(!rst) Q=8b0000_0000; else Q=D;9.自己设计一款全加器(输出输入端自由命名)答案:module quanjiaqi(a,b,cin,count,sum);input a;wire a;input b;wire b;input cin;wire cin;output count;wire count;output sum;wire sum;assign count,sum=a+b+cin;endmodule10.设计一款4位2进制计数器(输入输出端自由命名)答案:module jishuqi(clk,reset,out);input clk;wire clk;input reset;wire reset;output out;reg 3:0out;always ( posedge clk or negedge reset ) if ( !reset) out= 4b0000 ; else out=out+1; endmodule11.设计一个寄存器程序。module jicunqi(D,Q,clk,rst);input7:0D;input rst,clk;output7:0Q;wire 7:0D; reg7:0Q;always (posedge clk or negedge rst ) begin if(!rst) begin Q=8b0000_0000; end else begin Q=D; end end endmodule12. 设计一个计数器程序module jishuqi(clk,reset,out);input clk;wire clk;input reset;wire reset;output out;reg 3:0out;always ( posedge clk or negedge reset ) begin if ( !reset) out= 4b0000 ; else out=out+1; endendmodule13. 设计数据锁存器程序module shujusuocunqi(Q,D,OE,G);output 7:0Q;reg7:0Q;input 7:0D;input OE,G;always(*)begin if(OE) begin Q=bz; end else begin if(G) Q=D; else Q=Q;End14. 设计一个数据选择器程序module shujuxuanzeqi(A,G,D0,D1,D2,D3,D4,D5,D6,D7,Y);input 2:0A;wire 2:0A;input G;wire G;input D0;wire D0;input D1;wire D1;input D2;wire D2;input D3;wire D3;input D4;wire D4;input D5;wire D5;input D6;wire D6;input D7;wire D7;output Y;reg Y;always(*) begin if(G=1) case(A) 3b000:Y=D0; 3b001:Y=D1; 3b010:Y=D2; 3b011:Y=D3; 3b100:Y=D4; 3b101:Y=D5; 3b110:Y=D6; 3b111:Y=D7; endcase else Y=0; endendmodule15. 4位乘法器的verilogHDL描述如下:module multicate_4_4(a,b,m);input 3:0a,b;wire 3:0a,b;output 7:0m;reg 7:0m;always (a or b)beginm=a*b;endendmodule16.D触发器的verilogHDL描述如下:module D_FF(d,clk,q,qn);input d,clk;wire d,clk;output q,qn;reg q,qn;always (posedge clk)beginq=d; qn=d;endendmodule17.利用verilogHDL语言描述二输入与非门:module nand_2(y,a,b);output y;input a,b;wire a,b;reg y;nand(y,a,b);endmodule18. 利用verilogHDL语言描述1位半加器:module half_add(s,c,a,b);output s,c;wire a,b;input a,b;reg s,c;always (a or b)beginc,s=a+b;EndEndmodule19.利用verilogHDL语言描述单向总线缓冲器:module tri_buffer(dout,din,en);output 7:0dout;input 7:0din,en;wire 7:0din,en;reg 7:0dout;always if(en)dout=din;elsedout=8bz;endmodule20.移位寄存器设计实例:module shifter( din, clk, clr, dout); input din, clk, clr; output 7:0 dout; reg 7:0 dout; always (posedge clk) begin if(clr) _ /清零 _ _ /左移一位 _ /把输入信号放入寄存器的最低位endend endmodule答案:dout = 8b0; else begin dout = dout1; dout0 = din; 21.电平敏感型锁存器设计实例:module latch3( q, data, clk); output q; _ _always (clk or data) _ _ _end endmodule 答案:input data, clk; reg q; begin if(clk) q=data; 22.D触发器:module flop(data,clock,clear,q,qb); input data,clock,clear; output q,qb; nand nd1(a,data,clock,clear); _ _ _ _ _ _ not iv1(ndata,data); iv2(nclock,clock); endmodule 答案:nd2(b,ndata,clock); nd4(d,c,b,clear); nd5(e,c,nclock); nd6(f,d,nclock); nd8(qb,q,f,clear); nand nd3(c,a,d); nd7(q,e,qb);23.四位全加器:module fulladder4(sum,cout,a,b,cin); _ _ _ assign cout,sum =a+b+cin; endmodule答案:output3:0 sum; output cout; input 3:0 a,b; input cin;24.8-3编码器的设计实例 编码器设计方案之一:module encoder1(out,in); output 2:0 out; input 7:0 in; reg 2:0 out; always (in) begin_ _ _ _ _end end end endmodule 答案:local integer i; out = 0; for( i=0; i8; i=i+1 ) begin if( ini ) begin out = i;25.同步清零D触发器和module dff_tongbu (q,d,clk,clr); input d,clk,clr;output q;reg q;always (negedge clock) if (clr) q=0;else q=d;endmodule 26.异步清零D触发器module dff_yibu(q,d,clk,clr);/异步清零不受时钟控制input d,clk,clr;output q;reg q;always (clr) if (clr) q=0;else q=d27.利用verilog语言设计一个1/2分频器Module half_clk(reset,clk_in,clk_out);Input clk_in,reset;Output clk_out;reg clk_out;always(posedge clk_in)begin if(!reset)clk_out = 0;else clk_out=clk_out;endendmodule 28.使用verilog设计一个七段数码管译码器module SEG7_LUT ( input3:0 iDIG, output reg 6:0 oSEG );always(iDIG)begin case(iDIG)4h1: oSEG = 7b1111001; 4h2: oSEG = 7b0100100; | 4h3: oSEG = 7b0110000; 4h4: oSEG = 7b0011001;| 4h5: oSEG = 7b0010010; 4h6: oSEG = 7b0000010; 4h7: oSEG = 7b1111000;4h8: oSEG = 7b0000000; | 4h9: oSEG = 7b0011000; 4ha: oSEG = 7b0001000; 4hb: oSEG = 7b0000011; 4hc: oSEG = 7b1000110; 4hd: oSEG = 7b0100001; 4he: oSEG = 7b0000110; 4hf: oSEG = 7b0001110; default: oSEG = 7b1000000; endcase endendmodul30.数据选择器是在多路数据传送过程中,能够根据需要将其中任意一路选出来的电路。根据下表(8选1数据选择器的真值表)编写完成下面的Verilog代码module eda_8xuanyi(a,d0,d1,d2,d3,d4,d5,d6,d7,g,y);input 2:0a;input g;input d0,d1,d2,d3,d4,d5,d6,d7;output y;reg y;always (g,a)begin endEndmodule答案:if(g=0) y=0;Else case(a) 3b000:y=d0; 3b001:y=d1; 3b010:y=d2; 3b011:y=d3; 3b100:y=d4; 3b101:y=d5; 3b110:y=d6; 3b111:y=d7; Endcase31.编写一个带预置位,清零输入,上跳沿触发的边沿触发器的Verilog 代码。其逻辑功能表以及电路符号如下图所示。module dchufa(CLK,RESET,SET,D,Q,Qn);答案:input CLK;wire CLK;input RESET;wire RESET;input SET;wire SET;input D;wire D;output Q;reg Q;output Qn;wire Qn;assign Qn=Q;always(posedge CLK or negedge RESET or negedge SET)beginif (!RESET)Q=0;else if(!SET)Q=1;elseQ=D;end32.利用Verilog代码设计4位全加器。输入信号:被加数a3:0;加数b3:0;低位进位cin.输出信号:和数s3:0;进位co.module add4(a,b,cin,sum,count);Endmodule答案:input 3:0a;wire 3:0a;input 3:0b;wire 3:0b;input cin;wire cin;output 3:0sum;wire 3:0sum;output count;wire count;assign count,sum=a+b+cin;33.8_3编码器的真值表如下表所示,根据给出的部分Verilog代码,完成整个程序的编写。module bianma8_3(Y,A);input7:0Y;wire7:0Y;output2:0A;reg 2:0A;always(Y)beginendEndmodule答案:case(Y)8b00000001:A=3b000;8b00000010:A=3b001;8b00000100:A=3b010;8b00001000:A=3b011;8b00010000:A=3b100;8b00100000:A=3b101;8b01000000:A=3b110;8b10000000:A=3b111;default:A=3b000;endcase34.利用Verilog语言设计一位半加法器。输入信号:被加数a;加数b;输出信号:和数sum;进位count.答案:module halfadd(a,b,count,sum);input a;wire a;input b;wire b;output sum;wire sum;output count;wire count;assign sum=ab;assign count=a&b;endmodule35.编写一个4位的全加器(输入两个加数a、b ; 和sum ; 进位输入cin ; 进位输出cout ;)答案::module eda_qjq(a,b,cin,cout);input 3:0a;input 3:0b;input cin;output 3:0sum;output cout;beginassign cout,sum=a+b+cin ;endendmodule36.编写一个2选1多路器(输入a,b ; 输出out ; 输出由sl电平控制0是a、1是b)答案:Module eda_dlq(a,b,out,sl);Input a,b,sl;Output out;Reg out;always(sl or a or b)if(!s)out=a;else out=b;endmodule37.用Verilog HDL来描述乘法器 module mult(x,y,product); input 3:0 x,y; output 7:0 product; assign product=x*y; endmodule 38.4位计数器module counter(Q,clock,clear);output 3:0 Q;input clock,clear; reg 3:0Q;always(posedge clear or negedge clock);begin if(clear) Q=4d0; else Q=Q+1; end endmodule39.使用case语句实现四选一多路选择器module mux4_to_1(out,i0,i1,i2,i3,s1,s0);output out;input i0,i1,i2,i3;input s1,s0;reg out;always(s1 or s0 or i0 or i1 or i2 or i3)begincase(s1,s0)2b00:out = i0;2b01:out = i1;2b10:out = i2;2b11:out = i3;Default:out = 1bx;endcaseendendmodule40.顺序脉冲module shunxumaichong(clr,clk,q,rst);input clr,clk;input rst;output 7:0q;reg 7:0q;always ( posedge clk or posedge clr )beginif(clr)beginq = 8b00000000;endelsebegin q=(q1);end end endmodule41.设计8位计数器module counter(out,cout,data,load,cin,clk);output7:0 out;output cout;inout7:0 data;input load,cin,clk;reg7:0 out;always (posedge clk)beginif(load)out=data;elseout=out+cin;endassign cout=(&out)&cin;endmodule42.3-8译码器module a(y0,y1,y2,y3,din,A);output y0,y1,y2,y3;/4个数据通道input din;/数据输入input 1:0 A;reg y0,y1,y2,y3;always (din,A)beginy0=0;y1=0;y2=0;y3=0; /初始化,清零if(A=2b00)y0=din;else if(A=2b01)y1=din;else if(A=2b10)y2=din;else if(A=2b11)y3=din;endcaseendendmodule 43.设计一奇偶校验位生成电路,输入八位总线信号bus,输出及校验位odd,偶校验位even。module parity(even,odd,bus); output even,odd; input7:0 bus; /奇同偶异 assign even=bus; /偶校验用异或 assign odd=bus; /奇校验用同或 endmodule 44设计一个带复位端且对输入时钟clk进行二分频模块.设计要求:复位信号为同步、高电平有效,时钟的下降沿触发.module m2(out,clk,reset); input reset,clk; output out; reg out; always (negedge clk)begin if(reset) out=0;else out=out; end endmodule 45.设计一带异步复位端、异步置数段(低电平有效)的四位加法计数器,时钟clk上升沿有效),复位信号clr,置数信号load、输入数据data、输出qout。 module adder_4(qout,clr,clk,load,data); output3:0 qout; input3:0 data; input load,clr,clk; reg3:0 qout; always (posedge clk or negedge load or negedge clk)begin if(!load) qout=data; else if(!clr) qout=0; else qout=qout+1; end endmodule 47.设计一个带有异步复位控制端和时钟使能控制端的10进制计数器。 mdule CNT10 (CLK,RST,EN,LOAD,COUT,DOUT,DATA); input CLK ; input EN ; input RST ; input LOAD ; input 3:0 DATA ; output 3:0 DOUT ; output COUT ;reg 3:0 Q1 ; reg COUT ; assign DOUT = Q1; always (posedge CLK or negedge RST) begin if (!RST) Q1 = 0; else if (EN) begin if (!LOAD) Q1 = DATA; else if (Q19) Q1 = Q1+1; else Q1 = 4b0000; end end always (Q1) if (Q1=4h9) COUT = 1b1;else COUT = 1b0; endmodule 48.如何用Verilog语言设计一个脉冲发生器?module maichongfsq(clr,clk,q,);output2:0 q;reg 2:0 q;input clr,clk;reg n;always ( posedge clk or posedge clr )begin if ( clr=1) beginq=3b000;/赋初值endelse beginq=3b100;n=n+1;endif(n=2) q1; /给初值进行移位elseq=3b100;end endmodule 49. 二选一多路器 module muxtwo(out,a,b,s1); input a,b,s1; output out; always(s1 or a or b) if(!s1)out=a; else out=b; endmodule50. 4位计数器module counter(Q,clock,clear);output 3:0 Q;input clock,clear; reg 3:0Q;always(posedge clear or negedge clock);begin if(clear) Q=4d0; else Q=Q+1; end endmodule51.用Veriog描述带清零端的4位寄存器module jicun (d,clk,clr,q);input clk,clr;input 3:0 d;outout 3:0 q;reg 3:0;always(posedge clk or posedge clr) begin If(clr) q=0; else q=d; end endmodule52. 触发器设计 module chufa (q,data,clk);ouput q;input data,clk;reg q;always(posedge clk)begin q装载使能。(13分)答案:module DownCouter(clk, clr, en, load, q); -1分 input clk,clr,en,load; output 3:0q; reg 3:0q; -2分always (posedge clk) if (clr=0) -1分 q3:0= 4b0000; else if (load=1) -2分 q3:0=4b1001; else if (en=1) -2分 begin if (q3:0 =4b0000) -2分q3:0= 4b1001;else q3:0=q3:0-1; -2分end endmodule -1分 55.根据你所学的知识,填写完整D触发器的程序代码 module Dchufaqi(clk,reset,s,d,q);input clk,r,s,d;output q;reg q;_endendmodule答案:always(posedge clk or posedge reset or posedge s) begin if(reset) q=1b0; else if(s) q=1b1; else q=d;56.根据你所学的相关知识,补充完整下面数据锁存器的程序代码,其中oen为三态使能端,高电平时锁存器处于高阻状态;g为状态使能端,当g为高电平时,输出等于输入,否则输出保持原来的状态。 module suocunqi(q,d,oen,g); output7:0 q;/数据输出端 input7:0 d;/数据输入端 input oen,g;/三态控制端 reg7:0 q; _ endmodule答案:always * begin if (oen) begin q=8bz; end else begin if(g) q=d; else q=q; end end57.请你认真都懂下图,并根据时间状态图把程序补充完整,clr是清零使能端,高电平有效,脉冲发生器的输入输出均为8位数据。clk clrq0q1q2module shunxumaichong(clk,clr,q); input clk,clr; wire clk,clr; output 7:0q; reg 7:0q; always (posedge clk or negedge clr) begin _ endmodule 答案 if(cl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 数据安全管理员安全宣传评优考核试卷含答案
- 矿井制冷降温工岗中工作技巧考核试卷含答案
- 儿童发育指导师安全文化强化考核试卷含答案
- 花艺环境设计师安全生产知识水平考核试卷含答案
- 通信传输设备装调工安全培训知识考核试卷含答案
- 粉末冶金烧结工岗中岗位环保责任制考核试卷含答案
- 2026木质生物质能源发电项目投资回报周期报告
- 2026第三代半导体在新能源发电系统渗透率提升趋势研究报告
- 2026抗电磁干扰低压电缆在医疗设备中的应用前景评估
- 2026中国液体化工物流行业价格形成机制报告
- 2025-2026七年级数学第一次月考卷(全解全析)(深圳专用北师大版七上第1~2章)
- (2026年)热性惊厥患儿护理查房课件
- 第一单元学习项目一《没有共产党就没有新中国》课件人音版(简谱)初中音乐八年级上册
- 高素质农民培育项目服务方案投标文件(技术方案)
- 吉利汽车经销商运营手册
- (74)-1.2.2.2 设施蔬菜生长发育与光照条件
- 《蜀道难》ppt(优秀).ppt
评论
0/150
提交评论