Skip to content

Commit 62c4411

Browse files
committed
Build FfInitVals for the entire module once and use it for every ABC run.
1 parent 2654bd5 commit 62c4411

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

passes/techmap/abc.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct AbcModuleState {
156156
int map_autoidx = 0;
157157
std::vector<gate_t> signal_list;
158158
dict<RTLIL::SigBit, int> signal_map;
159-
FfInitVals initvals;
159+
FfInitVals &initvals;
160160
bool had_init = false;
161161
bool did_run_abc = false;
162162

@@ -171,7 +171,8 @@ struct AbcModuleState {
171171

172172
std::string tempdir_name;
173173

174-
AbcModuleState(const AbcConfig &config) : config(config) {}
174+
AbcModuleState(const AbcConfig &config, FfInitVals &initvals)
175+
: config(config), initvals(initvals) {}
175176

176177
int map_signal(const AbcSigMap &assign_map, RTLIL::SigBit bit, gate_type_t gate_type = G(NONE), int in1 = -1, int in2 = -1, int in3 = -1, int in4 = -1);
177178
void mark_port(const AbcSigMap &assign_map, RTLIL::SigSpec sig);
@@ -777,7 +778,6 @@ struct abc_output_filter
777778
void AbcModuleState::abc_module(RTLIL::Design *design, RTLIL::Module *module, AbcSigMap &assign_map, const std::vector<RTLIL::Cell*> &cells,
778779
bool dff_mode, std::string clk_str)
779780
{
780-
initvals.set(&assign_map, module);
781781
map_autoidx = autoidx++;
782782

783783
if (clk_str != "$")
@@ -2148,6 +2148,11 @@ struct AbcPass : public Pass {
21482148

21492149
AbcSigMap assign_map;
21502150
assign_map.set(mod);
2151+
// Create an FfInitVals and use it for all ABC runs. FfInitVals only cares about
2152+
// wires with the ID::init attribute and we don't add or remove any such wires
2153+
// in this pass.
2154+
FfInitVals initvals;
2155+
initvals.set(&assign_map, mod);
21512156

21522157
for (auto wire : mod->wires())
21532158
if (wire->port_id > 0 || wire->get_bool_attribute(ID::keep))
@@ -2157,7 +2162,7 @@ struct AbcPass : public Pass {
21572162
std::vector<RTLIL::Cell*> cells = mod->selected_cells();
21582163
assign_cell_connection_ports(mod, {&cells}, assign_map);
21592164

2160-
AbcModuleState state(config);
2165+
AbcModuleState state(config, initvals);
21612166
state.abc_module(design, mod, assign_map, cells, dff_mode, clk_str);
21622167
state.extract(assign_map, design, mod);
21632168
state.finish();
@@ -2180,8 +2185,6 @@ struct AbcPass : public Pass {
21802185
dict<RTLIL::Cell*, pool<RTLIL::SigBit>> cell_to_bit, cell_to_bit_up, cell_to_bit_down;
21812186
dict<RTLIL::SigBit, pool<RTLIL::Cell*>> bit_to_cell, bit_to_cell_up, bit_to_cell_down;
21822187

2183-
FfInitVals initvals;
2184-
initvals.set(&assign_map, mod);
21852188
for (auto cell : all_cells)
21862189
{
21872190
clkdomain_t key;
@@ -2321,7 +2324,7 @@ struct AbcPass : public Pass {
23212324
assign_cell_connection_ports(mod, cell_sets, assign_map);
23222325
}
23232326
for (auto &it : assigned_cells) {
2324-
AbcModuleState state(config);
2327+
AbcModuleState state(config, initvals);
23252328
state.clk_polarity = std::get<0>(it.first);
23262329
state.clk_sig = assign_map(std::get<1>(it.first));
23272330
state.en_polarity = std::get<2>(it.first);

0 commit comments

Comments
 (0)