可编程ASIC技术课程作业.doc_第1页
可编程ASIC技术课程作业.doc_第2页
可编程ASIC技术课程作业.doc_第3页
可编程ASIC技术课程作业.doc_第4页
可编程ASIC技术课程作业.doc_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

可编程ASIC技术课程作业1 请对下列Verilog HDL模块进行仿真和分析,说明其描述方式,画出对应的逻辑图或写出逻辑表达式(组),并概括地说明其逻辑功能。module exe1(out, d3, d2,d1,d0, s1,s0);output out;input d3, d2,d1,d0, s1,s0;not (not_s1,s1), (not_s0,s0);and (out0, d0, not_s1, not_s0), (out1, d1, not_s1, s0);and (out2, d2, s1, not_s0), (out3, d3, s1, s0);or (out, out0, out1, out2, out3);Endmodule答:该程序逻辑功能为,根据不同的s1和s0,输出通道改变: (1) 当s1=0,s0=0时,out0=d0;(2) 当s1=0,s0=1时,out1=d1; (3) 当s1=1,s0=0时,out2=d2; (4) 当s1=1,s0=1时,out3=d3;逻辑表达式组为:out0=S1S0d0 out1=S1S0d1 out2=S1S0d2out3=S1S0d3out=out0+out1+out2+out3 实现的逻辑功能为典型的数据通道选择器。2.请对下列Verilog HDL模块进行仿真和分析,用时序波图形或流程框图描述其行为,并概括地说明其逻辑功能。如果要使输出fd_out的占空比为50%,需要对该模块做什么修改?module exe2(fd_out, clk, d, clr);output fd_out;reg fd_out;input 15:0 d;input clk, clr;reg 15:0 cnt;always (posedge clk)beginif (!clr) cnt = 4h0000;elsebegincnt = cnt - 1;if (cnt=0) begin fd_out = 1; cnt = d; endelse fd_out = 0;endendEndmodule(1)原程序时序波形图:该程序实现的是可变模的减法计数器,输出的是每当到达设定模值就输出1,相当于对设定模进行检测。(2)要使输出fd_out的占空比为50%,对该模块做出如下修改:module exe2(fd_out, clk, d, clr);output fd_out;reg fd_out;input 15:0 d;input clk, clr;reg 15:0 cnt;always (posedge clk)beginif (!clr) cnt = 4h0000;elsebegincnt = cnt - 1;if (cnt=0) begin fd_out = 1; cnt = 1; endelse fd_out = 0;endendEndmodule修改程序后的时序波图:3. 请对下列Verilog HDL模块进行仿真和分析,写出对应的逻辑表达式(组)或真值表,并概括地说明其逻辑功能。module exe3(op_result, func_sel, op_a, op_b);output 7:0 op_result;input 2:0 func_sel;input 3:0 op_a, op_b;reg 7:0 op_result;always (func_sel or op_a or op_b)begincase (func_sel)3b000:op_result = op_a + op_b;3b001:op_result = op_a - op_b;3b010:op_result = op_a * op_b;3b011:op_result = op_a / op_b;3b100:op_result = op_a & op_b;3b101:op_result = op_a | op_b;3b110:op_result = op_a op_b;3b111:op_result = op_a op_b;endcaseendEndmodule原程序的时序波图:该程序逻辑功能为:(1) 当fun_sel=000时,op_result = op_a + op_b;(2) 当fun_sel=001时,op_result = op_a - op_b;(3) 当fun_sel=010时,op_result = op_a * op_b;(4) 当fun_sel=011时,op_result = op_a / op_b;(5) 当fun_sel=100时,op_result = op_a & op_b;(6) 当fun_sel=101时,op_result = op_a | op_b;(7) 当fun_sel=110时, op_result = op_a op_b;(8) 当fun_sel=111时, op_result = op_a op_b;由此可知,该段程序实现的功能是:根据不同的输入选择信号(000,001,010,011,100,101,110,111),对于两个四位二进制数进行加、减、乘、除、与、或、异或、同或运算。4. 请用持续赋值语句,设计一个可实现带使能端(E=1使能)的双4选1数据选择器的Verilog HDL模块。module exe4(outa,outb,in1,in2,in3,in4,in5,in6,in7,in8,sel1,sel2,en); input in1,in2,in3,in4,in5,in6,in7,in8,en; output outa,outb; input sel1,sel2; wire outa,outb;reg r_outa,r_outb;assign outa=r_outa;assign outb=r_outb;always (en)if(en)beginr_outa=sel1?(sel2?in4:in3):(sel2?in2:in1); r_outb=sel1?(sel2?in8:in7):(sel2?in6:in5);end Endmodule原程序的时序波图:5请用Verilog HDL或VHDL,设计一个功能和引脚与74138类似的译码器,并在Quartus下对其进行仿真验证。module exe5(out, in,en);output7:0 out;/*定义八位二进制码输出口*/input2:0 in;/*定义三位二进制码输入口*/input2:0 en;/*三个使能端*/reg7:0 out;always (in or en) begin if(en=3b100) case(in) 3d0: out=8b11111110; 3d1: out=8b11111101; 3d2: out=8b11111011; 3d3: out=8b11110111; 3d4: out=8b11101111; 3d5: out=8b11011111; 3d6: out=8b10111111; 3d7: out=8b01111111; endcase else out=8b11111111; endEndmodule原程序的时序波图:6请用Verilog HDL或VHDL,设计一个可同步预置、异步清零的8位移位寄存器,并在Quartus下对其进行仿真验证。moduleexe6(out,in,reset,set,clk);output7:0out;/定义四位输出端inputin,reset,set,clk;/输入信号、清零端、置数端、时钟信号reg7:0out;reg7:0md;/置数寄存器always(posedgeclk)beginbeginmd=8b11111111;end/这里预置数为11111111,可以根据需要更改 if(reset)beginout=0;endelsebeginif(set)beginout=md;end/置数信号为1,置数elsebeginout=out,in;endendendEndmodule原程序的时序波图:7 请用Verilog HDL或VHDL,设计一个上升沿触发的可预置、可清零的256进制计数器,并在Quartus下对其进行仿真验证。如果要将其改为60进制计数器,应对该设计做哪些修改?module exe7(Q,en,clock,clear,S);output 7:0Q;input 7:0S;input en,clock,clear;reg7:0Q;always (posedge clock) begin if (clear=0) begin Q=8b00000000; end else if(en=1) begin Q=S; end else begin Q=Q+1b1; end endendmodule原程序的时序波图:8请使用Verilog HDL,分别用结构描述、数据流描述、行为描述三种方式,设计一个8位可级联加法器(有进位输入、进位输出),并比较上述三种描述方式各自的优缺点。答:(1)结构描述module exe8_1(a,b,cin,sum,cout); input cin; input2:0 a,b; output cout;output 2:0 sum; wire m1,m2,m3; and (m1,a,b),(m2,b,cin),(m3,a,cin); assign sum=a+b+cin;or(cout,m1,m2,m3); endmodule(2)数据流描述moduleexe8_2(a,b,cin,sum,cout);inputcin;input2:0a,b;output2:0sum;outputcout;assigncout,sum=a+b+cin;endmodule(3)行为描述moduleexe8_3(cout,sum,a,b,cin);output2:0sum;outputcout;input2:0a,b;inputcin;reg2:0sum;regcout;always(aorborcin)begincout,sum=a+b+cin;endendmodule9请利用状态机设计一个序列检测器,该检测器在输入序列为“1001”时输出为1,其他情况下输出为0。请画出状态转移图,并用Verilog HDL进行设计和仿真。module exe9(out,in,clk,reset); output out;/*结果输出端*/ input in;/*串行输入的数据*/ input reset,clk;/*清零信号、时钟信号*/ reg out; reg3:0 S,NS; parameter S0=3b000,S1=3b001,S2=3b010,S3=3b011,S4=3b100,S5=3b101,S6=3b110,S7=3b111;/*状态编码*/ always(posedge clk or negedge reset)/*根据输入信号更新状态*/ begin if(!reset) S=S0; else S=NS; end always(S or in)/*根据输入,锁存记忆输入信号*/ begin case(S) S0: if(in) NS=S1; else NS=S0; S1: if(in) NS=S3; else NS=S2; S2: if(in) NS=S5; else NS=S4; S3: if(in) NS=S7; else NS=S6; S4: if(in) NS=S1; else NS=S0; S5: if(in) NS=S3; else NS=S2; S6: if(in) NS=S5; else NS=S4; S7: if(in) NS=S7; else NS=S6;endcase end always(S or reset or in) /*输出对应的结果*/ begin if(!reset) out= 0; else if(S = S4) if(NS=S1) out= 1; else out= 0; else out= 0; end Endmodule原程序的时序波图:10请设计一个加法器,实现sum=a0+a1+a2+a3,a0、a1、a2、a3宽度都是8位。如用下面两种方法实现,哪种方法更好一些(即速度更快 and/or 资源更省)。(1)sum=(a0+a1)+a2)+a3(2)sum=(a0+a1)+(a2+a3)答:第一种方法速度更快一些(10_1)moduleexe10_1(sum,cout,cout1,cout2,a0,a1,a2,a3,cin,clk);output7:0sum;outputcout1,cout2,cout;input7:0a0,a1,a2,a3;inputcin,clk;reg7:0S1,S2,sum;regcout1,cout2,cout;always(posedgeclk)begincout1,S1=a0+a1+cin;endalways(posedgeclk)begincout2,S2=S1+a2;endalways(posedgeclk)begincout,sum=S2+a3;endendmodule(10_2)moduleexe10_2(sum,cout,cout1,cout2,a0,a1,a2,a3,cin,clk);output7:0sum;outputcout1,cout2,cout;input7:0a0,a1,a2,a3;inputcin,clk;reg7:0S1,S2,sum;regcout1,cout2,cout;always(posedgeclk)begincout1,S1=a0+a1+cin;endalways(posedgeclk)begincout2,S2=a2+a3;endalways(posedgeclk)begincout,sum=S1+S2;endendmodule11 请用流水线技术对上例中的sum=(a0+a1)+a2)+a3的实现方式进行优化,对比最高工作频率,并分析说明流水线设计技术为何能提高数字系统的工作频率?moduleaddder8_3(cout1,cout2,cout3,sum,a1,a2,a3,a4,cin,clk);output7:0sum;outputcout1,cout2,cout3;input7:0a1,a2,a3,a4;inputcin,clk;reg7:0sum,sum1,sum2;regcout1,cout2,cout3,firstc,secondc,thirdc;reg3:0tempa1,tempa2,tempa3,tempb1,tempb2,tempb3,firstsum,secondsum,thirdsum;always(posedgeclk)beginfirstc,firstsum=a13:0+a23:

温馨提示

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

评论

0/150

提交评论