FPGA-I2C-Minion
FPGA-I2C-Minion copied to clipboard
The sda line can be activly driven high
In the "read" state (READ: send data to master): "sda_o_reg" can be set to one depending on the data. "sda_wen_reg" is set to one in this state too. If you look at how the output is written to, you see that this leads to the data line being actively driven high: sda <= sda_o_reg when sda_wen_reg = '1' else 'Z';
Devices on the I2C bus aren't allowed to actively dive the data lines.
I would change this line of code to: sda <= '0' when (sda_o_reg='0' and sda_wen_reg = '1') else 'Z'; to prevent this behaviour.
I haven't checked the testbenches but the change might lead to an undefined bus-state if you don't drive the bus with an 'H' signal if neither the master nor the slave is pulling the bus low.
If I misunderstood the code, please correct me, I am just a VHDL beginner.
Great catch, thank you! I believe, it will take more than just that one line to fix it.