【发布时间】:2018-12-03 01:43:46
【问题描述】:
对于i=0 和j=0,此代码使我的a,b,cin and s 信号变为xxxxxxxx。
对于i=0 和j=1,我的a,b,cin and s 都是00000000。对于i=0 j=0 cin =0,这应该是我的加法器的结果。怎么了?我确定我的加法器模块是正确的。
http://prntscr.com/lpngih(……等等)
大多数问题首先出现在 for 循环中,并在一些值未打印时开始,然后在我在每个循环中添加 begin end 后,我看到了带有上述问题的完整循环结果^^^ ^^.仍然不知道它是如何工作的,但它确实做到了
module test_cla4_n;
reg [7:0] a,b;
reg cin;
wire [7:0] s;
wire cout;
integer i;
integer j;
integer cv;
cla4_n#(.n(8)) UUT
(.a(a), .b(b),
.cin(cin),
.s(s), .cout(cout));
initial
begin
for(cv=0;cv<=1;cv=cv+1)
begin
for (i=0;i<6;i=i+1)
begin
for (j=0;j<6;j=j+1)
begin
#100 a = j; b = i; cin = cv;
end
end
end
end
initial
begin
$monitor($time, ,"a=%9b, b=%9b, cin=%b, sum=%9b", a, b, cin, s);
end
endmodule
【问题讨论】:
-
你先有一个延迟,然后设置值。测试台通常更喜欢反过来:
a = j; b = i; cin = cv; #100; -
马上回来查看
-
谢谢!!不会意识到即使我在那里再坐 10 个小时也可能更多。 prntscr.com/lpni7f.
-
@Oldfart btw 对
for循环上的begin end的任何评论。另请阅读我在帖子中的最后一段
标签: verilog