Forum Discussion
How to properly constrain bidirectional I2C SCL / SDA ports ?
Any update please on this?
I cant find any source that shows SDC constraints for SCL and SDA?
In I2c or I3C.
Because both are used as clock and data
Hi,
There is no Altera cookbook with dedicated SDC for I2C SDA/SCL. That is expected as I2C is open-drain and protocol-timed (NXP UM10204), while Quartus STA only use clocks + set_input_delay / set_output_delay on ports.
What we constrain in SDC:
- clk_10m , capture/launch clock of the controller
- set_input_delay on SCL and SDA (pad → first filter flop), or set_false_path -from if treated as async after the filter
- set_output_delay on bidir SDA (and SCL only if clock-stretch), with both -max and -min
Example (delay values are placeholders):
set_input_delay -clock [get_clocks clk_10m] -max 20 [get_ports {i2c_scl i2c_sda}]
set_input_delay -clock [get_clocks clk_10m] -min $i2c_board_min [get_ports {i2c_scl i2c_sda}]
set_output_delay -clock [get_clocks clk_10m] -max 20 [get_ports {i2c_sda}]
set_output_delay -clock [get_clocks clk_10m] -min -$i2c_board_max [get_ports {i2c_sda}]
Regards,
Richard Tan
- M_Aboelnaga8 days ago
New Contributor
Hi,
What about SCL as data?
there are some cases that use SCL as data, SDA as clock.
Do we make create_clock on SDA ? and input delay on SCL port with respect to SDA clock?- RichardT_altera8 days ago
Super Contributor
In I2C, SDA is never the clock and SCL is never data. The bus does not swap those roles.
create_clock on SDA + set_input_delay on SCL would only apply if a non-I2C design literally used the SDA pin as the capture clock of FPGA registers, and SCL as data into those registers, e.g.:
create_clock -name sda_clk -period <T> [get_ports {sda}]
set_input_delay -clock [get_clocks sda_clk] -max <placeholder> [get_ports {scl}]
set_input_delay -clock [get_clocks sda_clk] -min <placeholder> [get_ports {scl}]
That is generic source-synchronous / edge-clocked methodology. See AN433.
https://docs.altera.com/v/u/docs/653688/an-433-constraining-and-analyzing-source-synchronous-interfaces
AN 433 covers interfaces where the same device drives both clock and data, and the receiver captures data with that forwarded clock. That does not apply to I2C.
Regards,
Richard Tan- M_Aboelnaga8 days ago
New Contributor
Actually It applies in my I3c design
I was asking about I2c just because i saw the question on I2C.
But my design yes checks on SCL as data ( while SCL is high) and capture with SDA rising edge ( to capture Stop Condition)
So, in this case : Is it normal to have 2 clocks and 2 input delays with swapped roles ( clock SCL with input delay on SDA , clock on SDA with input delay on SCL)?