Skip to content

Commit 9ab1946

Browse files
authored
Merge pull request #5209 from povik/hieropt
Start `opt_hier` to enable hierarchical optimization
2 parents d009bcc + 415b7d3 commit 9ab1946

File tree

11 files changed

+583
-6
lines changed

11 files changed

+583
-6
lines changed

docs/source/code_examples/macro_commands/opt.ys

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ do
99
opt_merge
1010
opt_share (-full only)
1111
opt_dff (except when called with -noff)
12+
opt_hier (-hier only)
1213
opt_clean
1314
opt_expr
1415
while <changed design>

docs/source/using_yosys/synthesis/opt.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ control inputs.
192192
Called with ``-nodffe`` and ``-nosdff``, this pass is used to prepare a design
193193
for :doc:`/using_yosys/synthesis/fsm`.
194194

195+
Hierarchical optimization - `opt_hier` pass
196+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197+
198+
This pass considers the design hierarchy and propagates unused signals, constant
199+
signals, and tied-together signals across module boundaries to facilitate
200+
optimization by other passes.
201+
195202
Removing unused cells and wires - `opt_clean` pass
196203
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197204

passes/opt/Makefile.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ OBJS += passes/opt/opt_dff.o
1111
OBJS += passes/opt/opt_share.o
1212
OBJS += passes/opt/opt_clean.o
1313
OBJS += passes/opt/opt_expr.o
14+
OBJS += passes/opt/opt_hier.o
1415

1516
ifneq ($(SMALL),1)
1617
OBJS += passes/opt/share.o

passes/opt/opt.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct OptPass : public Pass {
4646
log(" opt_merge [-share_all]\n");
4747
log(" opt_share (-full only)\n");
4848
log(" opt_dff [-nodffe] [-nosdff] [-keepdc] [-sat] (except when called with -noff)\n");
49+
log(" opt_hier (-hier only)\n");
4950
log(" opt_clean [-purge]\n");
5051
log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-noclkinv] [-fine] [-full] [-keepdc]\n");
5152
log(" while <changed design>\n");
@@ -56,6 +57,7 @@ struct OptPass : public Pass {
5657
log(" opt_expr [-mux_undef] [-mux_bool] [-undriven] [-noclkinv] [-fine] [-full] [-keepdc]\n");
5758
log(" opt_merge [-share_all]\n");
5859
log(" opt_dff [-nodffe] [-nosdff] [-keepdc] [-sat] (except when called with -noff)\n");
60+
log(" opt_hier (-hier only)\n");
5961
log(" opt_clean [-purge]\n");
6062
log(" while <changed design in opt_dff>\n");
6163
log("\n");
@@ -74,6 +76,7 @@ struct OptPass : public Pass {
7476
bool opt_share = false;
7577
bool fast_mode = false;
7678
bool noff_mode = false;
79+
bool hier_mode = false;
7780

7881
log_header(design, "Executing OPT pass (performing simple optimizations).\n");
7982
log_push();
@@ -141,6 +144,10 @@ struct OptPass : public Pass {
141144
noff_mode = true;
142145
continue;
143146
}
147+
if (args[argidx] == "-hier") {
148+
hier_mode = true;
149+
continue;
150+
}
144151
break;
145152
}
146153
extra_args(args, argidx, design);
@@ -155,6 +162,8 @@ struct OptPass : public Pass {
155162
Pass::call(design, "opt_dff" + opt_dff_args);
156163
if (design->scratchpad_get_bool("opt.did_something") == false)
157164
break;
165+
if (hier_mode)
166+
Pass::call(design, "opt_hier");
158167
Pass::call(design, "opt_clean" + opt_clean_args);
159168
log_header(design, "Rerunning OPT passes. (Removed registers in this run.)\n");
160169
}
@@ -173,6 +182,8 @@ struct OptPass : public Pass {
173182
Pass::call(design, "opt_share");
174183
if (!noff_mode)
175184
Pass::call(design, "opt_dff" + opt_dff_args);
185+
if (hier_mode)
186+
Pass::call(design, "opt_hier");
176187
Pass::call(design, "opt_clean" + opt_clean_args);
177188
Pass::call(design, "opt_expr" + opt_expr_args);
178189
if (design->scratchpad_get_bool("opt.did_something") == false)

0 commit comments

Comments
 (0)