System Verilog Functions. Verilog functions here.

In System Verilog, functions have added functionality. It now supports “void” function calls and also allow formal arguments. Lets discuss these enhanced features next.

VOID functions. What is a void function? The system verilog functions are declared void when no return value is required. In our example we are calling function “testprint” to print a value passed as input integer.

~\Documents\fullchip\python\mysite\webpages\templates\webpages\test.v.html
function void testprint(int i);

***

Non-void system verilog functions. Example code below:

function [3:0] reverse_order (input[3:0] a, output[3:0] b );

integer i;

// No need of begin/end in SystemVerilog

for (i=0; i<4; i=i+1)

b = a[3-i];

endfunction

***

LTE - 4G Wireless Technology

Digital fundamentals.

Interview Questions.

So from example above we noticed that SystemVerilog doesn’t mandate begin and end for coding logic.

How are Function return used in System Verilog. For type (or non-void) functions, a value can be returned by adding a final line in code with “return abcd”. Where abcd is always associated with return and its the expression required to return a value with function call. Example below:

 

function [4:0] simple_adder_with_carry (input [3:0] x,y);

return x + y;

endfunction

***

So SV compilers by default interprets all statements within function and endfunction as sequential.

Tutorials @fullchipdesign.com

Verilog Tutorial.

LTE Tutorial.

Memory Tutorial.

Hope you liked! this page. Don't forgot to access relevant previous and next sections with links below.