i2c_master·A single-master I2C controller.
This is everything Akrida knew about the design. It never sees the design's code.
i2c_master is a single-master I2C controller. A host issues commands
(read a byte, write a byte, write a block, stop) on a valid/ready command
stream, supplies write data on one byte stream and receives read data on
another. The block generates START, repeated START and STOP conditions,
serializes address and data, samples acknowledges and supports clock
stretching by slaves. Standard 7-bit addressing only.
+-------------------------------------+
cmd ----> | command -> bus state -> bit | --> scl_o / scl_i
wdata ---> | decode machine engine | <-> sda_o / sda_i
rdata <--- | | --> busy, bus_control,
+-------------------------------------+ bus_active, missed_ack
| Port | Dir | Width | Description |
|---|---|---|---|
| clk | in | 1 | Clock. All signals are sampled on the rising edge. |
| rst | in | 1 | Synchronous reset, active high |
| s_axis_cmd_address | in | 7 | Target slave address |
| s_axis_cmd_start | in | 1 | Force a (repeated) START before this command |
| s_axis_cmd_read | in | 1 | Read one byte |
| s_axis_cmd_write | in | 1 | Write one byte |
| s_axis_cmd_write_multiple | in | 1 | Write bytes until one with s_axis_data_tlast |
| s_axis_cmd_stop | in | 1 | Issue STOP after this command; alone, a stop command |
| s_axis_cmd_valid | in | 1 | Command valid |
| s_axis_cmd_ready | out | 1 | Command accepted when valid and ready are both high |
| s_axis_data_tdata | in | 8 | Write data byte |
| s_axis_data_tvalid | in | 1 | Write data valid |
| s_axis_data_tready | out | 1 | Write data accepted when valid and ready are both high |
| s_axis_data_tlast | in | 1 | Marks the last byte of a write-multiple block |
| m_axis_data_tdata | out | 8 | Read data byte |
| m_axis_data_tvalid | out | 1 | Read data valid; held until taken |
| m_axis_data_tready | in | 1 | Host takes the read byte |
| m_axis_data_tlast | out | 1 | Read byte was the last before a STOP |
| scl_i | in | 1 | SCL as seen on the bus |
| scl_o | out | 1 | SCL drive: 0 pulls the line low, 1 releases it |
| scl_t | out | 1 | Tristate enable for SCL (same as scl_o) |
| sda_i | in | 1 | SDA as seen on the bus |
| sda_o | out | 1 | SDA drive: 0 pulls the line low, 1 releases it |
| sda_t | out | 1 | Tristate enable for SDA (same as sda_o) |
| busy | out | 1 | A bus operation is in progress |
| bus_control | out | 1 | This master holds the bus (between its START and STOP) |
| bus_active | out | 1 | Bus is between a START and a STOP from any master |
| missed_ack | out | 1 | One-cycle pulse when a slave fails to acknowledge |
| prescale | in | 16 | Timing unit in clock cycles: about a quarter of an SCL period |
| stop_on_idle | in | 1 | Issue STOP automatically when no command is waiting |
The bus is open drain: the line is the AND of every device's drive. The
verification target ties stop_on_idle to 0 and has no other master on
the bus.
read or
(write / write_multiple) set. A command with only stop set is a stop
command. Any other combination is ignored.tlast.m_axis_data_tlast is 1 when the command also had stop set.start is set, the
address differs from the previous command's, or the direction changes.
Otherwise the transfer continues with no new address phase.stop set ends with a STOP condition after its
data. A stop command issues a STOP if the master holds the bus and is
ignored otherwise.missed_ack pulses for one cycle. The master
continues the command regardless.prescale clock cycles, measured from when SCL is actually high on the
bus.prescale cycles
after SCL is high, and SCL stays high at least prescale cycles after a
START's SDA fall.bus_control is high from this master's START until its
STOP. bus_active is high between any START and the next STOP on the bus.rst is high, scl_o and sda_o are 1 (bus released),
s_axis_cmd_ready, s_axis_data_tready, m_axis_data_tvalid, busy,
bus_control, bus_active and missed_ack are 0.Multi-master arbitration, 10-bit addressing, stop_on_idle = 1, and
general-call or SMBus features.