module testfixture; // Data type declaration
为什么没 有端口?
// Instantiate modules
// Apply stimulus
// Display results
由于testfixture是最顶层模 块,不会被其它模块实例化。 因此不需要有端口。
endmodule
Test Fixture — 如何说明实例
module testfixture; // Data type declaration 多路器实例化语句
// Instantiate modules MUX2_1 mux (out, a, b, sel); // Apply stimulus
Time
0 5 10 15
Values a b sel 0 1 0 0 0 0 0 1 1 1 1 1
DUT 被测器件 (device under test)
module MUX2_1 (out, a, b, sel); 注释行 // Port declarations output out; input a, b, sel; 多路器由关键 wire out, a, b, sel; 词module和 wire sel_, a1, b1; endmodule 开始及结束。 // The netlist not (sel_, sel); and (a1, a, sel_); and (b1, b, sel); or (out, a1, b1); 已定义的 Verilog基 endmodule 本单元的 实例
•
a, b, sel是输入端口,out是输出 端口。所有信号通过这些端口从模 块输入/输出。
另一个模块可以通过模块名及端口 说明使用多路器。实例化多路器时 不需要知道其实现细节。这正是自 上而下设计方法的一个重要特点。 模块的实现可以是行为级也可以是 门级,但并不影响高层次模块对它 的使用。