Prev Problem
Next Problem

23. Open-Drain I2C SDA line

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

Model the I2C open-drain behaviour by pulling the line low when required and releasing it otherwise. Use a tri-state net with a pull-up (tri1) so the line stays high when not driven, matching real I2C operation.

 

Code

module i2c_line(
    input  drive_low,   // 1 = pull line low, 0 = release
    output tri1 sda      // tri1 gives default pull-up to 1
);

assign sda = (drive_low) ? 1'b0 : 1'bz;

endmodule
Was this helpful?
Upvote
Downvote