3

I'm trying to learn few things about testbenches with SystemVerilog. However I couldn't seem to find a way to monitor DUT signal inside program block

Consider following example. Signal 'dummy' is output of DUT and input to program block. Now I need to monitor 'dummy' in program block to raise a flag 'test' when 'dummy' has particular value.

In general module-driven testbench, I would simply write always @(dummy), but always blocks are not allowed under program. How would I achieve this?

3
  • I remember that someone said the program block has some issue and do not really suggest to use it. Commented Aug 1, 2012 at 23:21
  • @EnchanterThunderbird can you state some references about this issues? Commented Sep 1, 2012 at 7:53
  • See go.mentor.com/programblocks for recommendations on avoiding program blocks. Commented Oct 10, 2013 at 3:01

1 Answer 1

6

You can write sequential code like this:

program test(input dummy);
  initial begin
    ...
    wait(dummy == <something>);
    ...
    @(posedge dummy);
    ...    
  end
endprogram

Or you could emulate an always construct using a forever loop.

program test(input dummy);
  initial begin
    forever begin
      @(posedge dummy);
      if (dummy == <something>) ...
    end 
  end
endprogram
Sign up to request clarification or add additional context in comments.

1 Comment

awesome I can add wait under fork-join so TB can work properly through general execution as well as I can check the signal required

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.