Forum Discussion
How to properly constrain bidirectional I2C SCL / SDA ports ?
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
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)? - RichardT_altera8 days ago
Super Contributor
I believe it is possible to have 2 clocks and 2 input delays with swapped roles.
You might need to constrain each capture relationship to the clock that actually clocks the flop (set_input_delay / -add_delay)
Expect Clock-As-Data behavior when the same pin is both clock and data.
https://docs.altera.com/r/docs/683243/26.3/quartus-prime-pro-edition-user-guide-timing-analyzer/clock-as-data-analysis
Use -add_delay when a port already has delays vs another clock.
Note that: Specifying an input delay on the same port for a different clock, -clock_fall or -reference_pin removes any previously set input delays, unless you specify the -add_delay option.
Regards,
Richard Tan- M_Aboelnaga7 days ago
New Contributor
but when I tried on quartus, it ignores the input delay i put because the same port as a clock defintion