Skip to content

Commit

Permalink
tweak yosys FPGA flow and fix outdated flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kammoh committed Nov 25, 2024
1 parent 2b5c268 commit 4ebc952
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/xeda/flows/yosys/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ def init(self):
ss.flatten = True # design must be flattened
if ss.flatten:
append_flag(ss.synth_flags, "-flatten")
else:
append_flag(ss.synth_flags, "-noflatten")
if ss.abc_dff:
append_flag(ss.abc_flags, "-dff")
ss.set_attribute = hierarchical_merge(self.design.rtl.attributes, ss.set_attribute)
Expand Down
8 changes: 6 additions & 2 deletions src/xeda/flows/yosys/templates/yosys_fpga_synth.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ yosys flatten

{% if settings.pre_synth_opt %}
yosys log -stdout "** Pre-synthesis optimization **"
yosys opt -full -purge -sat
yosys opt -undriven -purge -keepdc -noff
{% endif %}

yosys opt_clean -purge

{% if settings.abc9 -%}
{% if settings.flow3 -%} yosys scratchpad -copy abc9.script.flow3 abc9.script {%- endif %}
{# decrease the target delay to account for interconnect delay #}
Expand All @@ -38,9 +40,11 @@ yosys log -stdout "[ERROR] Unknown FPGA vendor, family, or device"

{% if settings.post_synth_opt %}
yosys log -stdout "** Post-synthesis optimization **"
yosys opt -full -purge -sat
yosys opt -full -fine -purge -sat -undriven
{% endif %}

yosys opt_clean -purge

{% if settings.splitnets %}
yosys splitnets
{% endif %}
Expand Down
22 changes: 20 additions & 2 deletions src/xeda/flows/yosys/yosys_fpga.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,23 @@ def parse_reports(self) -> bool:
self.results["LUT"] += ram32m
self.results["LUT:RAM"] = ram32m
self.results["FF"] = sum_all_resources(
design_util, ["FDCE", "FDPE", "FDRE", "FDSE"]
design_util,
[
"FDCE", # D Flip-Flop with Clock Enable and Asynchronous Clear
"FDPE", # D Flip-Flop with Clock Enable and Asynchronous Preset
"FDRE", # D Flip-Flop with Clock Enable and Synchronous Reset
"FDSE", # D Flip-Flop with Clock Enable and Synchronous Set
],
)
latches = sum_all_resources(
design_util,
[
"LDCE", # Transparent Data Latch with Asynchronous Clear and Gate Enable
"LDPE", # Transparent Data Latch with Asynchronous Preset and Gate Enable
],
)
if latches:
self.results["LATCH"] = latches
brams: float = sum_all_resources(design_util, ["RAMB36"])
brams_half = sum_all_resources(design_util, ["RAMB18"])
brams += brams_half / 2
Expand All @@ -163,9 +178,12 @@ def parse_reports(self) -> bool:
dsps = sum_all_resources(design_util, ["DSP48E1", "DSP48E2", "DSP48E"])
if dsps:
self.results["DSP"] = dsps
carry_chains = sum_all_resources(design_util, ["CARRY4", "CARRY2"])
carry_chains = sum_all_resources(design_util, ["CARRY8", "CARRY4", "CARRY2"])
if carry_chains:
self.results["CARRY"] = carry_chains
muxf78 = sum_all_resources(design_util, ["MUXF7", "MUXF8"])
if carry_chains:
self.results["MUXF7/F8"] = muxf78

# if self.settings.fpga:
return True
Expand Down

0 comments on commit 4ebc952

Please sign in to comment.