Thursday, November 29, 2018

DIFFERENCE BETWEEN ‘@EVENT’ AND EVENT.TRIGGERED IN SYSTEMVERILOG

@EVENT:
- It is EDGE sensitive event. Event is sample by edge. @event should execute before event get trigger or it cause race condition.
- Consider scenario if ‘@event’ and ‘->event’ trigger at same time. @event looking for edge detection, until it will not detect next edge detection @event block the statements written below it.






USER WANTS CODE:

module edge_event;
event e; // event declaration
initial
begin
  repeat(1)
  begin
    #10; // SAME TIME
    ->e; // activate event or trigger event
  end
end

initial
begin
  repeat(2)
  begin
    #10; // SAME TIME
    @ (e) // check event trigger at CURRENT TIME slot
    $display("\n@%0t event is triggere\n",$realtime);
  end
end

initial
begin
  #50;
  $display("\nRACE Condition, statement is BLOCKED\n");
  $finish;
end
endmodule


To run simulation click on below link:

EVENT.TRIGGERED:
- It is level sensitive measurement. Event.triggered statement check LEVEL difference at CURRENT TIME slot.
- Consider scenario if ‘wait(event.triggered)’ and ‘->event’ trigger at same time. wait(event.triggered) looking for level difference in CURRENT TIME slot and execute the code written below it.



USER WANTS CODE:

module level_event;
event e; // event declaration
initial
begin
  repeat(1)
  begin
    #10; // SAME TIME
    ->e; // activate event or trigger event
  end
end

initial
begin
  repeat(2)
  begin
    #10; // SAME TIME
    wait(e.triggered) // check event trigger at CURRENT TIME slot
    $display("\n@%0t event is triggere\n",$realtime);
  end
end

initial
#50 $finish;

endmodule

To run simulation click on below link:
Link: https://www.edaplayground.com/x/3VXd

DIFFERENCE BETWEEN WAIT AND IF CONDITION
Wait: wait keyword use to blocking until condition is not satisfied.
Else keyword can not use with wait statement.
If: if keyword use to check the condition without any blocking.
Else keyword can use with if condition.

No comments:

Post a Comment