Counter inside assertion

I am thinking of a way to count the number of times grant is high using SVA. By doing that I want the assertion to throw an error if the count is more than 4. Is there any way of doing this in SVA?

The below code doesn’t work because ‘count = count + 1’ is not allowed. But I am looking for a property that works similarly to the below property.

  property p1;
    bit [2:0] count;
    @(posedge(clk)) $rose(grant) |-> (1, count = count + 1);
  endproperty : p1

In reply to Krishna9:

Hi,

Please try the following property to meet your requirement. I don’t think, you need to make use of a local variable to count the no. of clock cycles for which, the grant is high. The below property will check the status of grant for 1 to 4 consecutive cycles if there is a rise is grant. if the grant is not low after 4 cycles, the property fails.


property ppt;
	@(posedge clk) $rose(gnt) |-> gnt [*1:4] ##1 !gnt; 
endproperty

Putta Satish