系统Verilog中是否有一个函数可以返回数组的最重要位数
IAM试图在数组中获取有效钻头的数量 例如: 如果我有一个包含这些位序列的数组: 0000_0101 阵列的尺寸为8,我只想获得最重要的位数的方法,在这种情况下为3
iam trying to get the number of the effective bits in an array
for example:
if i have an array that contains these sequence of bits:
0000_0101
the dimension of the array is 8 , i just want way to get the number of the most significant bits which are 3 in this case
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个如帖子中所述的函数:
并产生结果:
Here is a function that behaves as described in the post:
And produces the results:
好吧,您正在寻找足以将其索引到8B向量的位。
假设您的变量(REG,逻辑)被命名为ARR []
您可以使用: $ clog2($ bit(arr))
这里$ bits(arr)为8。
然后clog2(8)将是3。这也需要2个宽度的非功率。
编辑:从clogb2()更改为clog2()。
Well, you're looking for number of bits enough to index into an 8b vector.
Assuming your variable (reg, logic) is named arr[]
You could use: $clog2($bits(arr))
Here $bits(arr) would be 8.
Then clog2(8) will be 3. This takes care of non-power of 2 widths also.
Edit: changed from clogb2() to clog2().