@@ -29,6 +29,10 @@ class Vpr(Edatool):
2929 "type" : "str" ,
3030 "desc" : "Path to target architecture in XML format" ,
3131 },
32+ "gen_constraints" : {
33+ "type" : "list" ,
34+ "desc" : "A list to be used for inserting two commands between the pack and place step" ,
35+ },
3236 "vpr_options" : {
3337 "type" : "str" ,
3438 "desc" : "Additional options for VPR." ,
@@ -67,16 +71,21 @@ def configure(self, edam):
6771 """
6872 super ().configure (edam )
6973
70- src_files = []
71- incdirs = set ()
72-
73- file_netlist = []
74+ netlist_file = ""
7475 timing_constraints = []
7576
76- for f in src_files :
77- if f .file_type in ["blif" , "eblif" ]:
78- file_netlist .append (f .name )
79- if f .file_type in ["SDC" ]:
77+ for f in self .files :
78+ file_type = f .get ("file_type" , "" )
79+
80+ if file_type in ["blif" , "eblif" ]:
81+ if netlist_file :
82+ raise RuntimeError (
83+ "VPR only supports one netlist file. Found {} and {}" .format (
84+ netlist_file , f ["name" ]
85+ )
86+ )
87+ netlist_file = f ["name" ]
88+ if file_type in ["SDC" ]:
8089 timing_constraints .append (f .name )
8190
8291 arch_xml = self .tool_options .get ("arch_xml" )
@@ -90,27 +99,59 @@ def configure(self, edam):
9099
91100 commands = EdaCommands ()
92101
93- depends = self . name + ".blif"
102+ depends = netlist_file
94103 targets = self .name + ".net"
95- command = ["vpr" , arch_xml , self . name + ".blif" , "--pack" ]
104+ command = ["vpr" , arch_xml , netlist_file , "--pack" ]
96105 command += sdc_opts + vpr_options
97106 commands .add (command , [targets ], [depends ])
98107
99- depends = self .name + ".net"
108+ # First, check if gen_constraint value list is passed in and is the correct size
109+ gen_constr_list = []
110+ if (
111+ self .tool_options .get ("gen_constraints" )
112+ and len (self .tool_options .get ("gen_constraints" )) == 4
113+ ):
114+ gen_constr_list = self .tool_options .get ("gen_constraints" )
115+
116+ # Run generate constraints scripts if correct list exists
117+ if gen_constr_list :
118+ depends = self .name + ".net"
119+ targets = gen_constr_list [0 ]
120+ commands .add (
121+ ["python3" , gen_constr_list [2 ]],
122+ [targets ],
123+ [depends ],
124+ )
125+
126+ depends = gen_constr_list [0 ]
127+ targets = gen_constr_list [1 ]
128+ commands .add (
129+ ["python3" , gen_constr_list [3 ]],
130+ [targets ],
131+ [depends ],
132+ )
133+
100134 targets = self .name + ".place"
101- command = ["vpr" , arch_xml , self .name + ".blif" , "--place" ]
135+ command = ["vpr" , arch_xml , netlist_file ]
136+ # Modify place stage if running generate constraints script
137+ if gen_constr_list :
138+ depends = gen_constr_list [1 ]
139+ command += [f"--fix_clusters { gen_constr_list [1 ]} " ]
140+ else :
141+ depends = self .name + ".net"
142+ command += ["--place" ]
102143 command += sdc_opts + vpr_options
103144 commands .add (command , [targets ], [depends ])
104145
105146 depends = self .name + ".place"
106147 targets = self .name + ".route"
107- command = ["vpr" , arch_xml , self . name + ".blif" , "--route" ]
148+ command = ["vpr" , arch_xml , netlist_file , "--route" ]
108149 command += sdc_opts + vpr_options
109150 commands .add (command , [targets ], [depends ])
110151
111152 depends = self .name + ".route"
112153 targets = self .name + ".analysis"
113- command = ["vpr" , arch_xml , self . name + ".blif" , "--analysis" ]
154+ command = ["vpr" , arch_xml , netlist_file , "--analysis" ]
114155 command += sdc_opts + vpr_options
115156 commands .add (command , [targets ], [depends ])
116157
0 commit comments