




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、可编程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,
2、 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模块进行仿真和分析,用时序波图形或流程框图描述其行为,并概括
3、地说明其逻辑功能。如果要使输出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 <= 4'h0000;elsebegincnt <= cnt - 1;if (cnt=0) begin fd_out <= 1; cnt <= d; endelse fd_out <= 0;endend
4、Endmodule(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 <= 4'h0000;elsebegincnt <= cnt - 1;if (cnt=0) begin
5、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)beginca
6、se (func_sel)3'b000:op_result <= op_a + op_b;3'b001:op_result <= op_a - op_b;3'b010:op_result <= op_a * op_b;3'b011:op_result <= op_a / op_b;3'b100:op_result <= op_a & op_b;3'b101:op_result <= op_a | op_b;3'b110:op_result <= op_a op_b;3'b111:o
7、p_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_res
8、ult = 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,in
9、8,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原程序的时序波
10、图: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=3'b100) case(in) 3'd0: out=8'b11111110; 3'd1: out=8'b11111101; 3'd2: ou
11、t=8'b11111011; 3'd3: out=8'b11110111; 3'd4: out=8'b11101111; 3'd5: out=8'b11011111; 3'd6: out=8'b10111111; 3'd7: out=8'b01111111; endcase else out=8'b11111111; endEndmodule原程序的时序波图:6请用Verilog HDL或VHDL,设计一个可同步预置、异步清零的8位移位寄存器,并在Quartus下对其进行仿真验证。module
12、60;exe6(out,in,reset,set,clk); output7:0 out;/定义四位输出端input in,reset,set,clk;/输入信号、清零端、置数端、时钟信号reg7:0 out; reg7:0 md;/置数寄存器always(posedge clk) begin begin md=8'b11111111;end/这里预置数为11111111,可以根据需要更改 if(reset)
13、0; begin out<=0;end else begin if(set)
14、 begin out<=md;end/置数信号为1,置数 else begin out<=out,in;end
15、0; end endEndmodule原程序的时序波图: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<=8'b00000000; en
16、d else if(en=1) begin Q<=S; end else begin Q<=Q+1'b1; 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,
17、cin),(m3,a,cin); assign sum=a+b+cin;or(cout,m1,m2,m3); endmodule(2)数据流描述module exe8_2 (a,b,cin,sum,cout); input cin; input 2:0 a,b; output 2:0 sum; output cout; assign cout,sum=a+b+cin; endmodule (3)行为描述module exe8_
18、3(cout,sum,a,b,cin); output2:0 sum; output cout; input2:0 a,b; input cin; reg2:0 sum; reg cout; always ( a or b or cin ) be
19、gin cout,sum=a+b+cin; end endmodule 9请利用状态机设计一个序列检测器,该检测器在输入序列为“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
20、S0=3'b000,S1=3'b001,S2=3'b010,S3=3'b011,S4=3'b100,S5=3'b101,S6=3'b110,S7=3'b111;/*状态编码*/ 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: i
21、f(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
22、(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)module exe10_1(sum,cout,cout1,cout2,a0,a1,a2,a3,cin,clk); output7:
23、0 sum;output cout1,cout2,cout;input7:0 a0,a1,a2,a3;input cin,clk;reg7:0 S1,S2,sum; reg cout1,cout2,cout; always(posedge clk) begin cout1,S1=a0+a1+cin;end always(posedge clk) begin cout2,S2=S1+a2; end alw
24、ays(posedge clk) begin cout,sum=S2+a3; end endmodule(10_2)module exe10_2(sum,cout,cout1,cout2,a0,a1,a2,a3,cin,clk); output7:0 sum;output cout1,cout2,cout;input7:0 a0,a1,a2,a3;input cin,clk;reg7:0 S1,S2,sum; reg cout1,cout2,c
25、out; always(posedge clk) begin cout1,S1=a0+a1+cin;end always(posedge clk) begin cout2,S2=a2+a3; end always(posedge clk) begin cout,sum=S1+S2; end endmodule11 请用流水线技术对上例中的sum=(a0+a1)+a2)+a3的实现方式进行优化,对比最高工作频率,
26、并分析说明流水线设计技术为何能提高数字系统的工作频率?module addder8_3(cout1,cout2,cout3,sum,a1,a2,a3,a4,cin,clk); output7:0 sum;output cout1,cout2,cout3;input7:0 a1,a2,a3,a4;input cin,clk;reg7:0 sum,sum1,sum2; reg cout1,cout2,cout3,firstc,secondc,thirdc; reg3:0 tempa1,te
27、mpa2,tempa3,tempb1,tempb2,tempb3,firstsum,secondsum,thirdsum; always(posedge clk) begin firstc,firstsum=a13:0+a23:0+cin; tempa1=a17:4; tempb1=a27:4; end always(posedge clk) begin cout1,sum17:4=tempa1+tempb1+firstc; sum13:0=firstsum; end always(posedge clk) begin secondc,secondsum=sum13:0+a33:0;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电信云基础知识培训内容课件
- 申通仲裁课件
- 影视与语文综合实践活动研究
- 田径场安全知识培训内容课件
- QQ游戏属于教学课件吗
- 新解读《GB-T 36767-2018醇胺类脱硫脱碳剂净化性能评价方法》
- 江苏南京2020-2023年中考满分作文53篇
- 月考试题(范围:第八、九单元)(含答案)2025-2026学年三年级数学上册(人教版)
- 广东省东莞市常香江中龙五校2024-2025学年八年级上学期期末生物试题(含答案)
- 新解读《GB-T 9999.2-2018中国标准连续出版物号 第2部分:ISSN》
- 企业技术人员管理制度
- DB13T 5545-2022 选矿厂安全生产基本条件
- 探索语文学习的有意义情境任务设计
- 血管内导管相关性血流感染预防与诊治2025
- JG/T 237-2008混凝土试模
- JG/T 232-2008卫浴型散热器
- 智慧停车系统开发与运营合作
- T/SHPTA 102-2024聚四氟乙烯内衬储罐技术要求
- T/CAQP 001-2017汽车零部件质量追溯体系规范
- 高速考试题目及答案
- 眼内炎护理疑难病例讨论
评论
0/150
提交评论