In reply to sonofthesand:
In general, it is best to write smaller assertions rather than large ones.
Below is how I converted your long assertion to multiple smaller ones. I also used the default clocking. In SystemVerilog, it is recommended to use the “let” instead of `define
You can also use the until, s_until. From my SVA Handbook 4th Edition, An until property of the non-overlapping form (i.e., until, s_until) evaluates to true if property_expr1 evaluates to true at every clock tick beginning with the starting clock tick of the evaluation attempt and continuing until at least one tick before a clock tick where property_expr2 (called the terminating property) evaluates to true. Theuntil, s_until operators have an implicit repetition until the terminating condition (i.e., property_expr2) occurs. Specifically, with a strong until (e.g.,s_until), if the simulation completes but the terminating condition is pending, the assertion fails, unlike the weak until where the assertion is evaluated as vacuously true. s_
I ran the model below on a popular tool, and I had no issue with compilation or simulation speed. We don’t address specific tools at this forum.
The free EDA Playground tools have limitations, as they are targeted for small models. However, you can modify the code and experiment.
// Your solution is OK, but is harder to read. However, I still prefer smaller assertions instead of one large one.
sequence seq1(wu_state, M); // Your OK solution
int cnt;
(state == 0,cnt=0) [*1:$] ##1
(state == 1) [*1:$] ##1
(state == 2,cnt++) [*1:$] ##0
(M==cnt) ##1
(state == 3) [*1:$] ##1
(state == 4) [*5] ##1
(state == 5) ;
endsequence
My preferred solution,with smaller assertions, more easily identifies which transition failed. It is also easier to read. For example, I read this in English for my solution with smaller assertions:
@ check_on, I stay in state0 until state1.
If in state1, I stay on state1 until state2
If in state2, I stay on state2 for M cycles and then go to state3.
…
Your solution makes a very long sentence, and the use of the variable makes it even more difficult to explain in plain English. It is more subjected to errors because of the complexity. KISS ((acronym)
I have a problem with your solution though.
The state may change before check_on is high.
This causes miss trigger of assert_seq1to2 and the ones below
In reply to ben@SystemVerilog.us:
I have a problem with your solution though.
The state may change before check_on is high.
This causes miss trigger of assert_seq1to2 and the ones below
Since I don’t have a full set of requirements, I initially thought that *check_on
is more like a go instead of a mode. Ifcheck_on is a mode that remains hi till state5 (i.e., is an envelope), then you can still use small assertions:
As I said before, all the experts on SVA (I have talked to many, including those on the IEEE SVA committee since I am also one of them) do recommend smaller assertions.
KISS !!!
Ben Cohen http://www.systemverilog.us/ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr