SVA : last_match

In reply to run2prem:

you suggest to use SV rather than SVA for this particular check.

This is not necessarily true. What I am saying is:

  • FOr very complex assertions an approach like the one I describe in my paper is often simpler; it is available at https://verificationacademy.com/news/verification-horizons-march-2018-issue
  • That pure SV approach basically computes the antecedent and then fires automatic tasks for the consequent as threads. It overcomes some of the issues with local variables and provides more flexibility since you use the full power of SV. Typical code would look like:

always @ (posedge clk)  begin
// local variable declations
// sequential statements (e.g., loops, @ (posedge clk), return, etc
if(vacuous_condition) return;
fork
task_emulating_the_consequent;
join_none

  • Understanding the equivalent mechanics and limitations of SVA can help create a better SVA model.

Your code looks like it has the correct approach, but I have an issue with its correctness.
You are looking for the last write cycle. Assuming that that you load the register with 2, 3 or 4 consecutive writes, and WrAddr is an active ONE, then the last write would occur when
$fell(WrAddr_pre)&& WrAddr rather than your WrAddr != WrAddr_pre.


 property data_integrity_check ();
   logic [7:0]Addr;
   logic [7:0]  Data;
    disable iff (~RG_ResetN)
    @(posedge WrClk)
    ($fell(WrAddr_pre)&&  WrAddr ), Addr = WrAddr, Data = WrData) |-> @(posedge RdClk) first_match (##[0:$] (RdEn && (RdAddr == Addr))) ##1 (RdData == Data);
  endproperty:data_integrity_check

also
first_match (##[0:$] (RdEn && (RdAddr == Addr))) ##1 (RdData == Data); is equivalent to 
(RdEn && RdAddr == Addr)[->1] ##1 (RdData == Data);
 

Test your assertions with a simple testbench. I use the following as a test template, then fill-in the details. That template is stored in an Autotext and Text Autocompletion in any application using the application available at no cost at https://www.phraseexpress.com/


import uvm_pkg::*; `include "uvm_macros.svh" 
module top; 
  timeunit 1ns;     timeprecision 100ps;    
	bit clk, a, b;  
	default clocking @(posedge clk); endclocking
    initial forever #10 clk=!clk;  
    initial begin
      $timeformat(-9, 1, "ns", 8);
      $display("%t", $realtime);
   end 
    always  @(posedge clk)  begin 
    end 
    
    initial begin 
       bit va, vb; 
      repeat(200) begin 
        @(posedge clk);   
        if (!randomize(va, vb)  with 
        { va dist {1'b1:=1, 1'b0:=3};
          vb dist {1'b1:=1, 1'b0:=2};      
      }) `uvm_error("MYERR", "This is a randomize error")
       a <= va; 
       b <= vb;
    end 
    $stop; 
  end 
endmodule    

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr


  1. https://verificationacademy.com/news/verification-horizons-march-2018-issue
  2. http://systemverilog.us/vf/SolvingComplexUsersAssertions.pdf
  3. “Using SVA for scoreboarding and TB designs”
    http://systemverilog.us/papers/sva4scoreboarding.pdf
  4. “Assertions Instead of FSMs/logic for Scoreboarding and Verification”
    https://verificationacademy.com/verification-horizons/october-2013-volume-9-issue-3
  5. SVA in a UVM Class-based Environment
    https://verificationacademy.com/verification-horizons/february-2013-volume-9-issue-1/SVA-in-a-UVM-Class-based-Environment