简体   繁体   English

verilog测试台比较原因错误

[英]verilog testbench compare cause errors

I have the most peculiar problem that none of the guys in my office came across or know how to handle, maybe you guys will find where's the catch. 我有一个最特殊的问题,就是我办公室里的所有人都没有遇到过或不知道如何处理,也许你们会发现问题所在。

In my verilog testbench, I have the following compare code: 在我的verilog测试平台中,我具有以下比较代码:

if (refFifo[7:0] != DUT.fifo[7:0] && rnd == 1) begin
  $display("Error! ref Fifo %h not equal DUT fifo %h after 1 byte", refFifo[7:0], DUT.fifo[7:0]);
  $stop;
end
else if (refFifo[15:0] != DUT.fifo[15:0] && rnd == 2) begin
  $display("Error! ref Fifo %h not equal DUT fifo %h after 2 byte", refFifo[15:0], DUT.fifo[15:0]);
  $stop;
end

... (until 5 bytes) ...(直到5个字节)
else
$display("Success!");

Now, the problem is that the comparison of 2 is always failing, while the rest of the comparisons pass smoothly (and this screws up with my runs): 现在的问题是,2的比较总是失败,而其余的比较顺利通过(这与我的实验相提并论):
'>Error: ref Fifo 090c not equal DUT fifo 090c after 2 byte' '>错误:2个字节后ref Fifo 090c不等于DUT fifo 090c'
I tried changing the position of the compare in the process, printing the values before the compare (in case they changed somehow during the compare), adding parenthesis, changing the compare range to [7:0] and building a new environment but nothing helped or gave some indication of what goes wrong with the compare of 2 bytes. 我尝试在过程中更改比较的位置,在比较之前打印值(以防在比较期间以某种方式更改它们的值),添加括号,将比较范围更改为[7:0]并建立一个新环境,但没有任何帮助或指出2字节比较出了什么问题。
Did anyone ever came across such a problem? 有没有人遇到过这样的问题? does anyone have an idea of how to solve it? 有谁知道如何解决这个问题?
I run with ModelSim 10.1d_1 with no optimization, in case it has something to do with my enigma. 我使用ModelSim 10.1d_1进行了优化,以防与我的谜团有关。
update also tried it on ModelSim 10.0d_1, but with no help. 更新也对ModelSim 10.0d_1进行了尝试,但没有帮助。

I can't see anything wrong with your code. 我看不到您的代码有什么问题。 The result of the && must be 1'b1 for the $display to be executed. &&的结果必须为1'b1 ,才能执行$display This means both comparisons must also have a result of 1'b1 , so there aren't any unknowns in resFifo , DUT.fifo , or rnd . 这意味着两个比较的结果也必须为1'b1 ,因此resFifoDUT.fifornd中没有任何未知数。 You should change your comparison operators to !== and === to confirm this. 您应该将比较运算符更改为!=====进行确认。 ModelSim is also not printing any X's with the %h modifier. ModelSim也不会使用%h修饰符打印任何X。 I'd change this to %b just to be sure. 为了确定,我将其更改为%b

Unless I've missed something obvious, I'd remove the cross-module reference ( DUT.fifo ) and try again. 除非我错过了明显的事情,否则我将删除跨模块引用( DUT.fifo ),然后重试。 Get a fifo port out of the DUT, and do the comparison against the port value. 从DUT中取出一个fifo端口,并与端口值进行比较。 This might help to track down the issue. 这可能有助于找出问题所在。

Your code looks fine to me. 您的代码对我来说很好。 You may be hitting a simulator bug; 您可能遇到了模拟器错误; if you can reproduce this in a test case you should submit it to Mentor support. 如果您可以在测试用例中重现此内容,则应将其提交给Mentor支持。

Here are are some other things to try: 这里还有其他一些尝试:

  • Create a 5-byte local variable for the DUT value before the if statements, and use that in the checks. if语句之前为DUT值创建一个5字节的局部变量,并在检查中使用它。
  • Change the order of the checks so that you look at rnd first. 更改检查顺序,以便您首先查看rnd This way the expression will short-circuit and avoid comparing the DUT values for cases which you don't need to check for. 这样,表达式将短路,并避免在不需要检查的情况下比较DUT值。
  • Refactor the check to use a case statement on rnd . 重构检查以在rnd上使用case语句。 Including a default case may help debug any problem where rnd != 2 . 包括默认情况可能有助于调试rnd != 2任何问题。
  • Delete the line and re-type it manually. 删除该行,然后手动重新键入。 Or copy/paste another line and change the numbers. 或复制/粘贴另一行并更改数字。 I have seen weird cases where a hidden/bad/unicode character will compile and run but cause something to misbehave. 我见过一些奇怪的情况,其中隐藏的/错误的/ unicode字符会编译并运行,但会导致某些行为异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM