When I am implementing a I2C slave, here shows a problem. My sda
is an inout port. At time 164ns
, which is is area circled by red in the picture, the the slave writes ack=1
to sda
. After that, the testbench writes data to sda
, and the slave SRAM reads from sda
.
However, seems that the area circled by red is also read by SRAM, which makes SRAM show 1 in MSB in blue denoted area. In practice, SRAM should read from the area after the red circled area. What might it be that causes this error?
part of the code shows below
READ_DATA:begin
addr_x<=addr_x;
ROM<=DATA_IN_ROM;
SRAM[SRAM_LEN-cnt]<=sda;
end
READ_ADDR: begin // rw<=rw;
SRAM<=SRAM;
ROM<=DATA_IN_ROM;
addr_x[REG_LEN-cnt-1]<=sda;
cnt<=cnt+1;
sda_reg<=sda_reg;
sda_vid<=sda_vid;
freeze_cnt<= freeze_cnt;
freeze<=freeze;
rwcnt<=rwcnt;
end
ROM<=DATA_IN_ROM;
? Seems that you are filling SRAM bit-by-bit based oncnt
value, so where iscnt
value increment? Can you post some more code? – sharvil111<=
, since there's not enough code to know), you don't need anysignal<=signal;
statements. – wilcroft