Skip to content

Commit b6043be

Browse files
committed
Add condition on another countdown, fix stop condition stopping forever
1 parent bcb7acb commit b6043be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/i2c_master.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ logic [COUNTER_WIDTH-1:0] countdown = COUNTER_WIDTH'(0);
6666
logic [3:0] transaction_progress = 4'd0;
6767

6868
logic release_line;
69-
assign release_line = transaction_progress == 4'd0 || countdown > 0;
69+
assign release_line = (transaction_progress == 4'd0 && counter == COUNTER_HIGH) || countdown > 0;
7070

7171
clock #(
7272
.COUNTER_WIDTH(COUNTER_WIDTH),
@@ -189,7 +189,7 @@ begin
189189
begin
190190
transaction_progress <= 4'd1;
191191
sda_internal <= 1'b0;
192-
if (transaction_progress == 4'd11) // Hold time padding
192+
if (transaction_progress == 4'd11 && COUNTER_HOLD_REPEATED_START > (COUNTER_END - COUNTER_RECEIVE)) // Hold time padding
193193
countdown <= COUNTER_HOLD_REPEATED_START - (COUNTER_END - COUNTER_RECEIVE);
194194
busy <= 1'b1;
195195
end

0 commit comments

Comments
 (0)