- 1、本文档共28页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第10章
Verilog行为仿真
测试程序TestBench
一个完整的简单例子 test fixture
被测试器件DUT是一个二选一多路器。测试程序(test fixture)提供测试激励及验证机制。
Test fixture使用行为级描述,DUT采用门级描述。下面将给出Test fixture的描述、DUT的描述及如何进行混合仿真。
DUT 被测器件 (device under test)
module MUX2_1 (
output wire out,
input wire a, b, sel
);
//wire sel, a1, b1;
// The netlist
not (sel_, sel);
and (a1, a, sel_);
and (b1, b, sel);
or (out, a1, b1);
endmodule
已定义的 Verilog基本单元的实例
a, b, sel是输入端口,out是输出端口。所有信号通过这些端口从模块输入/输出。
另一个模块可以通过模块名及端口说明使用多路器。实例化多路器时不需要知道其实现细节。这正是自上而下设计方法的一个重要特点。模块的实现可以是行为级也可以是门级,但并不影响高层次模块对它的使用。
Test Fixture template
module testfixture;
// Data type declaration
// Instantiate modules
// Apply stimulus
// Display results
endmodule
为什么没
有端口?
由于testfixture是最顶层模块,不会被其它模块实例化。因此不需要有端口。
Test Fixture — 如何说明实例
module testfixture;
// Data type declaration
// Instantiate modules
MUX2_1 mux (o, a, b, s);
// MUX2_1 mux (.out(o), .a(a), .b(b), .sel(s));
// Apply stimulus
// Display results
endmodule
module MUX2_1 (out, a, b, sel);
// Port declarations
output out;
input a, b, sel;
wire out, a, b, sel;
wire sel_, a1, b1;
// The netlist
not (sel_, sel);
and (a1, a, sel_);
and (b1, b, sel);
or (out, a1, b1);
endmodule
MUX的实例化语句包括:
模块名称:与引用模块相同
实例名称:任意,但要符合标记命名规则
端口列表:与引用模块的次序相同
Test fixture 激励描述
module testfixture;
// Data type declaration
reg a, b, s;
wire o;
// MUX instance
MUX2_1 mux (o, a, b, s);
// Apply stimulus
initial
begin
a = 0; b = 1; s = 0;
#5 b = 0;
#5 b = 1; s = 1;
#5 a = 1;
#5 $finish;
end
// Display results
endmodule
Time Values
a b s
0 0 1 0
5 0 0 0
10 0 1 1
15 1 1 1
例子中,a, b, s说明为reg类数据。reg类数据是寄存器类数据信号,在重新赋值前一直保持当前数据。
#5 用于指示等待5个时间单位。
$finish是结束仿真的系统任务。
完整的Test Fixture
module testfixture;
// 数据类型说明
reg a, b, s;
w
文档评论(0)