云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 第8章 仿真

第8章 仿真

  • 62 次阅读
  • 3 次下载
  • 2025/6/27 21:42:51

#DELY #DELY end

A= 8'd255; B= 8'd255; cin=1'b1; $finish;

initial $monitor($time,,,\; //输出格式定义 endmodule

module add8(SUM,cout,A,B,cin); //待测试的8位加法器模块 output[7:0] SUM; output cout; input[7:0] A,B; input cin;

assign {cout,SUM}=A+B+cin; endmodule

上面的例子用ModelSim编译仿真后的输出波形如图8.8(书中217页)所示。 文本输出如下所示:

3、2选1数据选择器的仿真

下面是一个2选1多路选择器仿真的例子。 例8-29 2选1多路选择器的仿真 'timescale 1ns/1ns module mux_tp; reg a,b,sel; wire out;

MUX2_1 m1(out,a,b,sel); //调用待测试模块 initial begin

a=1'b0; b=1'b0; sel=1'b0; #5 sel=1''b1; #5 a=1'b1; #5 sel=1'b1;

#5 a=1'b0; b=1'b1; sel=1'b0;

25

sel=1'b0;

#5 sel=1'b1;

#5 a=1'b1; b=1'b1; sel=1'b0; #5 sel=1'b1; end

initial $monitor($time,,,\; endmodule

module MUX2_1(out,a,b,sel); input a,b,sel; output out;

not #(0.4,0.3) (sel_,sel); and #(0.7,0.6) (a1,a,sel_); and #(0.7,0.6) (a2,b,sel); or #(0.7,0.6) (out,a1,a2); endmodule

2选1多路选择器的源代码如下所示,采用门级结构描述,图8.9(书中218页)是其门级原理图。 module MUX2_i(out, a,b,sel); //待测试的2选1MUX模块 input a,b,sel; output out;

not#(0.4,0.3)(sel_,sel); // #(0.4,0.3)为门延时 and#(0.7,0.6) (a1,a,sel_); and#(0.7,0.6) (a2,b,sel); or#(0.7,0.6) (out,al,a2 ); endmodule

上面的程序用ModelSim编译,仿真波形如图8.10(书中218页)所示。 主窗口中的文本显示如下所示:

从上面的输出结果可看出:由于在2选1 NEUX模块中对门元件的延时作了定义,因此当输入a、b、sel的值发生变化时,out并没有立即改变,而是经过相应的门延时后,out的值才改变。

8.5.4 时序电路的仿真

以一个带有同步复位的8位计数器的仿真为例,介绍时序电路的仿真。

26

例8-30 8位计数器的仿真 'timescale 10ns/1ns module count8_tp;

reg clk,reset; //输入激励信号定义为reg型 wire[7:0] qout; //输出信号定义为wire型 parameter DELY=100;

counter C1(qout,reset,clk); //调用测试对象 always #(DELY/2) clk = ~clk; //产生时钟波形 initial //激励波形定义 begin

clk =0; reset=0;

#DELY reset=1; #DELY

reset=0;

#(DELY*300) $finish; end //结果显示

initial $monitor($time,,,\; endmodule

module counter(qout,reset,clk); //待测试的8位计数器模块 output[7:0] qout; input clk,reset; reg[7:0] qout; always @(posedge clk) begin

if (reset) qout<=0; else

qout<=qout+1; end endmodule

上面的程序用ModelSim编译仿真后的波形如图8.11(书中220页)所示。 主窗口中的文本显示如下所示:.

27

搜索更多关于: 第8章 仿真 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

#DELY #DELY end A= 8'd255; B= 8'd255; cin=1'b1; $finish; initial $monitor($time,,,\; //输出格式定义 endmodule module add8(SUM,cout,A,B,cin); //待测试的8位加法器模块 output[7:0] SUM; output cout; input[7:0] A,B; input cin; assign {cout,SUM}=A+B+cin; endmodule 上面的例子用ModelSim编译仿真后的输出波形如图8.8(书中217页)所示。 文本输出如下所示: 3、2选1数据选择器的仿真 下面是一个2选1多路选择器仿真的

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com