3. 创建时钟约束
# 设置时钟 clk 为 1Hz (1000000000ns周期)(在 clock_run 中)
create_clock -period 1000000000 [get_pins clk]
# 设置 scl 为 interface_2 时钟,由 i2c_master 模块产生,频率为 400kHz(周期为2500ns)
create_clock -period 2500 [get_pins slave_top/scl]
# 4. 设置时钟不同时序约束
#set_clock_latency -max 2 -pin [get_pins i2c_master/clk]
#set_clock_latency -max 100 -pin [get_pins clock_run/clk]
#set_clock_latency -max 5 -pin [get_pins i2c_master/scl]
# 5. 设置输入输出时序约束
# 对于输入信号,如 rst_n
set_input_delay -max 1 [get_pins top_slave/rst]
set_input_delay -max 1 [get_pins top_slave/pulse]
# 对于输出信号,设置输出延时
set_output_delay -max 1 [get_pins top_slave/int]
# 6. 设置双向端口( SDA)的时序
set_input_delay -max 1 -clock [get_clocks clk] [get_pins top_slave/sda]
set_output_delay -max 1 -clock [get_clocks clk] [get_pins top_slave/sda]
# 7. 设置时钟之间的关系
set_clock_uncertainty 0.1 [get_clocks slave_top/clk]
set_clock_uncertainty 0.1 [get_clocks slave_top/scl]
# 9. 对 interface_2 和 clock_run 之间的交叉信号设置时序约束
# interface_2 的输出信号连接到 clock_run 的输入信号
# interface_2 的时钟是 scl(400kHz),clock_run 的时钟是 clk(1Hz)
# 设置从 interface_2 到 clock_run 的交叉信号约束:
# 对于 interface_2 的输出信号,时序约束应该基于 interface_2 的时钟 scl
set_input_delay -max 1 -clock [get_clocks clk] [get_pins clock_run/{pw_data}] # clock_run 输入信号 pwdata
set_output_delay -max 1 -clock [get_clocks scl] [get_pins interface_2/pw_data] # interface_2 输出信号 pw_data
set_output_delay -max 1 -clock [get_clocks clk] [get_pins clock_run/out_prdata] # clock_run 输出信号 prdata
set_input_delay -max 1 -clock [get_clocks scl] [get_pins interface_2/out_prdata] # interface_2 输入信号 pr_data
set_input_delay -max 1 -clock [get_clocks clk] [get_pins clock_run/reg_addr] # clock_run 输入信号 reg_addr
set_output_delay -max 1 -clock [get_clocks scl] [get_pins interface_2/reg_addr] # interface_2 输出信号 reg_addr
set_input_delay -max 1 -clock [get_clocks clk] [get_pins clock_run/w_en] # clock_run 输入信号 w_en
set_output_delay -max 1 -clock [get_clocks scl] [get_pins interface_2/w_en] # interface_2 输出信号 w_en
set_input_delay -max 1 -clock [get_clocks clk] [get_pins clock_run/r_en] # clock_run 输入信号 r_en
set_output_delay -max 1 -clock [get_clocks scl] [get_pins interface_2/r_en] # interface_2 输出信号 r_en
set_input_delay -max 1 -clock [get_clocks clk] [get_pins clock_run/block] # clock_run 输入信号 block
set_output_delay -max 1 -clock [get_clocks scl] [get_pins interface_2/block]
