Question

I am using SystemVerilog. My code is:

function write_pixel_data(datastr ds);
 /* some stuff here... but no return */
endfunction

then i am calling my function like:

write_pixel_data(someval);

And i get the vcs warning:

Warning-[SV-NFIVC] Non-void function used in void context.

But i am not returning anything, i know i can cast the function call to void to get rid of the warning. But why it gives this warning??!!

Thanks.

Was it helpful?

Solution

If you haven't declared the function as void and you call it without assigning the return value to anything, you'll see this error. Simple fix:

function void write_pixel_data(datastr ds);
 /* some stuff here... but no return */
endfunction

Careful though, you can't do anything that 'takes time' in a function. You'll need a task for that.

OTHER TIPS

A function declared with an implicit type returns logic. You must explicitly declare the return type to be void if that is your intention.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top