Skip to content

Commit 6161827

Browse files
committed
VTR flow: Allow to run experiments with custom ODIN II config (Python)
This set of changes introduces ability to modify the VTR flow through providing a custom default script. Also, fixes the problem of disable xml option crashing in odin.py and a problem with run_vtr_task.py followed by the name of the script. Changes to Python scripts. Signed-off-by: Georgiy Krylov <[email protected]>
1 parent fe538c8 commit 6161827

File tree

6 files changed

+91
-24
lines changed

6 files changed

+91
-24
lines changed

doc/src/vtr/run_vtr_flow.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,13 @@ Detailed Command-line Options
173173
Tells ODIN II to connect the first cin in an adder/subtractor chain
174174
to a global gnd/vdd net. Instead of creating a dummy adder to generate
175175
the input signal of the first cin port of the chain.
176+
177+
.. option:: -odin_xml <path_to_custom_xml>
178+
179+
Tells VTR flow to use a custom ODIN II configuration value. The default
180+
behavior is to use the vtr_flow/misc/basic_odin_config_split.xml.
181+
Instead, an alternative config file might be supplied, compare the
182+
default and vtr_flow/misc/custom_odin_config_no_mults.xml for usage
183+
scenarios. This option is needed for running the entire VTR flow with
184+
additional parameters for ODIN II that are provided from within the
185+
.xml file.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
This file specifies a way of hard-coding odin arguments to run a complete vtr flow
3+
Hard-coded values can modify the "XXX", "YYY" etc.
4+
The tags marked as required should be persisted for the run_vtr_flow.py to succeed
5+
-->
6+
<!-- required-->
7+
<config>
8+
<!-- required-->
9+
<verilog_files>
10+
<!-- Way of specifying multiple files in a project, required -->
11+
<verilog_file>XXX</verilog_file>
12+
</verilog_files>
13+
<!-- required-->
14+
<output>
15+
<!-- These are the output flags for the project, required -->
16+
<output_type>blif</output_type>
17+
<!-- required-->
18+
<output_path_and_name>ZZZ</output_path_and_name>
19+
<target>
20+
<!-- This is the target device the output is being built for, required -->
21+
<arch_file>YYY</arch_file>
22+
</target>
23+
</output>
24+
<!-- required-->
25+
<optimizations>
26+
<!-- optional-->
27+
<mix_soft_hard_blocks mults_ratio="0.0"></mix_soft_hard_blocks>+
28+
<!-- required-->
29+
<multiply size="MMM" fixed="1" fracture="0" padding="-1"/>
30+
<!-- required-->
31+
<memory split_memory_width="1" split_memory_depth="PPP"/>
32+
<!-- required-->
33+
<adder size="0" threshold_size="AAA"/>
34+
</optimizations>
35+
<!-- required-->
36+
<debug_outputs>
37+
<!-- Various debug options, all optional -->
38+
<debug_output_path>.</debug_output_path>
39+
<output_ast_graphs>1</output_ast_graphs>
40+
<output_netlist_graphs>1</output_netlist_graphs>
41+
</debug_outputs>
42+
</config>

