Hi,
I want to write a systemverilog assumption for 2 multibit signals say A[11:0] and B[11:0] such that they are never equal in ANY cycle.
Simple != is not working as it is checking only in same cycle.
Can someone please suggest a simple way.
In reply to ben@SystemVerilog.us:
The following example from my SVA book will guide you toward my approach as it uses associative arrays.
module memory_data_integrity_check (
input bit write, // memory write
input bit read, // memory read
input bit[31:0] wdata, // data written to memory
input bit[31:0] addr, // memory address -- small for simulation
input bit reset_n, // active low reset
input bit clk); // clock
timeunit 1ns; timeprecision 100ps;
default clocking cb_clk @ (posedge clk); endclocking
int mem_aarray[*]; // associative array (AA) to be used by property
bit [31:0] rdata; // data read from memory
bit mem_aarray_exists; // exists at specified address
assign mem_aarray_exists = mem_aarray.exists(addr);
always_comb
if(mem_aarray_exists)
rdata = mem_aarray[addr]; //
always@ (posedge clk)
if (reset_n==1'b0) mem_aarray.delete; // Clears AA elements
else if (write) mem_aarray[addr] = wdata; // store data
property p_read_after_write;
bit [31:0] v_wrdata, v_wraddr;
(write, v_wraddr=addr, v_wrdata= wdata) |-> // if write, save data and addr
(read && mem_aarray_exists && addr==v_wraddr) [->1] |-> // @read and data there at same written addr
rdata==v_wrdata; // read data is same as what was written
endproperty : p_read_after_write
ap_read_after_write : assert property (p_read_after_write)
$info("addr =%h, rdata=%h", $sampled(addr), $sampled(rdata)); else
$error("addr =%h, rdata=%h", $sampled(addr), $sampled(rdata));
property p_read_before_write;
not (read && !mem_aarray_exists); // never a read on an non written address
endproperty : p_read_before_write
ap_read_before_write : assert property (p_read_before_write);
endmodule : memory_data_integrity_check
Hi Ben,
Actually i am using Formal Verification tool and it is only allowing synthesizable code. It is printing out an error saying it cant synthesize dynamic array.
In reply to ppatel:
I don’t see a way in formal verification to express an assumption that 2 multibit signals (e.g., A[11:0] and B[11:0]) are never equal in ANY cycle. Reflecting on possibilities, I see two spaces (or maps) of values that are the XOR of each other, For a moment I thought of using the $past, but the number of pasts would not work in simulation for cycles that have not occurred unless you start the evaluation after “n” cycles. Here is an assertion where “a” and “b” are unequal in the last 4 cycles. Note the ##4 in the antecedent.
ap_diff: assume property(@ (posedge clk)
##4 1 |-> a!= b and
$past(a, 1) != $past(b, 1) and
$past(a, 2) != $past(b, 2) and
$past(a, 3) != $past(b, 3));
Thanks Ben for the help! As you said there may not be any simple way to write such synthesizable code. Maybe i will just do A%x==0 and B%x!=0 (some constant x)to generate some disjoint traffic.