I2C Write and Read Operations

Figure 1. I2C Operations on I2C Bus

Performing a Write Operation on I2C Master

  1. Ensure the busy signal is low.
  2. Assign din, command_byte, i2c_slave_addr and num_bytes, then assert the write signal for one clock cycle.
  3. Verify the status of the busy signal. If asserted, the I2C master sends out the write data to the I2C slave device.
  4. Verify the status of the write_done signal. If asserted, the din is written completely. If you want to issue multiple I2C write, insert new din value after write_done is high.
  5. After the busy signal goes low, verify i2c_arb_lost and i2c_rxak signals are low.
  6. The write data successfully sent out.
Figure 2. Write Operation on I2C Master Waveform. With 32-bit data width setting.

Figure 3. Multiple Write Operation on I2C Master Waveform. With 32-bit data width setting.

Performing a Read Operation on I2C Master

  1. Ensure the busy signal is low.
  2. Assign command_byte,i2c_slave_addr and num_bytes, then assert the read signal for one clock cycle.
  3. Verify the status of the busy signal. If asserted, the I2C master reads from the command_byte value of the I2C slave device.
  4. When data_out_valid signal is asserted, the data_out is a valid read data.
  5. After the busy signal is low, verify the i2c_arb_lost signal is low, and the i2c_rxak signal is high.
Figure 4. Read Operation on I2C Master Waveform. With 32-bit data width setting.

Performing a Write Operation on I2C Slave

  1. To send the data back to the I2C master when the master requests a read from the slave, you must provide the write data on the slave based on the command_byte value received.
  2. Wait for the ready_to_wr signal to go high, then assert the write signal for one clock cycle.
  3. Verify the status of the busy signal. If asserted, the I2C slave sends out the write data to the I2C master.
  4. Verify the status of the busy signal. The write transfer is complete when the busy signal is low.
Figure 5. Write Operation on I2C Slave Waveform

Performing a Read Operation on I2C Slave

  1. On the slave, wait for the ready_to_rd signal to go high due to the I2C master doing a write to the slave, then assert the read signal for one clock cycle.
  2. Verify the status of the busy signal. If asserted, the I2C slave reads out the data transferred by the I2C master.
  3. Verify the status of the rddata_valid signal. If asserted, the data_out is a valid read data.
  4. Verify the status of the busy signal. The read transfer is complete when the busy signal is low.
Note: The I2C slave drops the additional byte if the I2C master sends more than DATA_BYTE_WIDTH/8 bytes of data.
Figure 6. Read Operation on I2C Slave Waveform