vtr_flow/scripts/python_libs/vtr/flow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def run(
4343
vpr_args=None,
4444
keep_intermediate_files=True,
4545
keep_result_files=True,
46+
odin_config=None,
4647
min_hard_mult_size=3,
4748
min_hard_adder_size=1,
4849
check_equivalent=False,
@@ -182,6 +183,7 @@ def run(
182183
command_runner=command_runner,
183184
temp_dir=temp_dir,
184185
odin_args=odin_args,
186+
odin_config=odin_config,
185187
min_hard_mult_size=min_hard_mult_size,
186188
min_hard_adder_size=min_hard_adder_size,
187189
)

vtr_flow/scripts/python_libs/vtr/odin/odin.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,43 +82,46 @@ def run(
8282

8383
if odin_config is None:
8484
odin_base_config = str(paths.odin_cfg_path)
85+
else:
86+
odin_base_config = str(Path(odin_config).resolve())
87+
88+
# Copy the config file
89+
odin_config = "odin_config.xml"
90+
odin_config_full_path = str(temp_dir / odin_config)
91+
shutil.copyfile(odin_base_config, odin_config_full_path)
92+
93+
# Update the config file
94+
file_replace(
95+
odin_config_full_path,
96+
{
97+
"XXX": circuit_file.name,
98+
"YYY": architecture_file.name,
99+
"ZZZ": output_netlist.name,
100+
"PPP": determine_memory_addr_width(str(architecture_file)),
101+
"MMM": min_hard_mult_size,
102+
"AAA": min_hard_adder_size,
103+
},
104+
)
85105

86-
# Copy the config file
87-
odin_config = "odin_config.xml"
88-
odin_config_full_path = str(temp_dir / odin_config)
89-
shutil.copyfile(odin_base_config, odin_config_full_path)
90-
91-
# Update the config file
92-
file_replace(
93-
odin_config_full_path,
94-
{
95-
"XXX": circuit_file.name,
96-
"YYY": architecture_file.name,
97-
"ZZZ": output_netlist.name,
98-
"PPP": determine_memory_addr_width(str(architecture_file)),
99-
"MMM": min_hard_mult_size,
100-
"AAA": min_hard_adder_size,
101-
},
102-
)
103-
disable_odin_xml = False
104-
if "disable_odin_xml" in odin_args:
105-
disable_odin_xml = True
106-
del odin_args["disable_odin_xml"]
106+
cmd = [odin_exec]
107107
use_odin_simulation = False
108+
108109
if "use_odin_simulation" in odin_args:
109110
use_odin_simulation = True
110111
del odin_args["use_odin_simulation"]
111112

112-
cmd = [odin_exec, "-c", odin_config]
113113
for arg, value in odin_args.items():
114114
if isinstance(value, bool) and value:
115115
cmd += ["--" + arg]
116116
elif isinstance(value, (str, int, float)):
117117
cmd += ["--" + arg, str(value)]
118118
else:
119119
pass
120+
120121
cmd += ["-U0"]
121-
if disable_odin_xml:
122+
123+
if "disable_odin_xml" in odin_args:
124+
del odin_args["disable_odin_xml"]
122125
cmd += [
123126
"-a",
124127
architecture_file.name,
@@ -127,6 +130,8 @@ def run(
127130
"-o",
128131
output_netlist.name,
129132
]
133+
else:
134+
cmd += ["-c", odin_config]
130135

131136
command_runner.run_system_command(
132137
cmd, temp_dir=temp_dir, log_filename=log_filename, indent_depth=1

vtr_flow/scripts/run_vtr_flow.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ def vtr_command_argparser(prog=None):
314314
type=int,
315315
help="Tells ODIN II the minimum adder size that should be implemented using hard adder.",
316316
)
317+
odin.add_argument(
318+
"-odin_xml",
319+
default=None,
320+
dest="odin_config",
321+
help="Supplies Odin with a custom config file for optimizations.",
322+
)
317323
#
318324
# VPR arguments
319325
#
@@ -421,6 +427,7 @@ def vtr_command_main(arg_list, prog=None):
421427
keep_result_files=args.keep_result_files,
422428
min_hard_mult_size=args.min_hard_mult_size,
423429
min_hard_adder_size=args.min_hard_adder_size,
430+
odin_config=args.odin_config,
424431
check_equivalent=args.check_equivalent,
425432
check_incremental_sta_consistency=args.check_incremental_sta_consistency,
426433
use_old_abc_script=args.use_old_abc_script,

vtr_flow/scripts/run_vtr_task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def run_tasks(
283283

284284
if args.parse:
285285
print("\nParsing test results...")
286-
print("scripts/parse_vtr_task.py -l {}".format(args.list_file[0]))
286+
if len(args.list_file) > 0:
287+
print("scripts/parse_vtr_task.py -l {}".format(args.list_file[0]))
287288
parse_tasks(configs, jobs)
288289

289290
if args.create_golden:

0 commit comments

Comments
 (0)