Skip to content

Commit

Permalink
[i2c,rtl] Saturate NACK counter
Browse files Browse the repository at this point in the history
After reducing the counter from 32 bits to 8 bits, saturation is now
more likely. This commit saturates the NACK counter at the maximum value
of 0xFF.

Signed-off-by: Marno van der Maas <[email protected]>
  • Loading branch information
marnovandermaas committed Mar 19, 2024
1 parent 1447fc0 commit 158f544
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hw/ip/i2c/rtl/i2c_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,11 @@ module i2c_core import i2c_pkg::*;
assign hw2reg.target_fifo_status.acqlvl.d = MaxFifoDepthW'(acq_fifo_depth);
assign hw2reg.acqdata.abyte.d = acq_fifo_rdata[7:0];
assign hw2reg.acqdata.signal.d = acq_fifo_rdata[AcqFifoWidth-1:8];
// Add one to the target NACK count if this target has sent a NACK.
assign hw2reg.target_nack_count.de = event_target_nack;
assign hw2reg.target_nack_count.d = reg2hw.target_nack_count.q + 1;

// Add one to the target NACK count if this target has sent a NACK and if
// counter has not saturated.
assign hw2reg.target_nack_count.de = event_target_nack && (reg2hw.target_nack_count.q < 8'hFF);
assign hw2reg.target_nack_count.d = reg2hw.target_nack_count.q + 1;

assign override = reg2hw.ovrd.txovrden;

Expand Down

0 comments on commit 158f544

Please sign in to comment.