Skip to content

synth: Introduce -extra-map for amending techmap #4228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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