// open_drain_pin.sv // Top-level open-drain pin, as used for I2C SDA. The pin is either driven // low or released (high impedance) so an external pull-up can pull it high. // Tri-state buffers exist only in the I/O blocks, so keep this logic at the // top level of the design. module open_drain_pin ( inout wire sda, // FPGA pin input logic drive_low, // 1 = pull the line low output logic sda_in // value read back from the pin ); assign sda = drive_low ? 1'b0 : 1'bz; assign sda_in = sda; endmodule