Multiple program blocks

Let’s say this is my code:

program mytest1();
initial begin
  DUT.A = 1;
end
endprogram

program mytest2();
initial begin
  #50 DUT.B = 1;
end
endprogram

module DUT();
  reg A, B;
...
endmodule

I read all the files to compile and run. How do I tell the simulator which ‘program’ (mytest1 or mytest2) to run?

In reply to gopal_susarla:

If you were to compile this code, this results in 3 top-level design units. There are tool specific options to select the top-level units you want in your simulation. Please check the user manual of your tool and be aware this forum is not for tool specific information.

What you have written is an unusual way of structuring your testbench. A DUT needs to have inputs and outputs to be a useful device. Normally there would be a higher level testbench that instantiates your DUT providing stimulus through ports and interfaces. You test could be in that top-level, or it could be another instance instantiated by the top-level with connections between the two instances.

Also, I do not recommend the use of program blocks.

In reply to dave_59:

Thank you Dave. I simplified the question. The ‘DUT’ is this case is the top-level. It contains interfaces, BFMs and the the actual ‘dut’. The program blocks I have only contain a single initial begin-end block calling out tasks sequentially. Each program block is a testcase and is legacy code I inherited.

But thank you for responding. I’ve reviewed your blog post on program blocks.

regards,
-Gopal