typedef std::map<std::string, std::vector<TechmapWireData>> TechmapWires;
+ bool extern_mode;
+ bool assert_mode;
+ bool flatten_mode;
+
+ TechmapWorker()
+ {
+ extern_mode = false;
+ assert_mode = false;
+ flatten_mode = false;
+ }
+
std::string constmap_tpl_name(SigMap &sigmap, RTLIL::Module *tpl, RTLIL::Cell *cell, bool verbose)
{
std::string constmap_info;
return result;
}
- void techmap_module_worker(RTLIL::Design *design, RTLIL::Module *module, RTLIL::Cell *cell, RTLIL::Module *tpl, bool flatten_mode)
+ void techmap_module_worker(RTLIL::Design *design, RTLIL::Module *module, RTLIL::Cell *cell, RTLIL::Module *tpl)
{
log("Mapping `%s.%s' using `%s'.\n", RTLIL::id2cstr(module->name), RTLIL::id2cstr(cell->name), RTLIL::id2cstr(tpl->name));
}
bool techmap_module(RTLIL::Design *design, RTLIL::Module *module, RTLIL::Design *map, std::set<RTLIL::Cell*> &handled_cells,
- const std::map<RTLIL::IdString, std::set<RTLIL::IdString>> &celltypeMap, bool flatten_mode, bool extern_mode)
+ const std::map<RTLIL::IdString, std::set<RTLIL::IdString>> &celltypeMap)
{
if (!design->selected(module))
return false;
if (!design->selected(module, cell) || handled_cells.count(cell) > 0)
continue;
- if (celltypeMap.count(cell->type) == 0)
+ if (celltypeMap.count(cell->type) == 0) {
+ if (assert_mode && cell->type.back() != '_')
+ log_error("(ASSERT MODE) No matching template cell for type %s found.\n", log_id(cell->type));
continue;
+ }
for (auto &conn : cell->connections())
{
{
log_assert(handled_cells.count(cell) == 0);
log_assert(cell == module->cell(cell->name));
+ bool mapped_cell = false;
for (auto &tpl_name : celltypeMap.at(cell->type))
{
{
if (extern_mode)
{
- log("WARNING: Mapping simplat cell %s.%s (%s) in -extern mode is not supported yet.\n", log_id(module), log_id(cell), log_id(cell->type));
+ log("WARNING: Mapping simplemap cell %s.%s (%s) in -extern mode is not supported yet.\n", log_id(module), log_id(cell), log_id(cell->type));
break;
}
else
module->remove(cell);
cell = NULL;
did_something = true;
+ mapped_cell = true;
break;
}
}
}
else
{
- techmap_module_worker(design, module, cell, tpl, flatten_mode);
+ techmap_module_worker(design, module, cell, tpl);
cell = NULL;
}
did_something = true;
+ mapped_cell = true;
break;
}
+ if (assert_mode && !mapped_cell)
+ log_error("(ASSERT MODE) Failed to map cell %s.%s (%s).\n", log_id(module), log_id(cell), log_id(cell->type));
+
handled_cells.insert(cell);
}
log(" -max_iter <number>\n");
log(" only run the specified number of iterations.\n");
log("\n");
+ log(" -assert\n");
+ log(" this option will cause techmap to exit with an error if it can't map\n");
+ log(" a selected cell. only cell types that end on an underscore are accepted\n");
+ log(" as final cell types by this mode.\n");
+ log("\n");
log(" -D <define>, -I <incdir>\n");
log(" this options are passed as-is to the verilog frontend for loading the\n");
log(" map file. Note that the verilog frontend is also called with the\n");
log_header("Executing TECHMAP pass (map to technology primitives).\n");
log_push();
+ TechmapWorker worker;
+ simplemap_get_mappers(worker.simplemap_mappers);
+
std::vector<std::string> map_files;
std::string verilog_frontend = "verilog -ignore_redef";
- bool extern_mode = false;
int max_iter = -1;
size_t argidx;
verilog_frontend += " -I " + args[++argidx];
continue;
}
+ if (args[argidx] == "-assert") {
+ worker.assert_mode = true;
+ continue;
+ }
if (args[argidx] == "-extern") {
- extern_mode = true;
+ worker.extern_mode = true;
continue;
}
break;
}
extra_args(args, argidx, design);
- TechmapWorker worker;
- simplemap_get_mappers(worker.simplemap_mappers);
-
RTLIL::Design *map = new RTLIL::Design;
if (map_files.empty()) {
FILE *f = fmemopen(stdcells_code, strlen(stdcells_code), "rt");
std::set<RTLIL::Cell*> handled_cells;
while (did_something) {
did_something = false;
- if (worker.techmap_module(design, module, map, handled_cells, celltypeMap, false, extern_mode))
+ if (worker.techmap_module(design, module, map, handled_cells, celltypeMap))
did_something = true;
if (did_something)
module->check();
extra_args(args, 1, design);
TechmapWorker worker;
+ worker.flatten_mode = true;
std::map<RTLIL::IdString, std::set<RTLIL::IdString>> celltypeMap;
for (auto &it : design->modules_)
while (did_something) {
did_something = false;
if (top_mod != NULL) {
- if (worker.techmap_module(design, top_mod, design, handled_cells, celltypeMap, true, false))
+ if (worker.techmap_module(design, top_mod, design, handled_cells, celltypeMap))
did_something = true;
} else {
for (auto mod : design->modules())
- if (worker.techmap_module(design, mod, design, handled_cells, celltypeMap, true, false))
+ if (worker.techmap_module(design, mod, design, handled_cells, celltypeMap))
did_something = true;
}
}