1 input和output和funcion是一致的;另task可以加延时语句
2 task也可以用return,用于退出task使用;
###########################################################################################
案例1
module tb;
task mytask(input [7:0] x,
input [7:0] y,
output [15:0] z);
$display(“x = %0d”, x);
$display(“y = %0d”, y);
$display(“z = %0d”, z);
z = x + y - 1;
endtask
initial begin
byte unsigned a = 3;
byte unsigned b = 3;
byte unsigned c = 3;
mytask(a,b,c);
$display(“c = %0d”, c);
end
endmodule
运行结果:
x = 3
y = 3
z = x
c = 5
################################################################################################
案例 2 加延时语句
`timescale 1ns/1ps
module tb;
task mytask(input [7:0] x,
input [7:0] y,
output [15:0] z);
$display(“x = %0d”