可编程ASIC设计作业讲解.pdf
《可编程ASIC设计作业讲解.pdf》由会员分享,可在线阅读,更多相关《可编程ASIC设计作业讲解.pdf(26页珍藏版)》请在三一文库上搜索。
1、可编程 ASIC技术课程作业2015 1请对下列 Verilog HDL 模块进行仿真和分析,说明其描述方式,画出对应的 逻辑图或写出逻辑表达式(组) ,并概括地说明其逻辑功能。 module exe1n(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
2、); or (out, out0, out1, out2, out3); endmodule out d3 d2 d1 WideAnd0 WideAnd3 WideOr0 WideAnd1 d0 s0 s1 WideAnd2 将程序进行功能仿真,功能仿真图如下所示: (1)当 s1=0,s0=0 时 (2)当 s1=0,s0=1 时 (3)当 s1=1,s0=0 时 (4)当 s1=1,s0=1 时 由仿真图分析知,根据不同的s1 和 s0,输出通道进行变化: (1) 当 s1=0,s0=0 时,out=d0; (2) 当 s1=0,s0=1 时,out=d1; (3) 当 s1=1,s0=0
3、 时,out=d2; (4) 当 s1=1,s0=1 时,out=d3。 逻辑表达式组: Out=d(s1s2) 实现的逻辑功能就是典型的4 选 1 数据选择器 2请对下列 Verilog HDL 模块进行仿真和分析,用时序波图形或流程框图描述 其行为,并概括地说明其逻辑功能。如果要使输出fd_out的占空比为 50%,需 要对该模块做什么修改? module exe2n(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
4、) begin if (!clr) cnt = 4h0000; else begin cnt = cnt - 1; if (cnt=0) begin fd_out = 1; cnt = d; end else fd_out = 0; end end endmodule + A160 B160 ADDER DQ PRE ENA CLR = A310 B310 EQUAL D ENA Q PRE CLR SEL DATAA DATAB OUT0 MUX21 SEL DATAA DATAB OUT0 MUX21 Add0 1 h1 - 17 h1FFFD - cnt150 Equal0 16 h00
5、00 - 32 h00000000 - cnt150 cnt3116 16 h0000 - fd_out clr d150 clk fd_outreg0 (1)将程序进行功能仿真,仿真波形图如图所示: 由图知,该程序实现的是可变模的减法计数器,输出的是每当到达设定模 值就输出 1,相当于对设定模进行检测。 (2)若要使输出 fd_out 占空比为 50% ,则可以规定模值d=1,如下图: 3. 请对下列 Verilog HDL 模块进行仿真和分析,写出对应的逻辑表达式(组) 或真值表,并概括地说明其逻辑功能。 module exe3n(op_result, func_sel, op_a, op
6、_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) begin case (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 3b10
7、1: op_result = op_a | op_b; 3b110: op_result = op_a op_b; 3b111: op_result = op_a op_b; endcase end endmodule + A40 B40 ADDER + A50 B50 ADDER x A30 B30 MULTIPLIER / A30 B30 DIVIDER SEL20 DATA70 OUT MUX SEL20 DATA70 OUT MUX SEL20 DATA70 OUT MUX SEL20 DATA70 OUT MUX SEL20 DATA70 OUT MUX SEL20 DATA70 O
8、UT MUX SEL20 DATA70 OUT MUX SEL20 DATA70 OUT MUX Add0 1 h0 - 1 h0 - Add1 1 h0 - 1 h1 - 1 h0 - 1 h1 - Mult0 Div0 op_result0 op_result1 op_result2 op_result3 op_result4 op_result5 op_result6 op_result7 op_result8 op_result9 op_result10 op_result11 op_result12 op_result13 op_result14 op_result15 Mux0 5
9、 h10 - 1 h0 - Mux2 5 h10 - 1 h0 - Mux3 5 h10 - Mux4 Mux5 Mux6 Mux7 op_result70 func_sel20 op_a30 op_b30 Mux1 5 h10 - 1 h0 - 将程序进行功能仿真,功能仿真波形如图: (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
10、_result = op_a / op_b; (5) 当 fun_sel=100 时,op_result = op_a (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. 请用持续赋值语句,
11、设计一个可实现带使能端(E=1 使能)的双 4 选 1 数据 选择器的 Verilog HDL 模块。 带使能端的双 4 选 1 的数据选择器程序: module exe4n(out,in0,in1,in2,in3,in4,in5,in6,in7,sel,en); input in0,in1,in2,in3,in4,in5,in6,in7; output out; input2:0 sel; input en; reg out; always (in0 or in1 or in2 or in3 or in4 or in5 or in6 or in7 or sel) begin if(en) o
12、ut=0; else begin case(sel) 3b000: out=in0; 3b001: out=in1; 3b010: out=in2; 3b011: out=in3; 3b100: out=in4; 3b101: out=in5; 3b110: out=in6; 3b111: out=in7; default: out=3bx; endcase end end endmodule SEL20 DATA70 OUT MUX 0 10 out in0 in1 in2 in3 in4 in5 in6 in7 en sel20 out0 Mux0 当使能端 en=1,无效时, out=0
13、; 当使能端 en=0,有效时, out 根据 sel 选择输出; 5请用 Verilog HDL 或 VHDL ,设计一个功能和引脚与74138 类似的译码器, 并在 Quartus下对其进行仿真验证。 译码器程序: module exe5n(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; 3d
14、1: out=8b11111101; 3d2: out=8b11111011; 3d3: out=8b11110111; 3d4: out=8b11101111; 3d5: out=8b11011111; 3d6: out=8b10111111; 3d7: out=8b01111111; endcase else out=8b11111111; end endmodule IN20OUT70 DECODER = A20 B20 EQUALSEL DATAA DATAB OUT0 MUX21 Decoder0 out70 en20 out70 8 hFF - Equal0 3 h4 - in20
15、 译码器仿真波形 6请用 Verilog HDL 或 VHDL ,设计一个可同步预置、异步清零的8 位移位寄 存器,并在 Quartus下对其进行仿真验证。 可预置、可清零的移位寄存器程序: module exe6n(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=4b00001101;end/* 这里预置数为 00
16、001101,可以根据需要更改 */ if(reset) begin out=0;end else begin if(set) begin out=md;end/*置数信号为 1,置数 */ else begin out=out,in;end end end endmodule D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR SEL DATAA DATAB OUT0 MUX21 SEL D
17、ATAA DATAB OUT0 MUX21 out1reg0 out2reg0 out3reg0 out4reg0 out5reg0 out6reg0 out7reg0 in reset set clk out70 out0reg0 out70 8 h0D - out158 8 h00 - 移位寄存器的仿真波形图 7请用 Verilog HDL 或 VHDL ,设计一个上升沿触发的可预置、可清零的256 进制计数器,并在Quartus 下对其进行仿真验证。如果要将其改为60 进制计数 器,应对该设计做哪些修改? (1)可预置、可清零的256 进制计数器程序: module exe7n(out,
18、in,reset,set,clk); output7:0 out;/*计数器的输出端 */ input7:0 in;/* 预置初始值的输入段 */ input reset,set,clk; reg7:0 out; always(posedge clk) begin if(!reset) out=8h00000000;/*清零端,低电平有效 */ else if(set) out=in;/*预置数 */ else out=out+1; end endmodule + A70 B70 ADDER D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D E
19、NA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR D ENA Q PRE CLR SEL DATAA DATAB OUT0 MUX21 SEL DATAA DATAB OUT0 MUX21 out0reg0 out1reg0 out2reg0 out3reg0 out4reg0 out6reg0 out7reg0 out70 out158 8 h00 - reset set clk out70 in70 Add0 8 h01 - out5reg0 仿真波形: (2)可预置、可清零的60 进制计数器程序: module ex
20、e7n(out,in,reset,set,clk); output7:0 out;/*计数器的输出端 */ input7:0 in;/*预置初始值的输入段 */ input reset,set,clk; reg7:0 out; always(posedge clk) begin if((!reset)|(out=8b00111100) out=8h00000000;/* 这里遇到 60 时就清零,这样实现了10 进制*/ else if(set) out=in;/*预置数 */ else out=out+1; end endmodule 仿真波形: 8请使用 Verilog HDL ,分别用结
21、构描述、数据流描述、行为描述三种方式,设 计一个 8 位可级联加法器(有进位输入、进位输出),并比较上述三种描述方式 各自的优缺点。 8 位加法器结构描述程序: /* 主程序 */ module exe8n(sum,cout,a,b,cin); input cin; input7:0 a,b; output7:0 sum; output cout; full_add1 f0(a0,b0,cin,sum0,cin1); full_add1 f1(a1,b1,cin1,sum1,cin2); full_add1 f2(a2,b2,cin2,sum2,cin3); full_add1 f3(a3,b
22、3,cin3,sum3,cin4); full_add1 f4(a4,b4,cin4,sum4,cin5); full_add1 f5(a5,b5,cin5,sum5,cin6); full_add1 f6(a6,b6,cin6,sum6,cin7); full_add1 f7(a7,b7,cin7,sum7,cin8); endmodule /* 调用程序 */ module full_add1(a,b,cin,sum,cout); input a,b,cin ; output sum,cout;wire s1,m1,m2,m3; and (m1,a,b),(m2,b,cin),(m3,a,
23、cin); xor(s1,a,b),(sum,s1,cin);or(cout,m1,m2,m3); endmodule 8 位加法器数据流描述程序: module exe82n(count,sum,a,b,cin);/* 进位信号、和、两个加数、低位的进位信号*/ input cin;/* 低位的进位信号,作为低位加法器,该信号为0;作为高位加法器, 该信号根据进位变化 */ input7:0 a,b; output7:0 sum; output count; assign count,sum=a+b+cin; endmodule DATAB DATAC DATAD CIN SHAREIN S
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 可编程 ASIC 设计 作业 讲解
链接地址:https://www.31doc.com/p-5411119.html