1026 bool add_mode =
false;
1027 bool del_mode =
false;
1028 bool clear_mode =
false;
1029 bool none_mode =
false;
1030 bool list_mode =
false;
1031 bool count_mode =
false;
1032 bool got_module =
false;
1033 bool assert_none =
false;
1034 bool assert_any =
false;
1035 int assert_count = -1;
1036 std::string write_file;
1037 std::string set_name;
1038 std::string sel_str;
1043 for (argidx = 1; argidx <
args.size(); argidx++)
1045 std::string arg =
args[argidx];
1046 if (arg ==
"-add") {
1050 if (arg ==
"-del") {
1054 if (arg ==
"-assert-none") {
1058 if (arg ==
"-assert-any") {
1062 if (arg ==
"-assert-count" && argidx+1 <
args.size()) {
1063 assert_count = atoi(
args[++argidx].c_str());
1066 if (arg ==
"-clear") {
1070 if (arg ==
"-none") {
1074 if (arg ==
"-list") {
1078 if (arg ==
"-write" && argidx+1 <
args.size()) {
1079 write_file =
args[++argidx];
1082 if (arg ==
"-count") {
1086 if (arg ==
"-module" && argidx+1 <
args.size()) {
1088 if (design->
modules_.count(mod_name) == 0)
1094 if (arg ==
"-set" && argidx+1 <
args.size()) {
1098 if (arg.size() > 0 && arg[0] ==
'-')
1101 sel_str +=
" " + arg;
1104 if (clear_mode &&
args.size() != 2)
1105 log_cmd_error(
"Option -clear can not be combined with any other options.\n");
1107 if (none_mode &&
args.size() != 2)
1108 log_cmd_error(
"Option -none can not be combined with any other options.\n");
1110 if (add_mode + del_mode + assert_none + assert_any + (assert_count >= 0) > 1)
1111 log_cmd_error(
"Options -add, -del, -assert-none, -assert-any or -assert-count can not be combined.\n");
1113 if ((list_mode || !write_file.empty() || count_mode) && (add_mode || del_mode || assert_none || assert_any || assert_count >= 0))
1114 log_cmd_error(
"Options -list, -write and -count can not be combined with -add, -del, -assert-none, -assert-any or -assert-count.\n");
1116 if (!set_name.empty() && (list_mode || !write_file.empty() || count_mode || add_mode || del_mode || assert_none || assert_any || assert_count >= 0))
1117 log_cmd_error(
"Option -set can not be combined with -list, -write, -count, -add, -del, -assert-none, -assert-any or -assert-count.\n");
1143 if (list_mode || count_mode || !write_file.empty())
1145 #define LOG_OBJECT(...) { if (list_mode) log(__VA_ARGS__); if (f != NULL) fprintf(f, __VA_ARGS__); total_count++; }
1146 int total_count = 0;
1148 if (!write_file.empty()) {
1149 f = fopen(write_file.c_str(),
"w");
1151 log_error(
"Can't open '%s' for writing: %s\n", write_file.c_str(), strerror(errno));
1157 for (
auto mod_it : design->
modules_)
1162 for (
auto &it : mod_it.second->wires_)
1165 for (
auto &it : mod_it.second->memories)
1168 for (
auto &it : mod_it.second->cells_)
1171 for (
auto &it : mod_it.second->processes)
1177 log(
"%d objects.\n", total_count);
1207 log_error(
"Assertation failed: selection is not empty:%s\n", sel_str.c_str());
1216 log_error(
"Assertation failed: selection is empty:%s\n", sel_str.c_str());
1220 if (assert_count >= 0)
1222 int total_count = 0;
1227 for (
auto mod_it : design->
modules_)
1229 for (
auto &it : mod_it.second->wires_)
1232 for (
auto &it : mod_it.second->memories)
1235 for (
auto &it : mod_it.second->cells_)
1238 for (
auto &it : mod_it.second->processes)
1242 if (assert_count != total_count)
1243 log_error(
"Assertation failed: selection contains %d elements instead of the asserted %d:%s\n",
1244 total_count, assert_count, sel_str.c_str());
1248 if (!set_name.empty())
1264 for (
auto &it2 : it.second)
bool selected_module(RTLIL::IdString mod_name) const
static void select_filter_active_mod(RTLIL::Design *design, RTLIL::Selection &sel)
bool selected_whole_module(RTLIL::IdString mod_name) const
std::vector< RTLIL::Selection > selection_stack
static std::vector< RTLIL::Selection > work_stack
bool selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
std::set< RTLIL::IdString > selected_modules
std::map< RTLIL::IdString, std::set< RTLIL::IdString > > selected_members
void log_error(const char *format,...)
static std::string escape_id(std::string str)
std::map< RTLIL::IdString, RTLIL::Selection > selection_vars
#define log_assert(_assert_expr_)
static void select_stmt(RTLIL::Design *design, std::string arg)
static const char * id2cstr(const RTLIL::IdString &str)
void log_cmd_error(const char *format,...)
std::map< RTLIL::IdString, RTLIL::Module * > modules_
void log(const char *format,...)
static void select_op_diff(RTLIL::Design *design, RTLIL::Selection &lhs, const RTLIL::Selection &rhs)
void optimize(RTLIL::Design *design)
std::string selected_active_module
static void select_op_union(RTLIL::Design *, RTLIL::Selection &lhs, const RTLIL::Selection &rhs)