Hi All,
I want to write an assertion for i2c where sda data should be stable for each positive edge of scl. I am unable to figure out that how to write this assertion. please help me on same.
Hi arpan,
You should declare some flags in interface to indicate when the transfer is a command or data.Based on that use @sda as clocking event and check that scl is low at that time and also disable this assertion when the command signal flag (start or stop)is high.
In reply to rajanpassionate:
Hi rajanpassionate,
i have already took start and stop condition flag in interface based on @sda which indicated start and stop condition for sda bus but i want check data validity for sda as mention is specification -
“The data on the SDA line must be stable during the HIGH period of the clock. The HIGH or LOW state of the data line can only change when the clock signal on the SCL line is
LOW”
Arpan,
You can try writing the property this way.This worked for me.(Provided you should assert the respective flags at the right instant)
property p3;
@(I2C_INTERFACE.sda) disable iff(!I2C_INTERFACE.scl || I2C_INTERFACE.start || I2C_INTERFACE.stop || I2C_INTERFACE.idle) (I2C_INTERFACE.scl==1'b1) ;
endproperty
In reply to rajanpassionate:
Hi rajanpassionate,
i have already took start and stop condition flag in interface based on @sda which indicated start and stop condition for sda bus but i want check data validity for sda as mention is specification -
“The data on the SDA line must be stable during the HIGH period of the clock. The HIGH or LOW state of the data line can only change when the clock signal on the SCL line is
LOW”
Looks to me that this is not a SVA type of check because what you are looking is a continuous (not clocked) test where as long as clk==0 past_sda = sda // store value in a latch.
Then when clk==1 sda should not change (i.e., sda==past_sda), else an err signal is true.
always @(posedge err) $display(" %t sda error", $time); will flash the error condition.