Skip to content

Commit

Permalink
Merge pull request #4228 from povik/synth-inject
Browse files Browse the repository at this point in the history
synth: Introduce `-extra-map` for amending techmap
  • Loading branch information
nakengelhardt authored Mar 11, 2024
2 parents d42c04b + 570a8f1 commit e4f11eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions passes/techmap/techmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,8 @@ struct TechmapPass : public Pass {
log("\n");
log("When a port on a module in the map file has the 'techmap_autopurge' attribute\n");
log("set, and that port is not connected in the instantiation that is mapped, then\n");
log("then a cell port connected only to such wires will be omitted in the mapped\n");
log("version of the circuit.\n");
log("a cell port connected only to such wires will be omitted in the mapped version\n");
log("of the circuit.\n");
log("\n");
log("All wires in the modules from the map file matching the pattern _TECHMAP_*\n");
log("or *._TECHMAP_* are special wires that are used to pass instructions from\n");
Expand Down
25 changes: 22 additions & 3 deletions techlibs/common/synth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ struct SynthPass : public ScriptPass {
log(" read/write collision\" (same result as setting the no_rw_check\n");
log(" attribute on all memories).\n");
log("\n");
log(" -extra-map filename\n");
log(" source extra rules from the given file to complement the default\n");
log(" mapping library in the `techmap` step. this option can be\n");
log(" repeated.\n");
log("\n");
log("The following commands are executed by this synthesis command:\n");
help_script();
Expand All @@ -96,8 +100,8 @@ struct SynthPass : public ScriptPass {

string top_module, fsm_opts, memory_opts, abc;
bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth;

int lut;
std::vector<std::string> techmap_maps;

void clear_flags() override
{
Expand All @@ -115,6 +119,7 @@ struct SynthPass : public ScriptPass {
flowmap = false;
booth = false;
abc = "abc";
techmap_maps.clear();
}

void execute(std::vector<std::string> args, RTLIL::Design *design) override
Expand Down Expand Up @@ -151,7 +156,7 @@ struct SynthPass : public ScriptPass {
flatten = true;
continue;
}
if (args[argidx] == "-lut") {
if (args[argidx] == "-lut" && argidx + 1 < args.size()) {
lut = atoi(args[++argidx].c_str());
continue;
}
Expand Down Expand Up @@ -192,6 +197,10 @@ struct SynthPass : public ScriptPass {
memory_opts += " -no-rw-check";
continue;
}
if (args[argidx] == "-extra-map" && argidx + 1 < args.size()) {
techmap_maps.push_back(args[++argidx]);
continue;
}
break;
}
extra_args(args, argidx, design);
Expand Down Expand Up @@ -261,7 +270,17 @@ struct SynthPass : public ScriptPass {
run("opt -fast -full");
run("memory_map");
run("opt -full");
run("techmap");
if (help_mode) {
run("techmap", " (unless -extra-map)");
run("techmap -map +/techmap.v -map <inject>", " (if -extra-map)");
} else {
std::string techmap_opts;
if (!techmap_maps.empty())
techmap_opts += " -map +/techmap.v";
for (auto fn : techmap_maps)
techmap_opts += stringf(" -map %s", fn.c_str());
run("techmap" + techmap_opts);
}
if (help_mode) {
run("techmap -map +/gate2lut.v", "(if -noabc and -lut)");
run("clean; opt_lut", " (if -noabc and -lut)");
Expand Down

0 comments on commit e4f11eb

Please sign in to comment.