2023-07-26 18:47:43 -07:00
# Copyright (c) 2019-2023 Alex Forencich
2019-03-26 18:46:25 -07:00
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# AXI stream asynchronous FIFO timing constraints
foreach fifo_inst [ get_cells - hier - filter { ( ORIG_REF_NAME == axis_async_fifo || REF_NAME == axis_async_fifo) } ] {
puts " I n s e r t i n g t i m i n g c o n s t r a i n t s f o r a x i s _ a s y n c _ f i f o i n s t a n c e $ f i f o _ i n s t "
# get clock periods
2022-12-08 18:49:21 -08:00
set write_clk [ get_clocks - of_objects [ get_cells - quiet " $ f i f o _ i n s t / w r _ p t r _ r e g _ r e g [ * ] $ f i f o _ i n s t / w r _ p t r _ g r a y _ r e g _ r e g [ * ] $ f i f o _ i n s t / r d _ p t r _ g r a y _ s y n c 1 _ r e g _ r e g [ * ] " ] ]
set read_clk [ get_clocks - of_objects [ get_cells - quiet " $ f i f o _ i n s t / r d _ p t r _ r e g _ r e g [ * ] $ f i f o _ i n s t / r d _ p t r _ g r a y _ r e g _ r e g [ * ] $ f i f o _ i n s t / w r _ p t r _ g r a y _ s y n c 1 _ r e g _ r e g [ * ] " ] ]
2019-03-26 18:46:25 -07:00
2022-12-08 18:49:21 -08:00
set write_clk_period [ if { [ llength $write_clk ] } { get_property - min PERIOD $write_clk } { expr 1.0 } ]
set read_clk_period [ if { [ llength $read_clk ] } { get_property - min PERIOD $read_clk } { expr 1.0 } ]
2019-03-26 18:46:25 -07:00
2022-12-08 18:49:21 -08:00
set min_clk_period [ expr min( $write_clk_period , $read_clk_period ) ]
2019-03-26 18:46:25 -07:00
# reset synchronization
2021-10-13 18:07:45 -07:00
set reset_ffs [ get_cells - quiet - hier - regexp " . * / s _ r s t _ s y n c \[ 2 3 \] _ r e g _ r e g " - filter " P A R E N T = = $ f i f o _ i n s t " ]
2019-03-26 18:46:25 -07:00
2019-03-28 16:33:01 -07:00
if { [ llength $reset_ffs ] } {
set_property ASYNC_REG TRUE $reset_ffs
2019-03-26 18:46:25 -07:00
2021-10-13 14:05:13 -07:00
# hunt down source
set dest [ get_cells $fifo_inst / s_rst_sync2_reg_reg]
set dest_pins [ get_pins - of_objects $dest - filter { REF_PIN_NAME == D} ]
set net [ get_nets - segments - of_objects $dest_pins ]
set source_pins [ get_pins - of_objects $net - filter { IS_LEAF && DIRECTION == OUT} ]
set source [ get_cells - of_objects $source_pins ]
set_max_delay - from $source - to $dest - datapath_only $read_clk_period
2019-03-27 23:54:48 -07:00
}
2021-10-13 18:07:45 -07:00
set reset_ffs [ get_cells - quiet - hier - regexp " . * / m _ r s t _ s y n c \[ 2 3 \] _ r e g _ r e g " - filter " P A R E N T = = $ f i f o _ i n s t " ]
2021-10-13 14:05:13 -07:00
if { [ llength $reset_ffs ] } {
set_property ASYNC_REG TRUE $reset_ffs
# hunt down source
set dest [ get_cells $fifo_inst / m_rst_sync2_reg_reg]
set dest_pins [ get_pins - of_objects $dest - filter { REF_PIN_NAME == D} ]
set net [ get_nets - segments - of_objects $dest_pins ]
set source_pins [ get_pins - of_objects $net - filter { IS_LEAF && DIRECTION == OUT} ]
set source [ get_cells - of_objects $source_pins ]
set_max_delay - from $source - to $dest - datapath_only $write_clk_period
2019-03-27 23:54:48 -07:00
}
2019-03-26 18:46:25 -07:00
# pointer synchronization
2022-11-01 23:27:39 -07:00
set sync_ffs [ get_cells - quiet - hier - regexp " . * / r d _ p t r _ g r a y _ s y n c \[ 1 2 \] _ r e g _ r e g \\ \[ \\ d + \\ \] " - filter " P A R E N T = = $ f i f o _ i n s t " ]
2019-03-26 18:46:25 -07:00
2022-11-01 23:27:39 -07:00
if { [ llength $sync_ffs ] } {
set_property ASYNC_REG TRUE $sync_ffs
set_max_delay - from [ get_cells " $ f i f o _ i n s t / r d _ p t r _ r e g _ r e g [ * ] $ f i f o _ i n s t / r d _ p t r _ g r a y _ r e g _ r e g [ * ] " ] - to [ get_cells " $ f i f o _ i n s t / r d _ p t r _ g r a y _ s y n c 1 _ r e g _ r e g [ * ] " ] - datapath_only $read_clk_period
set_bus_skew - from [ get_cells " $ f i f o _ i n s t / r d _ p t r _ r e g _ r e g [ * ] $ f i f o _ i n s t / r d _ p t r _ g r a y _ r e g _ r e g [ * ] " ] - to [ get_cells " $ f i f o _ i n s t / r d _ p t r _ g r a y _ s y n c 1 _ r e g _ r e g [ * ] " ] $write_clk_period
}
set sync_ffs [ get_cells - quiet - hier - regexp " . * / w r _ p t r _ g r a y _ s y n c \[ 1 2 \] _ r e g _ r e g \\ \[ \\ d + \\ \] " - filter " P A R E N T = = $ f i f o _ i n s t " ]
if { [ llength $sync_ffs ] } {
set_property ASYNC_REG TRUE $sync_ffs
2023-07-26 18:47:43 -07:00
set_max_delay - from [ get_cells - quiet " $ f i f o _ i n s t / w r _ p t r _ r e g _ r e g [ * ] $ f i f o _ i n s t / w r _ p t r _ g r a y _ r e g _ r e g [ * ] " ] - to [ get_cells " $ f i f o _ i n s t / w r _ p t r _ g r a y _ s y n c 1 _ r e g _ r e g [ * ] " ] - datapath_only $write_clk_period
set_bus_skew - from [ get_cells - quiet " $ f i f o _ i n s t / w r _ p t r _ r e g _ r e g [ * ] $ f i f o _ i n s t / w r _ p t r _ g r a y _ r e g _ r e g [ * ] " ] - to [ get_cells " $ f i f o _ i n s t / w r _ p t r _ g r a y _ s y n c 1 _ r e g _ r e g [ * ] " ] $read_clk_period
}
set sync_ffs [ get_cells - quiet - hier - regexp " . * / w r _ p t r _ c o m m i t _ s y n c _ r e g _ r e g \\ \[ \\ d + \\ \] " - filter " P A R E N T = = $ f i f o _ i n s t " ]
if { [ llength $sync_ffs ] } {
set_property ASYNC_REG TRUE $sync_ffs
set_max_delay - from [ get_cells - quiet " $ f i f o _ i n s t / w r _ p t r _ s y n c _ c o m m i t _ r e g _ r e g [ * ] " ] - to [ get_cells " $ f i f o _ i n s t / w r _ p t r _ c o m m i t _ s y n c _ r e g _ r e g [ * ] " ] - datapath_only $write_clk_period
set_bus_skew - from [ get_cells - quiet " $ f i f o _ i n s t / w r _ p t r _ s y n c _ c o m m i t _ r e g _ r e g [ * ] " ] - to [ get_cells " $ f i f o _ i n s t / w r _ p t r _ c o m m i t _ s y n c _ r e g _ r e g [ * ] " ] $read_clk_period
2022-11-01 23:27:39 -07:00
}
2019-03-26 18:46:25 -07:00
2019-06-10 17:40:30 -07:00
# output register (needed for distributed RAM sync write/async read)
2022-12-29 23:54:17 -08:00
set output_reg_ffs [ get_cells - quiet " $ f i f o _ i n s t / m _ a x i s _ p i p e _ r e g _ r e g [ 0 ] [ * ] " ]
2019-06-10 17:40:30 -07:00
if { [ llength $output_reg_ffs ] } {
2023-07-26 14:53:01 -07:00
if { [ llength $write_clk ] } {
set_false_path - from $write_clk - to $output_reg_ffs
}
2019-06-10 17:40:30 -07:00
}
2019-03-26 18:46:25 -07:00
# frame FIFO pointer update synchronization
2019-06-10 17:39:18 -07:00
set update_ffs [ get_cells - quiet - hier - regexp " . * / w r _ p t r _ u p d a t e ( _ a c k ) ? _ s y n c \[ 1 2 3 \] _ r e g _ r e g " - filter " P A R E N T = = $ f i f o _ i n s t " ]
2019-03-26 18:46:25 -07:00
if { [ llength $update_ffs ] } {
set_property ASYNC_REG TRUE $update_ffs
2022-11-01 23:27:39 -07:00
set_max_delay - from [ get_cells " $ f i f o _ i n s t / w r _ p t r _ u p d a t e _ r e g _ r e g " ] - to [ get_cells " $ f i f o _ i n s t / w r _ p t r _ u p d a t e _ s y n c 1 _ r e g _ r e g " ] - datapath_only $write_clk_period
set_max_delay - from [ get_cells " $ f i f o _ i n s t / w r _ p t r _ u p d a t e _ s y n c 3 _ r e g _ r e g " ] - to [ get_cells " $ f i f o _ i n s t / w r _ p t r _ u p d a t e _ a c k _ s y n c 1 _ r e g _ r e g " ] - datapath_only $read_clk_period
2019-03-26 18:46:25 -07:00
}
# status synchronization
foreach i { overflow bad_frame good_frame} {
set status_sync_regs [ get_cells - quiet - hier - regexp " . * / $ { i } _ s y n c \[ 1 2 3 \] _ r e g _ r e g " - filter " P A R E N T = = $ f i f o _ i n s t " ]
if { [ llength $status_sync_regs ] } {
set_property ASYNC_REG TRUE $status_sync_regs
2022-11-01 23:27:39 -07:00
set_max_delay - from [ get_cells " $ f i f o _ i n s t / $ { i } _ s y n c 1 _ r e g _ r e g " ] - to [ get_cells " $ f i f o _ i n s t / $ { i } _ s y n c 2 _ r e g _ r e g " ] - datapath_only $read_clk_period
2019-03-26 18:46:25 -07:00
}
}
2023-08-14 16:57:16 -07:00
# pause sync
set sync_ffs [ get_cells - quiet - hier - regexp " . * / p a u s e . s _ p a u s e _ r e q _ s y n c \[ 1 2 3 \] _ r e g _ r e g " - filter " P A R E N T = = $ f i f o _ i n s t " ]
if { [ llength $sync_ffs ] } {
set_property ASYNC_REG TRUE $sync_ffs
set_max_delay - from [ get_cells " $ f i f o _ i n s t / p a u s e . s _ p a u s e _ r e q _ s y n c 1 _ r e g _ r e g " ] - to [ get_cells " $ f i f o _ i n s t / p a u s e . s _ p a u s e _ r e q _ s y n c 2 _ r e g _ r e g " ] - datapath_only $read_clk_period
}
set sync_ffs [ get_cells - quiet - hier - regexp " . * / p a u s e . s _ p a u s e _ a c k _ s y n c \[ 1 2 3 \] _ r e g _ r e g " - filter " P A R E N T = = $ f i f o _ i n s t " ]
if { [ llength $sync_ffs ] } {
set_property ASYNC_REG TRUE $sync_ffs
set_max_delay - from [ get_cells " $ f i f o _ i n s t / p a u s e . s _ p a u s e _ a c k _ s y n c 1 _ r e g _ r e g " ] - to [ get_cells " $ f i f o _ i n s t / p a u s e . s _ p a u s e _ a c k _ s y n c 2 _ r e g _ r e g " ] - datapath_only $write_clk_period
}
2019-03-26 18:46:25 -07:00
}