Jump to content
tudor.timi

Using $past in procedural code

Recommended Posts

Hi everyone,

 

I'm not sure if this is the right place to post this. I have question regarding the usage of $past(...) and the other members of that family inside procedural code. The SV 2012 standard says the following: "The use of these functions is not limited to assertion features; they may be used as expressions in procedural code as well."

 

I've tried using a call to $past(...) with an explicit clocking event inside a class task. One of our simulators complained that this is only allowed in assertions and procedural blocks. The other one we use allows it. The standard is rather vague here. What constitutes procedural code? Hopefully someone from the SV Committee hangs out in this forum.

 

Here's the code I'm trying.

module top;
   bit clk;
   bit some_signal;

   always #1 clk = ~clk;
   

class some_class;
   task some_task();
      bit foo;
       foo = $past(some_signal,,,@(negedge clk));
       $display("some_signal was %b at the last negedge", foo);
    endtask
 endclass
   
   initial begin
      automatic some_class obj = new();
      
      @(posedge clk);
      some_signal <= 1;
      @(negedge clk);
      some_signal <= 0;
      @(posedge clk);
           
      obj.some_task();
      $finish();
   end
endmodule

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...