build/xilinx/vivado: Add/Improve comments to _build_clock_constraints/_build_false_path_constraints.

This commit is contained in:
Florent Kermarrec 2024-12-02 16:39:07 +01:00
parent 3ba9217122
commit 0ae90a9653
1 changed files with 21 additions and 10 deletions

View File

@ -164,35 +164,45 @@ class XilinxVivadoToolchain(GenericToolchain):
# Timing Constraints (in xdc file) ------------------------------------------------------------- # Timing Constraints (in xdc file) -------------------------------------------------------------
def _build_clock_constraints(self): def _build_clock_constraints(self):
# Add clock constraints to the XDC file.
self.platform.add_platform_command(_xdc_separator("Clock constraints")) self.platform.add_platform_command(_xdc_separator("Clock constraints"))
# Determine whether a clock is defined as a net or a port.
def get_clk_type(clk): def get_clk_type(clk):
return { return {
False : "nets", False : "nets",
True : "ports", True : "ports",
}[hasattr(clk, "port")] }[hasattr(clk, "port")]
# Add create_clock commands for each clock in the design.
for clk, [period, name] in sorted(self.clocks.items(), key=lambda x: x[0].duid): for clk, [period, name] in sorted(self.clocks.items(), key=lambda x: x[0].duid):
if name is None: if name is None:
name = clk name = clk
self.platform.add_platform_command( self.platform.add_platform_command(
"create_clock -name {name} -period " + str(period) + "create_clock -name {name} -period " + str(period) +
" [get_" + get_clk_type(clk) + " {clk}]", name=name, clk=clk) " [get_" + get_clk_type(clk) + " {clk}]", name=name, clk=clk)
# Make sure add_period_constraint cannot be used again.
# Clear clock constraints after generation.
self.clocks.clear() self.clocks.clear()
def _build_false_path_constraints(self): def _build_false_path_constraints(self):
# Add false path constraints to the XDC file.
self.platform.add_platform_command(_xdc_separator("False path constraints")) self.platform.add_platform_command(_xdc_separator("False path constraints"))
# The asynchronous input to a MultiReg is a false path
# Mark asynchronous inputs to MultiReg as false paths.
self.platform.add_platform_command( self.platform.add_platform_command(
"set_false_path -quiet " "set_false_path -quiet "
"-through [get_nets -hierarchical -filter {{mr_ff == TRUE}}]" "-through [get_nets -hierarchical -filter {{mr_ff == TRUE}}]"
) )
# The asynchronous reset input to the AsyncResetSynchronizer is a false path
# Mark asynchronous reset inputs to AsyncResetSynchronizer as false paths.
self.platform.add_platform_command( self.platform.add_platform_command(
"set_false_path -quiet " "set_false_path -quiet "
"-to [get_pins -filter {{REF_PIN_NAME == PRE}} " "-to [get_pins -filter {{REF_PIN_NAME == PRE}} "
"-of_objects [get_cells -hierarchical -filter {{ars_ff1 == TRUE || ars_ff2 == TRUE}}]]" "-of_objects [get_cells -hierarchical -filter {{ars_ff1 == TRUE || ars_ff2 == TRUE}}]]"
) )
# clock_period-2ns to resolve metastability on the wire between the AsyncResetSynchronizer FFs
# Set a maximum delay for metastability resolution in AsyncResetSynchronizer.
self.platform.add_platform_command( self.platform.add_platform_command(
"set_max_delay 2 -quiet " "set_max_delay 2 -quiet "
"-from [get_pins -filter {{REF_PIN_NAME == C}} " "-from [get_pins -filter {{REF_PIN_NAME == C}} "
@ -200,11 +210,12 @@ class XilinxVivadoToolchain(GenericToolchain):
"-to [get_pins -filter {{REF_PIN_NAME == D}} " "-to [get_pins -filter {{REF_PIN_NAME == D}} "
"-of_objects [get_cells -hierarchical -filter {{ars_ff2 == TRUE}}]]" "-of_objects [get_cells -hierarchical -filter {{ars_ff2 == TRUE}}]]"
) )
# Add false paths between clocks
# Add false paths between asynchronous clock domains.
def get_clk_type(clk): def get_clk_type(clk):
return { return {
False: "nets", False : "nets",
True: "ports", True : "ports",
}[hasattr(clk, "port")] }[hasattr(clk, "port")]
for _from, _to in sorted(self.false_paths, key=lambda x: (x[0].duid, x[1].duid)): for _from, _to in sorted(self.false_paths, key=lambda x: (x[0].duid, x[1].duid)):
self.platform.add_platform_command( self.platform.add_platform_command(
@ -213,9 +224,9 @@ class XilinxVivadoToolchain(GenericToolchain):
"-group [get_clocks -include_generated_clocks -of [get_" + get_clk_type(_to) + " {_to}]] " "-group [get_clocks -include_generated_clocks -of [get_" + get_clk_type(_to) + " {_to}]] "
"-asynchronous", "-asynchronous",
_from=_from, _to=_to) _from=_from, _to=_to)
# Make sure add_false_path_constraint cannot be used again.
self.false_paths.clear()
# Clear false path constraints after generation.
self.false_paths.clear()
def build_timing_constraints(self, vns): def build_timing_constraints(self, vns):
# FIXME: -> self ? # FIXME: -> self ?