Verilog中的urandom_range(),urandom(),random() [英] urandom_range(), urandom(), random() in verilog

查看:1739
本文介绍了Verilog中的urandom_range(),urandom(),random()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这三个功能感到困惑,我想知道一些解释.如果设置范围,如何使范围互斥或互斥?如果我未指定范围,范围是包含的还是排他的?

I am confused between these three functions and I was wondering for some explanation. If I set the range how do I make the range exclusive or inclusive? Are the ranges inclusive or exclusive if I don't specify the range?

推荐答案

除了@ dave_59的答案外,还有其他重要区别:

In addition to the answer from @dave_59, there are other important differences:

i)$random返回一个带符号的32位整数; $urandom$urandom_range返回无符号的32位整数.

i) $random returns a signed 32-bit integer; $urandom and $urandom_range return unsigned 32-bit integers.

ii)$random的随机数生成器在 IEEE中指定1800-2012标准.使用相同的种子,您将在任何SystemVerilog模拟器中获得完全相同的随机数序列. $urandom$urandom_range并非如此,其中随机数生成器的设计取决于EDA供应商.

ii) The random number generator for $random is specified in IEEE Std 1800-2012. With the same seed you will get exactly the same sequence of random numbers in any SystemVerilog simulator. That is not the case for $urandom and $urandom_range, where the design of the random number generator is up to the EDA vendor.

iii)每个线程都有自己的$urandom$urandom_range随机数生成器,而在所有线程之间只有一个$random随机数生成器(即,整个仿真只有一个).这一点非常重要,因为每个线程具有单独的随机数生成器可以帮助您仿真改善称为随机稳定性的属性.假设您正在使用随机数生成器来生成随机刺激.假设您发现了一个错误并进行了修复.这可以轻松更改执行线程(即initialalways块)的顺序.如果该更改改变了随机数的生成顺序,那么您将永远不会知道该错误是否已经消失,因为您已将其修复或刺激措施已更改.如果每个线程都有一个随机数生成器,那么您的测试台就不会那么容易受到这种影响的影响-您可以更加确定该错误已消失,因为您已对其进行了修复.该属性称为随机稳定性.

iii) Each thread has its own random number generator for $urandom and $urandom_range, whereas there is only one random number generator for $random shared between all threads (ie only one for the entire simulation). This is really important, because having separate random number generators for each thread helps you simulation improve a property called random stability. Suppose you are using a random number generator to generate random stimulus. Suppose you find a bug and fix it. This could easily change the order in which threads (ie initial and always blocks) are executed. If that change changed the order in which random numbers were generated then you would never know whether the bug had gone away because you'd fixed it or because the stimulus has changed. If you have a random number generator for each thread then your testbench is far less vulnerable to such an effect - you can be far more sure that the bug has disappeared because you fixed it. That property is called random stability.

因此,正如@ dave_59所说,您应该只使用$urandom$urandom_range.

So, As @dave_59 says, you should only be using $urandom and $urandom_range.

这篇关于Verilog中的urandom_range(),urandom(),random()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