2017-02-17 57 views
0

我有多个函数可以产生1位变量/定义/枚举的连接数组。每次连接发生时,我都想确保最终的大小是32位宽。如果它小于或大于32位,则标记一个错误。 我试过$ bits,$ size,但它们似乎想要一个变量,并提供可变宽度而不是连接的宽度。这打破了目的。系统verilog中级联阵列的位宽

任何帮助表示赞赏。

谢谢!

这是我在想什么: - 例如。

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* 
+0

如果这些功能由宏反正产生,你为什么不只要把'if($ bits({a,b,c})!= 32)$ error()'放入函数中? –

回答

0

SystemVerilog中没有任何含有大量参数的参数可让您将其定义为获取可变数量的参数。 (你可以有默认参数,但没有从函数内部知道如果使用了默认)

为什么不

function f1(bunch of inputs generated by macros(variable no. of input) a,b,c) 
    size_check($bits({a,b,c})); 
    var_out = {a,b,c}; 
endfunction 
function void size (int in) **// what should be in this function ?** 
if(in !=32) - $error("msg"); *// this is what i want to achieve* 
endfunction 
+0

感谢它的工作。 – Szt13