0
\$\begingroup\$

I want to do something like this using concurrent assertions (I want to check that when from_clk changes to_clk must change and when to_clk changes from_clk must change):

($changed(from_clk) |-> $changed(to_clk)) &&
  ($changed(to_clk) |-> $changed(from_clk))

I have written the below assertions but it is not giving correct result in simulation.

property check_clock;
@(from_clk or to_clk) disable iff(reset || ~enable)
($changed(from_clk) |-> $changed(to_clk)) &&
 ($changed(to_clk) |-> $changed(from_clk));
endproperty

ASSERT_CHECK_CLOCK : assert property(check_clock)
                     else $error();

Please suggest how to achieve this.

\$\endgroup\$
1

1 Answer 1

1
\$\begingroup\$

I am rusty on writing assertions, but, maybe this will help... Do you expect them to be true on the same clock tick? If not, use ##[<value>:<value>] to express a range of clock cycles for it to be true. e.g. from_clk |-> ##[1:2] to_clk

And, without knowing more about the clocks, not sure if the && is going to work as seemingly one happened in the past(?) Might be more meaningful to use || assuming you only look for either condition for any given clock crossing(?) Maybe, two separate assertions... actually, one property to which you pass variables, and form two separate assertions (from-to, and to-from), might be better.

Also, a good simulator (e.g. Questa) will have assertion tracing you can use to visually debug the assertion by stepping through. Powerful and useful, as assertions can get complicated and, in turn, be painful to get right.

There are more details in the IEEE-1800 standard (or www.accellera.org if you don't have access to IEEE). But, a more direct and quicker example and explanation can be found here: https://www.doulos.com/knowhow/sysverilog/tutorial/assertions/

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.