如何在 systemverilog 中生成随机单精度浮点数?
我正在尝试使用通用验证方法验证浮点乘法器的行为,但遇到问题。 问题是当我想生成单精度浮点数时。基本上,这不可能直接实现,我决定生成两个随机 32 位数字,如下所示:
rand logic [31:0] A;
rand logic [31:0] B;
现在的问题是我们可能会产生许多数字,这些数字在 IEEE754 表示法中基本上不是有效数字。 我的问题是如何对这些数字施加正确的约束以及这些约束是什么?
I'm trying to verify behavior of a floating point multiplier using Universal Verification Methodology and I have an issue.
The problem is that when I want to generate single precision floating point numbers. Basically, This not possible directly and I decided to generate two random 32 bit numbers like following:
rand logic [31:0] A;
rand logic [31:0] B;
The issue is now we may produce many numbers which basically are not valid numbers in IEEE754 notation.
My question is that how can I put correct constraints for these numbers and what are those constraints?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Systemverilog 允许按照整数/逻辑/位向量值(不是真正的浮点数)进行随机化。有理有据!它会减慢处理器/服务器的速度来生成小数值。您可能想要做的是限制随机 int 变量并将其乘以您的用例的实际类型数。
Systemverilog allows randomization in terms of integer/logic/bit vector values (NOT real floating pt). Rationale being! it would slowdown processor/server speeds to generate fractional values. What you may want to do is constrain the random int variable and multiply it to the real type number for your use case.