Skip to content

Instantly share code, notes, and snippets.

@Kocha
Created March 5, 2012 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kocha/1975770 to your computer and use it in GitHub Desktop.
Save Kocha/1975770 to your computer and use it in GitHub Desktop.
sub module call task.
module tb;
reg r_a=0;
reg[1:0] r_b=0;
sub_m sub_m_inst(.in(r_a));
initial begin
sub_m_inst.task1;
sub_m_inst.task2(r_a);
sub_m_inst.task3(r_a, r_b); $display("------ Call Task3 output = %d", r_b);
sub_m_inst.task4(r_a, r_b); $display("------ Call Task4 output = %d", r_b);
end
endmodule
module sub_m(input reg in);
task task1;
$display("--- Call Task1 ---");
endtask
task task2(input a);
$display("--- Call Task2 input = %d ---", a);
endtask
task task3(input a, output b);
begin
$display("--- Call Task3 input = %d ---", a);
b = 1;
end
endtask
task task4;
input a; output reg[1:0] b;
begin
$display("--- Call Task4 input = %d ---", a);
b = 2;
end
endmodule
RTL=tb.v
run: work compile sim
work:
> vlib work
compile:
> vlog ${RTL}
sim:
> vsim -c -L work tb -do "run -all; quit"
clean:
> rm -rf work transcript vsim.wlf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment