if (top_module_name.empty())
for (auto & mod_it:design->modules_)
if (mod_it.second->get_bool_attribute("\\top"))
- top_module_name = mod_it.first;
+ top_module_name = mod_it.first.str();
fprintf(f, "# Generated by %s\n", yosys_version_str);
if (top_module_name.empty())
for (auto & mod_it:design->modules_)
if (mod_it.second->get_bool_attribute("\\top"))
- top_module_name = mod_it.first;
+ top_module_name = mod_it.first.str();
fprintf(f, "; Generated by %s\n", yosys_version_str);
fprintf(f, "; %s developed and maintained by Clifford Wolf <clifford@clifford.at>\n", yosys_version_str);
if (top_module_name.empty())
for (auto & mod_it:design->modules_)
if (mod_it.second->get_bool_attribute("\\top"))
- top_module_name = mod_it.first;
+ top_module_name = mod_it.first.str();
for (auto module_it : design->modules_)
{
continue;
if (top_module_name.empty())
- top_module_name = module->name;
+ top_module_name = module->name.str();
if (module->processes.size() != 0)
log_error("Found unmapped processes in module %s: unmapped processes are not supported in EDIF backend!\n", RTLIL::id2cstr(module->name));
if (top_module_name.empty())
for (auto & mod_it:design->modules_)
if (mod_it.second->get_bool_attribute("\\top"))
- top_module_name = mod_it.first;
+ top_module_name = mod_it.first.str();
fprintf(f, "* SPICE netlist generated by %s\n", yosys_version_str);
fprintf(f, "\n");
const char *log_id(RTLIL::IdString str)
{
- const char *p = str;
+ const char *p = str.c_str();
log_assert(RTLIL::IdString::global_refcount_storage_[str.index_] > 1);
if (p[0] == '\\' && p[1] != '$' && p[1] != 0)
return p+1;
void Pass::call_on_module(RTLIL::Design *design, RTLIL::Module *module, std::string command)
{
std::string backup_selected_active_module = design->selected_active_module;
- design->selected_active_module = module->name;
+ design->selected_active_module = module->name.str();
design->selection_stack.push_back(RTLIL::Selection(false));
design->selection_stack.back().select(module);
void Pass::call_on_module(RTLIL::Design *design, RTLIL::Module *module, std::vector<std::string> args)
{
std::string backup_selected_active_module = design->selected_active_module;
- design->selected_active_module = module->name;
+ design->selected_active_module = module->name.str();
design->selection_stack.push_back(RTLIL::Selection(false));
design->selection_stack.back().select(module);
for (auto &it : modules_) {
log_assert(this == it.second->design);
log_assert(it.first == it.second->name);
- log_assert(it.first.size() > 0 && (it.first[0] == '\\' || it.first[0] == '$'));
+ log_assert(!it.first.empty());
it.second->check();
}
#endif
void check()
{
- if (cell->type[0] != '$' || cell->type.substr(0, 3) == "$__" || cell->type.substr(0, 8) == "$paramod" ||
+ if (cell->type.substr(0, 1) != "$" || cell->type.substr(0, 3) == "$__" || cell->type.substr(0, 8) == "$paramod" ||
cell->type.substr(0, 9) == "$verific$" || cell->type.substr(0, 7) == "$array:" || cell->type.substr(0, 8) == "$extern:")
return;
for (auto &it : wires_) {
log_assert(this == it.second->module);
log_assert(it.first == it.second->name);
- log_assert(it.first.size() > 0 && (it.first[0] == '\\' || it.first[0] == '$'));
+ log_assert(!it.first.empty());
log_assert(it.second->width >= 0);
log_assert(it.second->port_id >= 0);
for (auto &it2 : it.second->attributes) {
- log_assert(it2.first.size() > 0 && (it2.first[0] == '\\' || it2.first[0] == '$'));
+ log_assert(!it2.first.empty());
}
}
for (auto &it : memories) {
log_assert(it.first == it.second->name);
- log_assert(it.first.size() > 0 && (it.first[0] == '\\' || it.first[0] == '$'));
+ log_assert(!it.first.empty());
log_assert(it.second->width >= 0);
log_assert(it.second->size >= 0);
for (auto &it2 : it.second->attributes) {
- log_assert(it2.first.size() > 0 && (it2.first[0] == '\\' || it2.first[0] == '$'));
+ log_assert(!it2.first.empty());
}
}
for (auto &it : cells_) {
log_assert(this == it.second->module);
log_assert(it.first == it.second->name);
- log_assert(it.first.size() > 0 && (it.first[0] == '\\' || it.first[0] == '$'));
- log_assert(it.second->type.size() > 0 && (it.second->type[0] == '\\' || it.second->type[0] == '$'));
+ log_assert(!it.first.empty());
+ log_assert(!it.second->type.empty());
for (auto &it2 : it.second->connections()) {
- log_assert(it2.first.size() > 0 && (it2.first[0] == '\\' || it2.first[0] == '$'));
+ log_assert(!it2.first.empty());
it2.second.check();
}
for (auto &it2 : it.second->attributes) {
- log_assert(it2.first.size() > 0 && (it2.first[0] == '\\' || it2.first[0] == '$'));
+ log_assert(!it2.first.empty());
}
for (auto &it2 : it.second->parameters) {
- log_assert(it2.first.size() > 0 && (it2.first[0] == '\\' || it2.first[0] == '$'));
+ log_assert(!it2.first.empty());
}
InternalCellChecker checker(this, it.second);
checker.check();
for (auto &it : processes) {
log_assert(it.first == it.second->name);
- log_assert(it.first.size() > 0 && (it.first[0] == '\\' || it.first[0] == '$'));
+ log_assert(!it.first.empty());
// FIXME: More checks here..
}
}
for (auto &it : attributes) {
- log_assert(it.first.size() > 0 && (it.first[0] == '\\' || it.first[0] == '$'));
+ log_assert(!it.first.empty());
}
#endif
}
void RTLIL::Cell::fixup_parameters(bool set_a_signed, bool set_b_signed)
{
- if (type[0] != '$' || type.substr(0, 2) == "$_" || type.substr(0, 8) == "$paramod" ||
+ if (type.substr(0, 1) != "$" || type.substr(0, 2) == "$_" || type.substr(0, 8) == "$paramod" ||
type.substr(0, 9) == "$verific$" || type.substr(0, 7) == "$array:" || type.substr(0, 8) == "$extern:")
return;
*this = id;
}
- const char*c_str() const {
- return global_id_storage_.at(index_);
- }
-
- operator const char*() const {
+ const char *c_str() const {
return global_id_storage_.at(index_);
}
return c_str()[i];
}
+ char operator[](size_t i) const {
+ return c_str()[i];
+ }
+
std::string substr(size_t pos = 0, size_t len = std::string::npos) const {
if (len == std::string::npos || len >= strlen(c_str() + pos))
return std::string(c_str() + pos);
id1 = id2;
else if (edges[id1].size() > edges[id2].size())
continue;
- else if (w1->name > w2->name)
+ else if (w2->name < w1->name)
id1 = id2;
}
for (auto mod : copy_src_modules)
{
- std::string trg_name = as_name.empty() ? std::string(mod->name) : RTLIL::escape_id(as_name);
+ std::string trg_name = as_name.empty() ? mod->name.str() : RTLIL::escape_id(as_name);
if (copy_to_design->modules_.count(trg_name))
delete copy_to_design->modules_.at(trg_name);
RTLIL::IdString mod_name = RTLIL::escape_id(args[++argidx]);
if (design->modules_.count(mod_name) == 0)
log_cmd_error("No such module: %s\n", id2cstr(mod_name));
- design->selected_active_module = mod_name;
+ design->selected_active_module = mod_name.str();
got_module = true;
continue;
}
if (design->modules_.count(design->selected_active_module) > 0)
module = design->modules_.at(design->selected_active_module);
if (module != NULL && module->cells_.count(modname) > 0)
- modname = module->cells_.at(modname)->type;
+ modname = module->cells_.at(modname)->type.str();
}
if (design->modules_.count(modname) > 0) {
else if (it.second->port_output)
all_sinks.insert(stringf("n%d", id2num(it.first)));
} else {
- wires_on_demand[stringf("n%d", id2num(it.first))] = it.first;
+ wires_on_demand[stringf("n%d", id2num(it.first))] = it.first.str();
}
}
kiss_name.assign(attr_it->second.decode_string());
}
else {
- kiss_name.assign(module->name);
+ kiss_name.assign(module->name.str());
kiss_name.append('-' + cell->name.str() + ".kiss2");
}
}
std::stringstream sstr;
- sstr << "$mem$" << memory->name << "$" << (autoidx++);
+ sstr << "$mem$" << memory->name.str() << "$" << (autoidx++);
RTLIL::Cell *mem = module->addCell(sstr.str(), "$mem");
mem->parameters["\\MEMID"] = RTLIL::Const(memory->name.str());
if (sig_bit_ref.count(bit) == 0) {
bit_ref_t &bit_ref = sig_bit_ref[bit];
- bit_ref.cell = cell->name;
- bit_ref.port = conn.first;
+ bit_ref.cell = cell->name.str();
+ bit_ref.port = conn.first.str();
bit_ref.bit = i;
}
if (!flatten_mode)
for (auto &it : tpl->cells_)
if (it.first == "\\_TECHMAP_REPLACE_") {
- orig_cell_name = cell->name;
+ orig_cell_name = cell->name.str();
module->rename(cell, stringf("$techmap%d", autoidx++) + cell->name.str());
break;
}