我有多个函数生成1位变量/定义/枚举的连接数组 . 每次发生连接时,我都要确保最终大小为32位宽 . 如果小于或大于32位,则标记错误 . 我已经尝试了$ bits,$ size,但他们似乎想要一个变量并提供变量宽度而不是连接的宽度 . 这打败了目的 .
任何帮助表示赞赏 .
谢谢!
这就是我的想法: - 例如 .
logic [31:0] var_out;
function f1(bunch of inputs generated by macros(variable no. of input) a,b,c)
size({a,b,c});
var_out = {a,b,c};
endfunction
function f2(bunch of inputs generated by macros(variable no. of input) e,f,g,h,i)
size({e,f,g,h,i});
var_out = {e,f,g,h,i};
endfunction
function size (in) **// what should be in this function ?**
if(length(in)!=32) - $error("msg"); *// this is what i want to achieve*
1 回答
SystemVerilog中没有任何内容可以使用多个参数来定义它以获取可变数量的参数 . (你可以有默认参数,但是如果使用默认参数,则无法从函数内部知道)
为什么不