可编程ASIC设计作业.doc
《可编程ASIC技术》课程作业2015
1.请对下列VerilogHDL模块进行仿真和分析,说明其描述方式,画出对应的逻辑图或写出逻辑表达式(组),并概括地说明其逻辑功能。
moduleexe1n(out,d3,d2,d1,d0,s1,s0);
outputout;
inputd3,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
将程序进行功能仿真,功能仿真图如下所示:
(1)当s1=0,s0=0时
(2)当s1=0,s0=1时
(3)当s1=1,s0=0时
(4)当s1=1,s0=1时
由仿真图分析知,根据不同的s1和s0,输出通道进行变化:
当s1=0,s0=0时,out=d0;
当s1=0,s0=1时,out=d1;
当s1=1,s0=0时,out=d2;
当s1=1,s0=1时,out=d3。
逻辑表达式组:
Out=d(s1s2)
实现的逻辑功能就是典型的4选1数据选择器
2.请对下列VerilogHDL模块进行仿真和分析,用时序波图形或流程框图描述其行为,并概括地说明其逻辑功能。如果要使输出fd_out的占空比为50%,需要对该模块做什么修改?
moduleexe2n(fd_out,clk,d,clr);
outputfd_out;
regfd_out;
input[15:0]d;
inputclk,clr;
reg[15:0]cnt;
always@(posedgeclk)
begin
if(!clr)cnt=4h0000;
else begin
cnt=cnt-1;
if(cnt==0)beginfd_out=1;cnt=d;end
elsefd_out=0;
end
end
endmodule
(1)将程序进行功能仿真,仿真波形图如图所示:
由图知,该程序实现的是可变模的减法计数器,输出的是每当到达设定模值就输出1,相当于对设定模进行检测。
(2)若要使输出fd_out占空比为50%,则可以规定模值d=1,如下图:
3.请对下列VerilogHDL模块进行仿真和分析,写出对应的逻辑表达式(组)或真值表,并概括地说明其逻辑功能。
moduleexe3n(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_selorop_aorop_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_aop_b;
3b101: op_result=op_a|op_b;
3b110: op_result=op_a^op_b;
3b111: op_result=op_a~^op_b;
endcase
end
endmodule
将程序进行功能仿真,功能仿真波形如图:
当fun_sel=000时,op_result=op_a+op_b
当fun_sel=001时,op_result=op_a-op_b;
当fun_sel=010时,op_result=op_a*op_b;
当fun_sel=011时,op_result=op_a/op_b;
当fun_sel=100时,op_result=op_aop_b;
当fun_sel=101时,op_result=op_a|op_b;
当fun_sel=110时 op_result=op_a^op_b;
当fun_sel=111时 op_result=op_a~^op_b;
由此可知,该段程序实现的功能是:
根据不同的输入选择信号(000,001,010,011,100,101,110