0

I have multiple functions that generate concatenated array of 1 bit variables/defines/enums. Everytime a concatenation happens i want to make sure the final size is 32 bits wide. And flag an error if it is less than or greater than 32 bits. i have tried $bits, $size, but they seem to be wanting a variable and provide the variable width not the width of concatenation. which defeats the purpose.

Any help is appreciated.

Thanks!

here is what i was thinking :- For example.

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
  • If these functions are generated by macros anyways, why don't you just put if ($bits({a,b,c}) != 32) $error() into the function? Commented Feb 17, 2017 at 1:32

1 Answer 1

0

Nothing in SystemVerilog that takes a number of arguments lets you define it to take a variable number of arguments. (you can have default arguments, but there is no way of knowing from inside the function if the default was used)

Why not

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.