Skip to content

Commit 33d5138

Browse files
committed
prep: add -barriers flag
* This uses optbarriers and flatten -barriers to insert barriers on public wires in the design, limiting the optimization that can affect them
1 parent c6e8fb2 commit 33d5138

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

techlibs/common/prep.cc

+17-3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ struct PrepPass : public ScriptPass
6767
log(" -nokeepdc\n");
6868
log(" do not call opt_* with -keepdc\n");
6969
log("\n");
70+
log(" -barriers\n");
71+
log(" add optimization barriers to all public wires to preserve their structure.\n");
72+
log(" this limits the optimizations that can be applied to the design to only\n");
73+
log(" those involving private wires.\n");
74+
log("\n");
7075
log(" -run <from_label>[:<to_label>]\n");
7176
log(" only run the commands between the labels (see below). an empty\n");
7277
log(" from label is synonymous to 'begin', and empty to label is\n");
@@ -79,7 +84,7 @@ struct PrepPass : public ScriptPass
7984
}
8085

8186
string top_module, fsm_opts;
82-
bool autotop, flatten, ifxmode, memxmode, nomemmode, nokeepdc, rdff;
87+
bool autotop, flatten, ifxmode, memxmode, nomemmode, nokeepdc, rdff, barriers;
8388

8489
void clear_flags() override
8590
{
@@ -92,6 +97,7 @@ struct PrepPass : public ScriptPass
9297
nomemmode = false;
9398
nokeepdc = false;
9499
rdff = false;
100+
barriers = false;
95101
}
96102

97103
void execute(std::vector<std::string> args, RTLIL::Design *design) override
@@ -148,6 +154,10 @@ struct PrepPass : public ScriptPass
148154
nokeepdc = true;
149155
continue;
150156
}
157+
if (args[argidx] == "-barriers") {
158+
barriers = true;
159+
continue;
160+
}
151161
break;
152162
}
153163
extra_args(args, argidx, design);
@@ -183,12 +193,16 @@ struct PrepPass : public ScriptPass
183193

184194
if (check_label("coarse"))
185195
{
196+
if (help_mode || barriers)
197+
run("optbarriers", "(if -barriers)");
186198
if (help_mode)
187199
run("proc [-ifx]");
188200
else
189201
run(ifxmode ? "proc -ifx" : "proc");
190-
if (help_mode || flatten)
191-
run("flatten", "(if -flatten)");
202+
if (help_mode)
203+
run("flatten [-barriers]", "(if -flatten)");
204+
else if (flatten)
205+
run(barriers ? "flatten -barriers" : "flatten");
192206
run("future");
193207
run(nokeepdc ? "opt_expr" : "opt_expr -keepdc");
194208
run("opt_clean");

0 commit comments

Comments
 (0)