16.14.6 clarifies that The triggered status of the sequence is set in the
Observed region and persists through the remainder of the time step. In
addition to using this method in assertion statements, it may be used in
wait* statements (see 9.4.3) or Boolean expressions outside a sequence
context. *In addition, the LRM shows an example in program "check" with if
(e1.triggered).
*However, that are nuances as to how this .triggered method can and cannot
be used*, even though it compiles and elaborates correctly. To demonstrate,
let me use this simple example, with the key implication of incorrect usage
identified in red and with the "<-----" pointer.
module trig; logic a=0, b=0, c=0, d, e; bit clk; sequence a_then_b;
@(posedge clk) a ##[1:5] b; endsequence // req_ack initial forever #50 clk =
!clk; *// d is always set to 0 at @ (posedge clk) always @(posedge clk) d =
a_then_b.triggered; // <-----BAD USAGE* // e is always X in simulation
always @(posedge clk) if(a_then_b.triggered) e=1; <----*BAD USAGE* // trig
is set to 1 on every endpoint of a_then_b wire trig = a_then_b.triggered; //
Useful USAGE ?? always @ (posedge clk) begin a0 : assert (std::randomize(a,
b)); end always begin wait(a_then_b.triggered) c=!c; @ (posedge clk); end
endmodule : trig
In the above example, *// d is always set to 0 at @ (posedge clk) always
@(posedge clk) d = a_then_b.triggered; // <-----* // e is always X in
simulation always @(posedge clk) if(a_then_b.triggered) e=1; <----
We get those results because the sequence is clocked by the same (posedge
clk) but its triggered property doesn't come true until the Observed region
of the scheduler. But the @(posedge clk) block executes before that, in the
Active region.
Other working solutions are:
event trig_ev;
always @(posedge clk) @(a_then_b.triggered) -> trig_ev;
// or
always @(a_then_b) ...
What I am suggesting is that we write a clarification on the usage if the
.triggered method. I can write such a mantis; however, before doing so, I
would like to know if there is an interest in doing this, and any comments
you might want to make about usage.
Ben Cohen
// Below is quote from lrm
16.14.6 Sequence methods
The triggered status of the sequence is set in the Observed region and
persists through the remainder of the time step. In addition to using this
method in assertion statements, it may be used in wait statements (see
9.4.3) or Boolean expressions outside a sequence context. It shall be
considered an error to invoke this method outside a sequence context on
sequences that treat their formal arguments as local variables. A sequence
treats its formal argument as a local variable if the formal argument is
used as an lvalue in operator_assignment or inc_or_dec_expression in
sequence_match_item. There shall be no circular dependencies between
sequences induced by the use of triggered.
…
program check;
initial begin
wait (e1.triggered || e2.triggered);
if (e1.triggered)
$display("e1 passed");
if (e2.triggered)
$display("e2 passed");
L2: ...
end
endprogram
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Sun May 8 13:32:35 2011
This archive was generated by hypermail 2.1.8 : Sun May 08 2011 - 13:32:41 PDT