Skip to content

Commit

Permalink
Refactor VPR for f4pga/symbiflow usage (includes vprfix)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pocketkid2 authored and olofk committed Aug 27, 2022
1 parent b381679 commit 6264fd8
Showing 1 changed file with 55 additions and 14 deletions.
69 changes: 55 additions & 14 deletions edalize/tools/vpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class Vpr(Edatool):
"type": "str",
"desc": "Path to target architecture in XML format",
},
"gen_constraints": {
"type": "list",
"desc": "A list to be used for inserting two commands between the pack and place step",
},
"vpr_options": {
"type": "str",
"desc": "Additional options for VPR.",
Expand Down Expand Up @@ -67,16 +71,21 @@ def configure(self, edam):
"""
super().configure(edam)

src_files = []
incdirs = set()

file_netlist = []
netlist_file = ""
timing_constraints = []

for f in src_files:
if f.file_type in ["blif", "eblif"]:
file_netlist.append(f.name)
if f.file_type in ["SDC"]:
for f in self.files:
file_type = f.get("file_type", "")

if file_type in ["blif", "eblif"]:
if netlist_file:
raise RuntimeError(
"VPR only supports one netlist file. Found {} and {}".format(
netlist_file, f["name"]
)
)
netlist_file = f["name"]
if file_type in ["SDC"]:
timing_constraints.append(f.name)

arch_xml = self.tool_options.get("arch_xml")
Expand All @@ -90,27 +99,59 @@ def configure(self, edam):

commands = EdaCommands()

depends = self.name + ".blif"
depends = netlist_file
targets = self.name + ".net"
command = ["vpr", arch_xml, self.name + ".blif", "--pack"]
command = ["vpr", arch_xml, netlist_file, "--pack"]
command += sdc_opts + vpr_options
commands.add(command, [targets], [depends])

depends = self.name + ".net"
# First, check if gen_constraint value list is passed in and is the correct size
gen_constr_list = []
if (
self.tool_options.get("gen_constraints")
and len(self.tool_options.get("gen_constraints")) == 4
):
gen_constr_list = self.tool_options.get("gen_constraints")

# Run generate constraints scripts if correct list exists
if gen_constr_list:
depends = self.name + ".net"
targets = gen_constr_list[0]
commands.add(
["python3", gen_constr_list[2]],
[targets],
[depends],
)

depends = gen_constr_list[0]
targets = gen_constr_list[1]
commands.add(
["python3", gen_constr_list[3]],
[targets],
[depends],
)

targets = self.name + ".place"
command = ["vpr", arch_xml, self.name + ".blif", "--place"]
command = ["vpr", arch_xml, netlist_file]
# Modify place stage if running generate constraints script
if gen_constr_list:
depends = gen_constr_list[1]
command += [f"--fix_clusters {gen_constr_list[1]}"]
else:
depends = self.name + ".net"
command += ["--place"]
command += sdc_opts + vpr_options
commands.add(command, [targets], [depends])

depends = self.name + ".place"
targets = self.name + ".route"
command = ["vpr", arch_xml, self.name + ".blif", "--route"]
command = ["vpr", arch_xml, netlist_file, "--route"]
command += sdc_opts + vpr_options
commands.add(command, [targets], [depends])

depends = self.name + ".route"
targets = self.name + ".analysis"
command = ["vpr", arch_xml, self.name + ".blif", "--analysis"]
command = ["vpr", arch_xml, netlist_file, "--analysis"]
command += sdc_opts + vpr_options
commands.add(command, [targets], [depends])

Expand Down

0 comments on commit 6264fd8

Please sign in to comment.