Verilog 中的随机数数组
我想测试 verilog 模块的所有可能的输入组合。我已经能够通过使用嵌套 for 循环构建数组来生成这些输入。但是我想以随机顺序遍历数组。这是如何做到的,或者有没有办法生成一个已经按随机顺序排列的所有可能输入的数组?
I want to test all possible combinations of inputs to a verilog module. I have been able to do generate these inputs by building an array with a nested for loop. However I want to go through the array in random order. How can this be done, or is there a way to generate an array of all possible inputs that is already in random order?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想重新排列测试用例列表,例如洗牌,可以使用一种名为 Fisher-Yates 洗牌 来做到这一点。或者,如果您使用 SystemVerilog,toolic 会指出数组有一个内置的
shuffle
方法。If you want to rearrange a list of test cases like shuffling a deck of cards, there's an algorithm called the Fisher–Yates shuffle to do that. Or if you're using SystemVerilog, toolic pointed out that there's a built-in
shuffle
method for arrays.