Skip to content

Commit

Permalink
Add a --pgm tool option to stop build stage from automatically progra…
Browse files Browse the repository at this point in the history
…mming (#392)

Add --pgm flag to tools with programming capabilities
  • Loading branch information
GCHQDeveloper147 authored and olofk committed Nov 21, 2023
1 parent 2862825 commit 2bf3994
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
7 changes: 7 additions & 0 deletions edalize/ise.py
Expand Up @@ -94,6 +94,11 @@ def get_doc(cls, api_ver):
"type": "Integer",
"desc": "Specifies the FPGA's device number in the JTAG chain, starting at 1",
},
{
"name": "pgm",
"type": "String",
"desc": "Programming tool. Default is 'none', set to 'ise' to program the FPGA in the run stage.",
},
],
}

Expand Down Expand Up @@ -188,6 +193,8 @@ def _write_tcl_file(self):
tcl_file.close()

def run_main(self):
if ("pgm" not in self.tool_options) or (self.tool_options["pgm"] != "ise"):
return
pgm_file_name = os.path.join(self.work_root, self.name + ".pgm")
self._write_pgm_file(pgm_file_name)
self._run_tool("impact", ["-batch", pgm_file_name])
Expand Down
14 changes: 7 additions & 7 deletions edalize/quartus.py
Expand Up @@ -58,6 +58,11 @@ def get_doc(cls, api_ver):
"type": "String",
"desc": "P&R tool. Allowed values are quartus (default), dse (to run Design Space Explorer) and none (to just run synthesis)",
},
{
"name": "pgm",
"type": "String",
"desc": "Programming tool. Default is 'none', set to 'quartus' to program the FPGA in the run stage.",
},
],
"lists": [
{
Expand Down Expand Up @@ -272,13 +277,8 @@ def run_main(self):
args += ["-o"]
args += ["p;" + self.name.replace(".", "_") + ".sof"]

if "pnr" in self.tool_options:
if self.tool_options["pnr"] == "quartus":
pass
elif self.tool_options["pnr"] == "dse":
return
elif self.tool_options["pnr"] == "none":
return
if ("pgm" not in self.tool_options) or (self.tool_options["pgm"] != "quartus"):
return

if "board_device_index" in self.tool_options:
args[-1] += "@" + self.tool_options["board_device_index"]
Expand Down
12 changes: 7 additions & 5 deletions edalize/vivado.py
Expand Up @@ -61,6 +61,11 @@ def get_doc(cls, api_ver):
"type": "String",
"desc": "P&R tool. Allowed values are vivado (default) and none (to just run synthesis)",
},
{
"name": "pgm",
"type": "String",
"desc": "Programming tool. Default is none, set to 'vivado' to program the FPGA in the run stage.",
},
{
"name": "jobs",
"type": "Integer",
Expand Down Expand Up @@ -115,11 +120,8 @@ def run_main(self):
correct FPGA board and then downloads the bitstream. The tcl script is then
executed in Vivado's batch mode.
"""
if "pnr" in self.tool_options:
if self.tool_options["pnr"] == "vivado":
pass
elif self.tool_options["pnr"] == "none":
return
if ("pgm" not in self.tool_options) or (self.tool_options["pgm"] != "vivado"):
return

self._run_tool("make", ["pgm"])

Expand Down

0 comments on commit 2bf3994

Please sign in to comment.