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?

  • An I²C SDA line is open-drain, meaning devices can pull it low but never drive it high.
  • Using tri1 declares the wire with a default pull-up to logic 1 when undriven.
  • When drive_low = 1, the module actively drives 0 onto the line.
  • When drive_low = 0, the module outputs high-impedance (Z), releasing the line.
  • The result correctly models I²C behavior: wired-AND, idle high, pull-low only.

 

Code

/*Write your code here*/
module i2c_line(
    input  drive_low,   
    output tri1 sda     
);
    assign sda = (drive_low) ? 1'b0 : 1'bz;
endmodule
Was this helpful?
Upvote
Downvote