2

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.

4

2 回答 2

4

如果您没有将函数声明为void并且在没有将返回值分配给任何内容的情况下调用它,您将看到此错误。简单修复:

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

不过要小心,你不能在函数中做任何“需要时间”的事情。你需要一个task

于 2012-03-13T17:20:38.127 回答
3

使用隐式类型声明的函数返回logic. 如果这是您的意图,您必须明确声明返回类型为 void。

于 2012-03-13T17:19:47.103 回答