6 testing loops verilog system-verilog
我必须为此原理图创建 Verilog 代码和测试平台。

我这里有它的设计。
module prob1(input wire a,b,c,d, output wire out);
assign out = (a||d)&&(!d&&b&&c);
endmodule
Run Code Online (Sandbox Code Playgroud)
这是到目前为止我所拥有的测试平台。
module prob1_tb();
reg a,b,c,d;
wire out;
prob1 prob1_test(a,b,c,d, out);
initial begin
for(int i=0; i=16; i=i+1)
<loop code here>
end
end
endmodule
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是如何将该数字转换为原理图中使用的 4 个输入?或者有更好的方法来做到这一点吗?
这是使用连接运算符的简单方法:
module prob1(input wire a,b,c,d, output wire out);
assign out = (a||d)&&(!d&&b&&c);
endmodule
module prob1_tb();
reg a,b,c,d;
wire out;
prob1 prob1_test(a,b,c,d, out);
initial begin
$monitor(a,b,c,d,out);
for (int i=0; i<16; i=i+1) begin
{a,b,c,d} = i;
#1;
end
end
endmodule
Run Code Online (Sandbox Code Playgroud)
输出:
00000
00010
00100
00110
01000
01010
01100
01110
10000
10010
10100
10110
11000
11010
11101
11110
Run Code Online (Sandbox Code Playgroud)
是的,有更好的方法来验证逻辑。首先要做的是引入随机值(参考$urandomIEEE Std 1800-2009中的函数)。当然,您还需要使用模型对输出进行检查,这在您的情况下是微不足道的。
根据您有多少时间(和培训),您可以采用标准流程,例如通用验证方法 (UVM)。人们围绕验证建立职业生涯。
| 归档时间: |
|
| 查看次数: |
31064 次 |
| 最近记录: |