yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ExtractPass Struct Reference
+ Inheritance diagram for ExtractPass:
+ Collaboration diagram for ExtractPass:

Public Member Functions

 ExtractPass ()
 
virtual void help ()
 
virtual void execute (std::vector< std::string > args, RTLIL::Design *design)
 
pre_post_exec_state_t pre_execute ()
 
void post_execute (pre_post_exec_state_t state)
 
void cmd_log_args (const std::vector< std::string > &args)
 
void cmd_error (const std::vector< std::string > &args, size_t argidx, std::string msg)
 
void extra_args (std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
 
virtual void run_register ()
 

Static Public Member Functions

static void call (RTLIL::Design *design, std::string command)
 
static void call (RTLIL::Design *design, std::vector< std::string > args)
 
static void call_on_selection (RTLIL::Design *design, const RTLIL::Selection &selection, std::string command)
 
static void call_on_selection (RTLIL::Design *design, const RTLIL::Selection &selection, std::vector< std::string > args)
 
static void call_on_module (RTLIL::Design *design, RTLIL::Module *module, std::string command)
 
static void call_on_module (RTLIL::Design *design, RTLIL::Module *module, std::vector< std::string > args)
 
static void init_register ()
 
static void done_register ()
 

Data Fields

std::string pass_name
 
std::string short_help
 
int call_counter
 
int64_t runtime_ns
 
Passnext_queued_pass
 

Detailed Description

Definition at line 353 of file extract.cc.

Constructor & Destructor Documentation

ExtractPass::ExtractPass ( )
inline

Definition at line 354 of file extract.cc.

354 : Pass("extract", "find subcircuits and replace them with cells") { }
Pass(std::string name, std::string short_help="** document me **")
Definition: register.cc:40

Member Function Documentation

void Pass::call ( RTLIL::Design design,
std::string  command 
)
staticinherited

Definition at line 146 of file register.cc.

147 {
148  std::vector<std::string> args;
149 
150  std::string cmd_buf = command;
151  std::string tok = next_token(cmd_buf, " \t\r\n");
152 
153  if (tok.empty() || tok[0] == '#')
154  return;
155 
156  if (tok[0] == '!') {
157  cmd_buf = command.substr(command.find('!') + 1);
158  while (!cmd_buf.empty() && (cmd_buf.back() == ' ' || cmd_buf.back() == '\t' ||
159  cmd_buf.back() == '\r' || cmd_buf.back() == '\n'))
160  cmd_buf.resize(cmd_buf.size()-1);
161  log_header("Shell command: %s\n", cmd_buf.c_str());
162  int retCode = run_command(cmd_buf);
163  if (retCode != 0)
164  log_cmd_error("Shell command returned error code %d.\n", retCode);
165  return;
166  }
167 
168  while (!tok.empty()) {
169  if (tok == "#")
170  break;
171  if (tok.back() == ';') {
172  int num_semikolon = 0;
173  while (!tok.empty() && tok.back() == ';')
174  tok.resize(tok.size()-1), num_semikolon++;
175  if (!tok.empty())
176  args.push_back(tok);
177  call(design, args);
178  args.clear();
179  if (num_semikolon == 2)
180  call(design, "clean");
181  if (num_semikolon == 3)
182  call(design, "clean -purge");
183  } else
184  args.push_back(tok);
185  tok = next_token(cmd_buf, " \t\r\n");
186  }
187 
188  call(design, args);
189 }
static std::string next_token(bool pass_newline=false)
Definition: preproc.cc:96
void log_header(const char *format,...)
Definition: log.cc:188
int run_command(const std::string &command, std::function< void(const std::string &)> process_line)
Definition: yosys.cc:195
void log_cmd_error(const char *format,...)
Definition: log.cc:211
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::call ( RTLIL::Design design,
std::vector< std::string >  args 
)
staticinherited

Definition at line 191 of file register.cc.

192 {
193  if (args.size() == 0 || args[0][0] == '#')
194  return;
195 
196  if (echo_mode) {
197  log("%s", create_prompt(design, 0));
198  for (size_t i = 0; i < args.size(); i++)
199  log("%s%s", i ? " " : "", args[i].c_str());
200  log("\n");
201  }
202 
203  if (pass_register.count(args[0]) == 0)
204  log_cmd_error("No such command: %s (type 'help' for a command overview)\n", args[0].c_str());
205 
206  size_t orig_sel_stack_pos = design->selection_stack.size();
207  auto state = pass_register[args[0]]->pre_execute();
208  pass_register[args[0]]->execute(args, design);
209  pass_register[args[0]]->post_execute(state);
210  while (design->selection_stack.size() > orig_sel_stack_pos)
211  design->selection_stack.pop_back();
212 
213  design->check();
214 }
bool echo_mode
Definition: register.cc:30
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
const char * create_prompt(RTLIL::Design *design, int recursion_counter)
Definition: yosys.cc:400
void check()
Definition: rtlil.cc:357
void log_cmd_error(const char *format,...)
Definition: log.cc:211
void log(const char *format,...)
Definition: log.cc:180
std::map< std::string, Pass * > pass_register
Definition: register.cc:35

+ Here is the call graph for this function:

void Pass::call_on_module ( RTLIL::Design design,
RTLIL::Module module,
std::string  command 
)
staticinherited

Definition at line 240 of file register.cc.

241 {
242  std::string backup_selected_active_module = design->selected_active_module;
243  design->selected_active_module = module->name.str();
244  design->selection_stack.push_back(RTLIL::Selection(false));
245  design->selection_stack.back().select(module);
246 
247  Pass::call(design, command);
248 
249  design->selection_stack.pop_back();
250  design->selected_active_module = backup_selected_active_module;
251 }
std::string str() const
Definition: rtlil.h:182
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
RTLIL::IdString name
Definition: rtlil.h:599
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::call_on_module ( RTLIL::Design design,
RTLIL::Module module,
std::vector< std::string >  args 
)
staticinherited

Definition at line 253 of file register.cc.

254 {
255  std::string backup_selected_active_module = design->selected_active_module;
256  design->selected_active_module = module->name.str();
257  design->selection_stack.push_back(RTLIL::Selection(false));
258  design->selection_stack.back().select(module);
259 
260  Pass::call(design, args);
261 
262  design->selection_stack.pop_back();
263  design->selected_active_module = backup_selected_active_module;
264 }
std::string str() const
Definition: rtlil.h:182
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
RTLIL::IdString name
Definition: rtlil.h:599
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

void Pass::call_on_selection ( RTLIL::Design design,
const RTLIL::Selection selection,
std::string  command 
)
staticinherited

Definition at line 216 of file register.cc.

217 {
218  std::string backup_selected_active_module = design->selected_active_module;
219  design->selected_active_module.clear();
220  design->selection_stack.push_back(selection);
221 
222  Pass::call(design, command);
223 
224  design->selection_stack.pop_back();
225  design->selected_active_module = backup_selected_active_module;
226 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

void Pass::call_on_selection ( RTLIL::Design design,
const RTLIL::Selection selection,
std::vector< std::string >  args 
)
staticinherited

Definition at line 228 of file register.cc.

229 {
230  std::string backup_selected_active_module = design->selected_active_module;
231  design->selected_active_module.clear();
232  design->selection_stack.push_back(selection);
233 
234  Pass::call(design, args);
235 
236  design->selection_stack.pop_back();
237  design->selected_active_module = backup_selected_active_module;
238 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::string selected_active_module
Definition: rtlil.h:511
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146

+ Here is the call graph for this function:

void Pass::cmd_error ( const std::vector< std::string > &  args,
size_t  argidx,
std::string  msg 
)
inherited

Definition at line 110 of file register.cc.

111 {
112  std::string command_text;
113  int error_pos = 0;
114 
115  for (size_t i = 0; i < args.size(); i++) {
116  if (i < argidx)
117  error_pos += args[i].size() + 1;
118  command_text = command_text + (command_text.empty() ? "" : " ") + args[i];
119  }
120 
121  log("\nSyntax error in command `%s':\n", command_text.c_str());
122  help();
123 
124  log_cmd_error("Command syntax error: %s\n> %s\n> %*s^\n",
125  msg.c_str(), command_text.c_str(), error_pos, "");
126 }
virtual void help()
Definition: register.cc:93
void log_cmd_error(const char *format,...)
Definition: log.cc:211
void log(const char *format,...)
Definition: log.cc:180

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::cmd_log_args ( const std::vector< std::string > &  args)
inherited

Definition at line 100 of file register.cc.

101 {
102  if (args.size() <= 1)
103  return;
104  log("Full command line:");
105  for (size_t i = 0; i < args.size(); i++)
106  log(" %s", args[i].c_str());
107  log("\n");
108 }
void log(const char *format,...)
Definition: log.cc:180

+ Here is the call graph for this function:

void Pass::done_register ( )
staticinherited

Definition at line 62 of file register.cc.

63 {
64  frontend_register.clear();
65  pass_register.clear();
66  backend_register.clear();
68 }
std::map< std::string, Frontend * > frontend_register
Definition: register.cc:34
Pass * first_queued_pass
Definition: register.cc:31
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL
std::map< std::string, Pass * > pass_register
Definition: register.cc:35
std::map< std::string, Backend * > backend_register
Definition: register.cc:36

+ Here is the caller graph for this function:

virtual void ExtractPass::execute ( std::vector< std::string >  args,
RTLIL::Design design 
)
inlinevirtual

Implements Pass.

Definition at line 443 of file extract.cc.

444  {
445  log_header("Executing EXTRACT pass (map subcircuits to cells).\n");
446  log_push();
447 
448  SubCircuitSolver solver;
449 
450  std::vector<std::string> map_filenames;
451  std::string mine_outfile;
452  bool constports = false;
453  bool nodefaultswaps = false;
454 
455  bool mine_mode = false;
456  int mine_cells_min = 3;
457  int mine_cells_max = 5;
458  int mine_min_freq = 10;
459  int mine_limit_mod = -1;
460  int mine_max_fanout = -1;
461  std::set<std::pair<RTLIL::IdString, RTLIL::IdString>> mine_split;
462 
463  size_t argidx;
464  for (argidx = 1; argidx < args.size(); argidx++) {
465  if (args[argidx] == "-map" && argidx+1 < args.size()) {
466  if (mine_mode)
467  log_cmd_error("You cannot mix -map and -mine.\n");
468  map_filenames.push_back(args[++argidx]);
469  continue;
470  }
471  if (args[argidx] == "-mine" && argidx+1 < args.size()) {
472  if (!map_filenames.empty())
473  log_cmd_error("You cannot mix -map and -mine.\n");
474  mine_outfile = args[++argidx];
475  mine_mode = true;
476  continue;
477  }
478  if (args[argidx] == "-mine_cells_span" && argidx+2 < args.size()) {
479  mine_cells_min = atoi(args[++argidx].c_str());
480  mine_cells_max = atoi(args[++argidx].c_str());
481  continue;
482  }
483  if (args[argidx] == "-mine_min_freq" && argidx+1 < args.size()) {
484  mine_min_freq = atoi(args[++argidx].c_str());
485  continue;
486  }
487  if (args[argidx] == "-mine_limit_matches_per_module" && argidx+1 < args.size()) {
488  mine_limit_mod = atoi(args[++argidx].c_str());
489  continue;
490  }
491  if (args[argidx] == "-mine_split" && argidx+2 < args.size()) {
492  mine_split.insert(std::pair<RTLIL::IdString, RTLIL::IdString>(RTLIL::escape_id(args[argidx+1]), RTLIL::escape_id(args[argidx+2])));
493  argidx += 2;
494  continue;
495  }
496  if (args[argidx] == "-mine_max_fanout" && argidx+1 < args.size()) {
497  mine_max_fanout = atoi(args[++argidx].c_str());
498  continue;
499  }
500  if (args[argidx] == "-verbose") {
501  solver.setVerbose();
502  continue;
503  }
504  if (args[argidx] == "-constports") {
505  constports = true;
506  continue;
507  }
508  if (args[argidx] == "-nodefaultswaps") {
509  nodefaultswaps = true;
510  continue;
511  }
512  if (args[argidx] == "-compat" && argidx+2 < args.size()) {
513  std::string needle_type = RTLIL::escape_id(args[++argidx]);
514  std::string haystack_type = RTLIL::escape_id(args[++argidx]);
515  solver.addCompatibleTypes(needle_type, haystack_type);
516  continue;
517  }
518  if (args[argidx] == "-swap" && argidx+2 < args.size()) {
519  std::string type = RTLIL::escape_id(args[++argidx]);
520  std::set<std::string> ports;
521  std::string ports_str = args[++argidx], p;
522  while (!(p = next_token(ports_str, ",\t\r\n ")).empty())
523  ports.insert(RTLIL::escape_id(p));
524  solver.addSwappablePorts(type, ports);
525  continue;
526  }
527  if (args[argidx] == "-perm" && argidx+3 < args.size()) {
528  std::string type = RTLIL::escape_id(args[++argidx]);
529  std::vector<std::string> map_left, map_right;
530  std::string left_str = args[++argidx];
531  std::string right_str = args[++argidx], p;
532  while (!(p = next_token(left_str, ",\t\r\n ")).empty())
533  map_left.push_back(RTLIL::escape_id(p));
534  while (!(p = next_token(right_str, ",\t\r\n ")).empty())
535  map_right.push_back(RTLIL::escape_id(p));
536  if (map_left.size() != map_right.size())
537  log_cmd_error("Arguments to -perm are not a valid permutation!\n");
538  std::map<std::string, std::string> map;
539  for (size_t i = 0; i < map_left.size(); i++)
540  map[map_left[i]] = map_right[i];
541  std::sort(map_left.begin(), map_left.end());
542  std::sort(map_right.begin(), map_right.end());
543  if (map_left != map_right)
544  log_cmd_error("Arguments to -perm are not a valid permutation!\n");
545  solver.addSwappablePortsPermutation(type, map);
546  continue;
547  }
548  if (args[argidx] == "-cell_attr" && argidx+1 < args.size()) {
549  solver.cell_attr.insert(RTLIL::escape_id(args[++argidx]));
550  continue;
551  }
552  if (args[argidx] == "-wire_attr" && argidx+1 < args.size()) {
553  solver.wire_attr.insert(RTLIL::escape_id(args[++argidx]));
554  continue;
555  }
556  if (args[argidx] == "-ignore_parameters") {
557  solver.ignore_parameters = true;
558  continue;
559  }
560  if (args[argidx] == "-ignore_param" && argidx+2 < args.size()) {
561  solver.ignored_parameters.insert(std::pair<RTLIL::IdString, RTLIL::IdString>(RTLIL::escape_id(args[argidx+1]), RTLIL::escape_id(args[argidx+2])));
562  argidx += 2;
563  continue;
564  }
565  break;
566  }
567  extra_args(args, argidx, design);
568 
569  if (!nodefaultswaps) {
570  solver.addSwappablePorts("$and", "\\A", "\\B");
571  solver.addSwappablePorts("$or", "\\A", "\\B");
572  solver.addSwappablePorts("$xor", "\\A", "\\B");
573  solver.addSwappablePorts("$xnor", "\\A", "\\B");
574  solver.addSwappablePorts("$eq", "\\A", "\\B");
575  solver.addSwappablePorts("$ne", "\\A", "\\B");
576  solver.addSwappablePorts("$eqx", "\\A", "\\B");
577  solver.addSwappablePorts("$nex", "\\A", "\\B");
578  solver.addSwappablePorts("$add", "\\A", "\\B");
579  solver.addSwappablePorts("$mul", "\\A", "\\B");
580  solver.addSwappablePorts("$logic_and", "\\A", "\\B");
581  solver.addSwappablePorts("$logic_or", "\\A", "\\B");
582  solver.addSwappablePorts("$_AND_", "\\A", "\\B");
583  solver.addSwappablePorts("$_OR_", "\\A", "\\B");
584  solver.addSwappablePorts("$_XOR_", "\\A", "\\B");
585  }
586 
587  if (map_filenames.empty() && mine_outfile.empty())
588  log_cmd_error("Missing option -map <verilog_or_ilang_file> or -mine <output_ilang_file>.\n");
589 
590  RTLIL::Design *map = NULL;
591 
592  if (!mine_mode)
593  {
594  map = new RTLIL::Design;
595  for (auto &filename : map_filenames)
596  {
597  if (filename.substr(0, 1) == "%")
598  {
599  if (!saved_designs.count(filename.substr(1))) {
600  delete map;
601  log_cmd_error("Can't saved design `%s'.\n", filename.c_str()+1);
602  }
603  for (auto mod : saved_designs.at(filename.substr(1))->modules())
604  if (!map->has(mod->name))
605  map->add(mod->clone());
606  }
607  else
608  {
609  std::ifstream f;
610  f.open(filename.c_str());
611  if (f.fail()) {
612  delete map;
613  log_cmd_error("Can't open map file `%s'.\n", filename.c_str());
614  }
615  Frontend::frontend_call(map, &f, filename, (filename.size() > 3 && filename.substr(filename.size()-3) == ".il") ? "ilang" : "verilog");
616  f.close();
617 
618  if (filename.size() <= 3 || filename.substr(filename.size()-3) != ".il") {
619  Pass::call(map, "proc");
620  Pass::call(map, "opt_clean");
621  }
622  }
623  }
624  }
625 
626  std::map<std::string, RTLIL::Module*> needle_map, haystack_map;
627  std::vector<RTLIL::Module*> needle_list;
628 
629  log_header("Creating graphs for SubCircuit library.\n");
630 
631  if (!mine_mode)
632  for (auto &mod_it : map->modules_) {
633  SubCircuit::Graph mod_graph;
634  std::string graph_name = "needle_" + RTLIL::unescape_id(mod_it.first);
635  log("Creating needle graph %s.\n", graph_name.c_str());
636  if (module2graph(mod_graph, mod_it.second, constports)) {
637  solver.addGraph(graph_name, mod_graph);
638  needle_map[graph_name] = mod_it.second;
639  needle_list.push_back(mod_it.second);
640  }
641  }
642 
643  for (auto &mod_it : design->modules_) {
644  SubCircuit::Graph mod_graph;
645  std::string graph_name = "haystack_" + RTLIL::unescape_id(mod_it.first);
646  log("Creating haystack graph %s.\n", graph_name.c_str());
647  if (module2graph(mod_graph, mod_it.second, constports, design, mine_mode ? mine_max_fanout : -1, mine_mode ? &mine_split : NULL)) {
648  solver.addGraph(graph_name, mod_graph);
649  haystack_map[graph_name] = mod_it.second;
650  }
651  }
652 
653  if (!mine_mode)
654  {
655  std::vector<SubCircuit::Solver::Result> results;
656  log_header("Running solver from SubCircuit library.\n");
657 
658  std::sort(needle_list.begin(), needle_list.end(), compareSortNeedleList);
659 
660  for (auto needle : needle_list)
661  for (auto &haystack_it : haystack_map) {
662  log("Solving for %s in %s.\n", ("needle_" + RTLIL::unescape_id(needle->name)).c_str(), haystack_it.first.c_str());
663  solver.solve(results, "needle_" + RTLIL::unescape_id(needle->name), haystack_it.first, false);
664  }
665  log("Found %d matches.\n", GetSize(results));
666 
667  if (results.size() > 0)
668  {
669  log_header("Substitute SubCircuits with cells.\n");
670 
671  for (int i = 0; i < int(results.size()); i++) {
672  auto &result = results[i];
673  log("\nMatch #%d: (%s in %s)\n", i, result.needleGraphId.c_str(), result.haystackGraphId.c_str());
674  for (const auto &it : result.mappings) {
675  log(" %s -> %s", it.first.c_str(), it.second.haystackNodeId.c_str());
676  for (const auto & it2 : it.second.portMapping)
677  log(" %s:%s", it2.first.c_str(), it2.second.c_str());
678  log("\n");
679  }
680  RTLIL::Cell *new_cell = replace(needle_map.at(result.needleGraphId), haystack_map.at(result.haystackGraphId), result);
681  design->select(haystack_map.at(result.haystackGraphId), new_cell);
682  log(" new cell: %s\n", id2cstr(new_cell->name));
683  }
684  }
685  }
686  else
687  {
688  std::vector<SubCircuit::Solver::MineResult> results;
689 
690  log_header("Running miner from SubCircuit library.\n");
691  solver.mine(results, mine_cells_min, mine_cells_max, mine_min_freq, mine_limit_mod);
692 
693  map = new RTLIL::Design;
694 
695  int needleCounter = 0;
696  for (auto &result: results)
697  {
698  log("\nFrequent SubCircuit with %d nodes and %d matches:\n", int(result.nodes.size()), result.totalMatchesAfterLimits);
699  log(" primary match in %s:", id2cstr(haystack_map.at(result.graphId)->name));
700  for (auto &node : result.nodes)
701  log(" %s", RTLIL::unescape_id(node.nodeId).c_str());
702  log("\n");
703  for (auto &it : result.matchesPerGraph)
704  log(" matches in %s: %d\n", id2cstr(haystack_map.at(it.first)->name), it.second);
705 
706  RTLIL::Module *mod = haystack_map.at(result.graphId);
707  std::set<RTLIL::Cell*> cells;
708  std::set<RTLIL::Wire*> wires;
709 
710  SigMap sigmap(mod);
711 
712  for (auto &node : result.nodes)
713  cells.insert((RTLIL::Cell*)node.userData);
714 
715  for (auto cell : cells)
716  for (auto &conn : cell->connections()) {
717  RTLIL::SigSpec sig = sigmap(conn.second);
718  for (auto &chunk : sig.chunks())
719  if (chunk.wire != NULL)
720  wires.insert(chunk.wire);
721  }
722 
723  RTLIL::Module *newMod = new RTLIL::Module;
724  newMod->name = stringf("\\needle%05d_%s_%dx", needleCounter++, id2cstr(haystack_map.at(result.graphId)->name), result.totalMatchesAfterLimits);
725  map->add(newMod);
726 
727  for (auto wire : wires) {
728  RTLIL::Wire *newWire = newMod->addWire(wire->name, wire->width);
729  newWire->port_input = true;
730  newWire->port_output = true;
731  }
732 
733  newMod->fixup_ports();
734 
735  for (auto cell : cells) {
736  RTLIL::Cell *newCell = newMod->addCell(cell->name, cell->type);
737  newCell->parameters = cell->parameters;
738  for (auto &conn : cell->connections()) {
739  std::vector<RTLIL::SigChunk> chunks = sigmap(conn.second);
740  for (auto &chunk : chunks)
741  if (chunk.wire != NULL)
742  chunk.wire = newMod->wires_.at(chunk.wire->name);
743  newCell->setPort(conn.first, chunks);
744  }
745  }
746  }
747 
748  std::ofstream f;
749  f.open(mine_outfile.c_str(), std::ofstream::trunc);
750  if (f.fail())
751  log_error("Can't open output file `%s'.\n", mine_outfile.c_str());
752  Backend::backend_call(map, &f, mine_outfile, "ilang");
753  f.close();
754  }
755 
756  delete map;
757  log_pop();
758  }
static std::string next_token(bool pass_newline=false)
Definition: preproc.cc:96
std::set< RTLIL::IdString > wire_attr
Definition: extract.cc:39
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
RTLIL::Cell * addCell(RTLIL::IdString name, RTLIL::IdString type)
Definition: rtlil.cc:1353
void add(RTLIL::Module *module)
Definition: rtlil.cc:259
std::set< RTLIL::IdString > cell_attr
Definition: extract.cc:39
void log_header(const char *format,...)
Definition: log.cc:188
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
Definition: rtlil.h:595
static std::string unescape_id(std::string str)
Definition: rtlil.h:257
static void frontend_call(RTLIL::Design *design, std::istream *f, std::string filename, std::string command)
Definition: register.cc:375
RTLIL::IdString name
Definition: rtlil.h:853
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal)
Definition: rtlil.cc:1789
bool port_input
Definition: rtlil.h:827
void addSwappablePorts(std::string needleTypeId, std::string portId1, std::string portId2, std::string portId3=std::string(), std::string portId4=std::string())
Definition: subcircuit.cc:1647
void log_error(const char *format,...)
Definition: log.cc:204
std::map< RTLIL::IdString, RTLIL::Const > parameters
Definition: rtlil.h:856
void log_pop()
Definition: log.cc:237
void select(T1 *module, T2 *member)
Definition: rtlil.h:559
bool compareSortNeedleList(RTLIL::Module *left, RTLIL::Module *right)
Definition: extract.cc:341
static std::string escape_id(std::string str)
Definition: rtlil.h:251
bool port_output
Definition: rtlil.h:827
void solve(std::vector< Result > &results, std::string needleGraphId, std::string haystackGraphId, bool allowOverlap=true, int maxSolutions=-1)
Definition: subcircuit.cc:1668
std::map< std::string, RTLIL::Design * > saved_designs
Definition: design.cc:27
static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::string command)
Definition: register.cc:479
void addGraph(std::string graphId, const Graph &graph)
Definition: subcircuit.cc:1632
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
void fixup_ports()
Definition: rtlil.cc:1312
RTLIL::Wire * addWire(RTLIL::IdString name, int width=1)
Definition: rtlil.cc:1331
RTLIL::IdString name
Definition: rtlil.h:599
void addSwappablePortsPermutation(std::string needleTypeId, std::map< std::string, std::string > portMapping)
Definition: subcircuit.cc:1663
void mine(std::vector< MineResult > &results, int minNodes, int maxNodes, int minMatches, int limitMatchesPerGraph=-1)
Definition: subcircuit.cc:1680
static const char * id2cstr(const RTLIL::IdString &str)
Definition: rtlil.h:267
void log_cmd_error(const char *format,...)
Definition: log.cc:211
bool module2graph(SubCircuit::Graph &graph, RTLIL::Module *mod, bool constports, RTLIL::Design *sel=NULL, int max_fanout=-1, std::set< std::pair< RTLIL::IdString, RTLIL::IdString >> *split=NULL)
Definition: extract.cc:152
std::set< std::pair< RTLIL::IdString, RTLIL::IdString > > ignored_parameters
Definition: extract.cc:38
bool has(RTLIL::IdString id) const
Definition: rtlil.h:519
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
#define NULL
void log(const char *format,...)
Definition: log.cc:180
RTLIL::Cell * replace(RTLIL::Module *needle, RTLIL::Module *haystack, SubCircuit::Solver::Result &match)
Definition: extract.cc:294
void log_push()
Definition: log.cc:232
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
Definition: register.cc:128
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146
void addCompatibleTypes(std::string needleTypeId, std::string haystackTypeId)
Definition: subcircuit.cc:1637
const std::vector< RTLIL::SigChunk > & chunks() const
Definition: rtlil.h:1016
bool ignore_parameters
Definition: extract.cc:37

+ Here is the call graph for this function:

void Pass::extra_args ( std::vector< std::string >  args,
size_t  argidx,
RTLIL::Design design,
bool  select = true 
)
inherited

Definition at line 128 of file register.cc.

129 {
130  for (; argidx < args.size(); argidx++)
131  {
132  std::string arg = args[argidx];
133 
134  if (arg.substr(0, 1) == "-")
135  cmd_error(args, argidx, "Unknown option or option in arguments.");
136 
137  if (!select)
138  cmd_error(args, argidx, "Extra argument.");
139 
140  handle_extra_select_args(this, args, argidx, args.size(), design);
141  break;
142  }
143  // cmd_log_args(args);
144 }
void cmd_error(const std::vector< std::string > &args, size_t argidx, std::string msg)
Definition: register.cc:110
void handle_extra_select_args(Pass *pass, std::vector< std::string > args, size_t argidx, size_t args_size, RTLIL::Design *design)
Definition: select.cc:803

+ Here is the call graph for this function:

virtual void ExtractPass::help ( )
inlinevirtual

Reimplemented from Pass.

Definition at line 355 of file extract.cc.

356  {
357  // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
358  log("\n");
359  log(" extract -map <map_file> [options] [selection]\n");
360  log(" extract -mine <out_file> [options] [selection]\n");
361  log("\n");
362  log("This pass looks for subcircuits that are isomorphic to any of the modules\n");
363  log("in the given map file and replaces them with instances of this modules. The\n");
364  log("map file can be a verilog source file (*.v) or an ilang file (*.il).\n");
365  log("\n");
366  log(" -map <map_file>\n");
367  log(" use the modules in this file as reference. This option can be used\n");
368  log(" multiple times.\n");
369  log("\n");
370  log(" -map %%<design-name>\n");
371  log(" use the modules in this in-memory design as reference. This option can\n");
372  log(" be used multiple times.\n");
373  log("\n");
374  log(" -verbose\n");
375  log(" print debug output while analyzing\n");
376  log("\n");
377  log(" -constports\n");
378  log(" also find instances with constant drivers. this may be much\n");
379  log(" slower than the normal operation.\n");
380  log("\n");
381  log(" -nodefaultswaps\n");
382  log(" normally builtin port swapping rules for internal cells are used per\n");
383  log(" default. This turns that off, so e.g. 'a^b' does not match 'b^a'\n");
384  log(" when this option is used.\n");
385  log("\n");
386  log(" -compat <needle_type> <haystack_type>\n");
387  log(" Per default, the cells in the map file (needle) must have the\n");
388  log(" type as the cells in the active design (haystack). This option\n");
389  log(" can be used to register additional pairs of types that should\n");
390  log(" match. This option can be used multiple times.\n");
391  log("\n");
392  log(" -swap <needle_type> <port1>,<port2>[,...]\n");
393  log(" Register a set of swapable ports for a needle cell type.\n");
394  log(" This option can be used multiple times.\n");
395  log("\n");
396  log(" -perm <needle_type> <port1>,<port2>[,...] <portA>,<portB>[,...]\n");
397  log(" Register a valid permutation of swapable ports for a needle\n");
398  log(" cell type. This option can be used multiple times.\n");
399  log("\n");
400  log(" -cell_attr <attribute_name>\n");
401  log(" Attributes on cells with the given name must match.\n");
402  log("\n");
403  log(" -wire_attr <attribute_name>\n");
404  log(" Attributes on wires with the given name must match.\n");
405  log("\n");
406  log(" -ignore_parameters\n");
407  log(" Do not use parameters when matching cells.\n");
408  log("\n");
409  log(" -ignore_param <cell_type> <parameter_name>\n");
410  log(" Do not use this parameter when matching cells.\n");
411  log("\n");
412  log("This pass does not operate on modules with uprocessed processes in it.\n");
413  log("(I.e. the 'proc' pass should be used first to convert processes to netlists.)\n");
414  log("\n");
415  log("This pass can also be used for mining for frequent subcircuits. In this mode\n");
416  log("the following options are to be used instead of the -map option.\n");
417  log("\n");
418  log(" -mine <out_file>\n");
419  log(" mine for frequent subcircuits and write them to the given ilang file\n");
420  log("\n");
421  log(" -mine_cells_span <min> <max>\n");
422  log(" only mine for subcircuits with the specified number of cells\n");
423  log(" default value: 3 5\n");
424  log("\n");
425  log(" -mine_min_freq <num>\n");
426  log(" only mine for subcircuits with at least the specified number of matches\n");
427  log(" default value: 10\n");
428  log("\n");
429  log(" -mine_limit_matches_per_module <num>\n");
430  log(" when calculating the number of matches for a subcircuit, don't count\n");
431  log(" more than the specified number of matches per module\n");
432  log("\n");
433  log(" -mine_max_fanout <num>\n");
434  log(" don't consider internal signals with more than <num> connections\n");
435  log("\n");
436  log("The modules in the map file may have the attribute 'extract_order' set to an\n");
437  log("integer value. Then this value is used to determine the order in which the pass\n");
438  log("tries to map the modules to the design (ascending, default value is 0).\n");
439  log("\n");
440  log("See 'help techmap' for a pass that does the opposite thing.\n");
441  log("\n");
442  }
void log(const char *format,...)
Definition: log.cc:180

+ Here is the call graph for this function:

void Pass::init_register ( )
staticinherited

Definition at line 54 of file register.cc.

55 {
56  while (first_queued_pass) {
59  }
60 }
Pass * first_queued_pass
Definition: register.cc:31
Pass * next_queued_pass
Definition: register.h:60
virtual void run_register()
Definition: register.cc:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::post_execute ( Pass::pre_post_exec_state_t  state)
inherited

Definition at line 84 of file register.cc.

85 {
86  int64_t time_ns = PerformanceTimer::query() - state.begin_ns;
87  runtime_ns += time_ns;
88  current_pass = state.parent_pass;
89  if (current_pass)
90  current_pass->runtime_ns -= time_ns;
91 }
static int64_t query()
Definition: log.h:151
int64_t runtime_ns
Definition: register.h:37
Pass * current_pass
Definition: register.cc:32
Pass * parent_pass
Definition: register.h:40
int64_t begin_ns
Definition: register.h:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Pass::pre_post_exec_state_t Pass::pre_execute ( )
inherited

Definition at line 74 of file register.cc.

75 {
76  pre_post_exec_state_t state;
77  call_counter++;
78  state.begin_ns = PerformanceTimer::query();
79  state.parent_pass = current_pass;
80  current_pass = this;
81  return state;
82 }
static int64_t query()
Definition: log.h:151
Pass * current_pass
Definition: register.cc:32
int call_counter
Definition: register.h:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Pass::run_register ( )
virtualinherited

Reimplemented in Backend, and Frontend.

Definition at line 48 of file register.cc.

49 {
50  log_assert(pass_register.count(pass_name) == 0);
51  pass_register[pass_name] = this;
52 }
std::string pass_name
Definition: register.h:29
#define log_assert(_assert_expr_)
Definition: log.h:85
std::map< std::string, Pass * > pass_register
Definition: register.cc:35

+ Here is the caller graph for this function:

Field Documentation

int Pass::call_counter
inherited

Definition at line 36 of file register.h.

Pass* Pass::next_queued_pass
inherited

Definition at line 60 of file register.h.

std::string Pass::pass_name
inherited

Definition at line 29 of file register.h.

int64_t Pass::runtime_ns
inherited

Definition at line 37 of file register.h.

std::string Pass::short_help
inherited

Definition at line 29 of file register.h.


The documentation for this struct was generated from the following file: