1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| module tb();
int inputa; int inputb; int res;
function int sum1(int a, int b); return a+b; endfunction
function int sum2(int a, int b); sum2=a+b; endfunction
function sum3(int a, int b); sum3=a+b; endfunction
function int sum4; input int a, b; sum4=a+b; endfunction
function int sum5(input int a, b, output int res); res = a+b+1; return a + b; endfunction
initial begin inputa=3; inputb=3; $display("sum1:%0d", sum1(inputa, inputb)); $display("sum2:%0d", sum2(inputa, inputb)); $display("sum3:%0d", sum3(inputa, inputb)); $display("sum4:%0d", sum4(inputa, inputb));
$display("sum5:%0d", sum5(inputa, inputb, res)); $display("res:%0d", res);
$display("inputa:%0d", inputa); $display("inputb:%0d", inputb); end endmodule
|