From f80f059d9b177ded26ea4f198781e3f943637d14 Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Sun, 26 Jan 2025 22:05:57 -0800 Subject: [PATCH] Add directives, remove vestigial main --- src/build_fpga/vivado/vivado.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/build_fpga/vivado/vivado.py b/src/build_fpga/vivado/vivado.py index 54dab9b..3c79d5a 100644 --- a/src/build_fpga/vivado/vivado.py +++ b/src/build_fpga/vivado/vivado.py @@ -11,6 +11,23 @@ def build_nonprj(cfg): top = cfg["design_info"]["top_module"] part = cfg["device_info"]["device"] + synth_directive = "default" + opt_directive = "default" + place_directive = "default" + route_directive = "default" + + if "synthesis_options" in cfg.keys(): + if "synth_directive" in cfg["synthesis_options"]: + synth_directive = cfg["synthesis_options"]["synth_directive"] + if "opt_directive" in cfg["synthesis_options"]: + opt_directive = cfg["synthesis_options"]["opt_directive"] + + if "pnr_options" in cfg.keys(): + if "place_directive" in cfg["pnr_options"]: + place_directive = cfg["pnr_options"]["place_directive"] + if "route_directive" in cfg["pnr_options"]: + route_directive = cfg["pnr_options"]["route_directive"] + with open("build.tcl", "w") as f: f.write(f"set outputDir ./nonprojectflow\n") f.write(f"file mkdir $outputDir\n") @@ -22,21 +39,19 @@ def build_nonprj(cfg): f.write(f"read_xdc {' '.join(xdc_sources)}\n") f.write(f"synth_ip [get_ips *]\n") - f.write(f"synth_design -top {top}\n") + f.write(f"synth_design -top {top} -directive {synth_directive}\n") f.write(f"write_checkpoint -force $outputDir/post_synth.dcp\n") f.write(f"report_utilization -file $outputDir/post_synth_util.rpt\n") - f.write(f"opt_design\n") - f.write(f"place_design\n") + f.write(f"opt_design -directive {opt_directive}\n") + f.write(f"place_design -directive {place_directive}\n") f.write(f"write_checkpoint -force $outputDir/post_place.dcp\n") - f.write(f"route_design\n") + f.write(f"route_design -directive {route_directive}\n") f.write(f"write_checkpoint -force $outputDir/post_route.dcp\n") f.write(f"report_utilization -file $outputDir/post_impl_util.rpt\n") + f.write(f"report_timing -file $outputDir/timing.rpt\n") f.write(f"write_bitstream -force $outputDir/{top}.bit\n") f.write(f"exit\n") os.system(f"vivado -mode tcl -source build.tcl") - os.remove("build.tcl") - -if __name__ == "__main__": - main() + os.remove("build.tcl") \ No newline at end of file