mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 01:25:33 +00:00
Replaced std::unordered_map as implementation for Yosys::dict
This commit is contained in:
parent
e52d1f9b9a
commit
9e6fb0b02c
12 changed files with 318 additions and 103 deletions
|
@ -103,7 +103,7 @@ void ILANG_BACKEND::dump_sigspec(std::ostream &f, const RTLIL::SigSpec &sig, boo
|
|||
dump_sigchunk(f, sig.as_chunk(), autoint);
|
||||
} else {
|
||||
f << stringf("{ ");
|
||||
for (auto it = sig.chunks().rbegin(); it != sig.chunks().rend(); it++) {
|
||||
for (auto it = sig.chunks().rbegin(); it != sig.chunks().rend(); ++it) {
|
||||
dump_sigchunk(f, *it, false);
|
||||
f << stringf(" ");
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void ILANG_BACKEND::dump_wire(std::ostream &f, std::string indent, const RTLIL::
|
|||
{
|
||||
std::map<RTLIL::IdString, RTLIL::Const, RTLIL::sort_by_id_str> sorted_attributes(wire->attributes.begin(), wire->attributes.end());
|
||||
|
||||
for (auto it = sorted_attributes.begin(); it != sorted_attributes.end(); it++) {
|
||||
for (auto it = sorted_attributes.begin(); it != sorted_attributes.end(); ++it) {
|
||||
f << stringf("%s" "attribute %s ", indent.c_str(), it->first.c_str());
|
||||
dump_const(f, it->second);
|
||||
f << stringf("\n");
|
||||
|
@ -140,7 +140,7 @@ void ILANG_BACKEND::dump_memory(std::ostream &f, std::string indent, const RTLIL
|
|||
{
|
||||
std::map<RTLIL::IdString, RTLIL::Const, RTLIL::sort_by_id_str> sorted_attributes(memory->attributes.begin(), memory->attributes.end());
|
||||
|
||||
for (auto it = sorted_attributes.begin(); it != sorted_attributes.end(); it++) {
|
||||
for (auto it = sorted_attributes.begin(); it != sorted_attributes.end(); ++it) {
|
||||
f << stringf("%s" "attribute %s ", indent.c_str(), it->first.c_str());
|
||||
dump_const(f, it->second);
|
||||
f << stringf("\n");
|
||||
|
@ -159,18 +159,18 @@ void ILANG_BACKEND::dump_cell(std::ostream &f, std::string indent, const RTLIL::
|
|||
std::map<RTLIL::IdString, RTLIL::Const, RTLIL::sort_by_id_str> sorted_parameters(cell->parameters.begin(), cell->parameters.end());
|
||||
std::map<RTLIL::IdString, RTLIL::SigSpec, RTLIL::sort_by_id_str> sorted_connections(cell->connections().begin(), cell->connections().end());
|
||||
|
||||
for (auto it = sorted_attributes.begin(); it != sorted_attributes.end(); it++) {
|
||||
for (auto it = sorted_attributes.begin(); it != sorted_attributes.end(); ++it) {
|
||||
f << stringf("%s" "attribute %s ", indent.c_str(), it->first.c_str());
|
||||
dump_const(f, it->second);
|
||||
f << stringf("\n");
|
||||
}
|
||||
f << stringf("%s" "cell %s %s\n", indent.c_str(), cell->type.c_str(), cell->name.c_str());
|
||||
for (auto it = sorted_parameters.begin(); it != sorted_parameters.end(); it++) {
|
||||
for (auto it = sorted_parameters.begin(); it != sorted_parameters.end(); ++it) {
|
||||
f << stringf("%s parameter%s %s ", indent.c_str(), (it->second.flags & RTLIL::CONST_FLAG_SIGNED) != 0 ? " signed" : "", it->first.c_str());
|
||||
dump_const(f, it->second);
|
||||
f << stringf("\n");
|
||||
}
|
||||
for (auto it = sorted_connections.begin(); it != sorted_connections.end(); it++) {
|
||||
for (auto it = sorted_connections.begin(); it != sorted_connections.end(); ++it) {
|
||||
f << stringf("%s connect %s ", indent.c_str(), it->first.c_str());
|
||||
dump_sigspec(f, it->second);
|
||||
f << stringf("\n");
|
||||
|
@ -180,7 +180,7 @@ void ILANG_BACKEND::dump_cell(std::ostream &f, std::string indent, const RTLIL::
|
|||
|
||||
void ILANG_BACKEND::dump_proc_case_body(std::ostream &f, std::string indent, const RTLIL::CaseRule *cs)
|
||||
{
|
||||
for (auto it = cs->actions.begin(); it != cs->actions.end(); it++)
|
||||
for (auto it = cs->actions.begin(); it != cs->actions.end(); ++it)
|
||||
{
|
||||
f << stringf("%s" "assign ", indent.c_str());
|
||||
dump_sigspec(f, it->first);
|
||||
|
@ -189,13 +189,13 @@ void ILANG_BACKEND::dump_proc_case_body(std::ostream &f, std::string indent, con
|
|||
f << stringf("\n");
|
||||
}
|
||||
|
||||
for (auto it = cs->switches.begin(); it != cs->switches.end(); it++)
|
||||
for (auto it = cs->switches.begin(); it != cs->switches.end(); ++it)
|
||||
dump_proc_switch(f, indent, *it);
|
||||
}
|
||||
|
||||
void ILANG_BACKEND::dump_proc_switch(std::ostream &f, std::string indent, const RTLIL::SwitchRule *sw)
|
||||
{
|
||||
for (auto it = sw->attributes.begin(); it != sw->attributes.end(); it++) {
|
||||
for (auto it = sw->attributes.begin(); it != sw->attributes.end(); ++it) {
|
||||
f << stringf("%s" "attribute %s ", indent.c_str(), it->first.c_str());
|
||||
dump_const(f, it->second);
|
||||
f << stringf("\n");
|
||||
|
@ -205,7 +205,7 @@ void ILANG_BACKEND::dump_proc_switch(std::ostream &f, std::string indent, const
|
|||
dump_sigspec(f, sw->signal);
|
||||
f << stringf("\n");
|
||||
|
||||
for (auto it = sw->cases.begin(); it != sw->cases.end(); it++)
|
||||
for (auto it = sw->cases.begin(); it != sw->cases.end(); ++it)
|
||||
{
|
||||
f << stringf("%s case ", indent.c_str());
|
||||
for (size_t i = 0; i < (*it)->compare.size(); i++) {
|
||||
|
@ -237,7 +237,7 @@ void ILANG_BACKEND::dump_proc_sync(std::ostream &f, std::string indent, const RT
|
|||
case RTLIL::STi: f << stringf("init\n"); break;
|
||||
}
|
||||
|
||||
for (auto it = sy->actions.begin(); it != sy->actions.end(); it++) {
|
||||
for (auto it = sy->actions.begin(); it != sy->actions.end(); ++it) {
|
||||
f << stringf("%s update ", indent.c_str());
|
||||
dump_sigspec(f, it->first);
|
||||
f << stringf(" ");
|
||||
|
@ -248,14 +248,14 @@ void ILANG_BACKEND::dump_proc_sync(std::ostream &f, std::string indent, const RT
|
|||
|
||||
void ILANG_BACKEND::dump_proc(std::ostream &f, std::string indent, const RTLIL::Process *proc)
|
||||
{
|
||||
for (auto it = proc->attributes.begin(); it != proc->attributes.end(); it++) {
|
||||
for (auto it = proc->attributes.begin(); it != proc->attributes.end(); ++it) {
|
||||
f << stringf("%s" "attribute %s ", indent.c_str(), it->first.c_str());
|
||||
dump_const(f, it->second);
|
||||
f << stringf("\n");
|
||||
}
|
||||
f << stringf("%s" "process %s\n", indent.c_str(), proc->name.c_str());
|
||||
dump_proc_case_body(f, indent + " ", &proc->root_case);
|
||||
for (auto it = proc->syncs.begin(); it != proc->syncs.end(); it++)
|
||||
for (auto it = proc->syncs.begin(); it != proc->syncs.end(); ++it)
|
||||
dump_proc_sync(f, indent + " ", *it);
|
||||
f << stringf("%s" "end\n", indent.c_str());
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ void ILANG_BACKEND::dump_module(std::ostream &f, std::string indent, RTLIL::Modu
|
|||
|
||||
if (print_header)
|
||||
{
|
||||
for (auto it = module->attributes.begin(); it != module->attributes.end(); it++) {
|
||||
for (auto it = module->attributes.begin(); it != module->attributes.end(); ++it) {
|
||||
f << stringf("%s" "attribute %s ", indent.c_str(), it->first.c_str());
|
||||
dump_const(f, it->second);
|
||||
f << stringf("\n");
|
||||
|
@ -336,7 +336,7 @@ void ILANG_BACKEND::dump_module(std::ostream &f, std::string indent, RTLIL::Modu
|
|||
}
|
||||
|
||||
bool first_conn_line = true;
|
||||
for (auto it = module->connections().begin(); it != module->connections().end(); it++) {
|
||||
for (auto it = module->connections().begin(); it != module->connections().end(); ++it) {
|
||||
bool show_conn = !only_selected;
|
||||
if (only_selected) {
|
||||
RTLIL::SigSpec sigs = it->first;
|
||||
|
@ -366,7 +366,7 @@ void ILANG_BACKEND::dump_design(std::ostream &f, RTLIL::Design *design, bool onl
|
|||
|
||||
if (!flag_m) {
|
||||
int count_selected_mods = 0;
|
||||
for (auto it = design->modules_.begin(); it != design->modules_.end(); it++) {
|
||||
for (auto it = design->modules_.begin(); it != design->modules_.end(); ++it) {
|
||||
if (design->selected_whole_module(it->first))
|
||||
flag_m = true;
|
||||
if (design->selected(it->second))
|
||||
|
@ -382,7 +382,7 @@ void ILANG_BACKEND::dump_design(std::ostream &f, RTLIL::Design *design, bool onl
|
|||
f << stringf("autoidx %d\n", autoidx);
|
||||
}
|
||||
|
||||
for (auto it = design->modules_.begin(); it != design->modules_.end(); it++) {
|
||||
for (auto it = design->modules_.begin(); it != design->modules_.end(); ++it) {
|
||||
if (!only_selected || design->selected(it->second)) {
|
||||
if (only_selected)
|
||||
f << stringf("\n");
|
||||
|
|
|
@ -74,22 +74,22 @@ void reset_auto_counter(RTLIL::Module *module)
|
|||
|
||||
reset_auto_counter_id(module->name, false);
|
||||
|
||||
for (auto it = module->wires_.begin(); it != module->wires_.end(); it++)
|
||||
for (auto it = module->wires_.begin(); it != module->wires_.end(); ++it)
|
||||
reset_auto_counter_id(it->second->name, true);
|
||||
|
||||
for (auto it = module->cells_.begin(); it != module->cells_.end(); it++) {
|
||||
for (auto it = module->cells_.begin(); it != module->cells_.end(); ++it) {
|
||||
reset_auto_counter_id(it->second->name, true);
|
||||
reset_auto_counter_id(it->second->type, false);
|
||||
}
|
||||
|
||||
for (auto it = module->processes.begin(); it != module->processes.end(); it++)
|
||||
for (auto it = module->processes.begin(); it != module->processes.end(); ++it)
|
||||
reset_auto_counter_id(it->second->name, false);
|
||||
|
||||
auto_name_digits = 1;
|
||||
for (size_t i = 10; i < auto_name_offset + auto_name_map.size(); i = i*10)
|
||||
auto_name_digits++;
|
||||
|
||||
for (auto it = auto_name_map.begin(); it != auto_name_map.end(); it++)
|
||||
for (auto it = auto_name_map.begin(); it != auto_name_map.end(); ++it)
|
||||
log(" renaming `%s' to `_%0*d_'.\n", it->first.c_str(), auto_name_digits, auto_name_offset + it->second);
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ void dump_sigspec(std::ostream &f, const RTLIL::SigSpec &sig)
|
|||
dump_sigchunk(f, sig.as_chunk());
|
||||
} else {
|
||||
f << stringf("{ ");
|
||||
for (auto it = sig.chunks().rbegin(); it != sig.chunks().rend(); it++) {
|
||||
for (auto it = sig.chunks().rbegin(); it != sig.chunks().rend(); ++it) {
|
||||
if (it != sig.chunks().rbegin())
|
||||
f << stringf(", ");
|
||||
dump_sigchunk(f, *it, true);
|
||||
|
@ -250,7 +250,7 @@ void dump_attributes(std::ostream &f, std::string indent, dict<RTLIL::IdString,
|
|||
{
|
||||
if (noattr)
|
||||
return;
|
||||
for (auto it = attributes.begin(); it != attributes.end(); it++) {
|
||||
for (auto it = attributes.begin(); it != attributes.end(); ++it) {
|
||||
f << stringf("%s" "%s %s", indent.c_str(), attr2comment ? "/*" : "(*", id(it->first).c_str());
|
||||
f << stringf(" = ");
|
||||
dump_const(f, it->second);
|
||||
|
@ -744,7 +744,7 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
|
|||
|
||||
if (cell->parameters.size() > 0) {
|
||||
f << stringf(" #(");
|
||||
for (auto it = cell->parameters.begin(); it != cell->parameters.end(); it++) {
|
||||
for (auto it = cell->parameters.begin(); it != cell->parameters.end(); ++it) {
|
||||
if (it != cell->parameters.begin())
|
||||
f << stringf(",");
|
||||
f << stringf("\n%s .%s(", indent.c_str(), id(it->first).c_str());
|
||||
|
@ -766,7 +766,7 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
|
|||
for (int i = 1; true; i++) {
|
||||
char str[16];
|
||||
snprintf(str, 16, "$%d", i);
|
||||
for (auto it = cell->connections().begin(); it != cell->connections().end(); it++) {
|
||||
for (auto it = cell->connections().begin(); it != cell->connections().end(); ++it) {
|
||||
if (it->first != str)
|
||||
continue;
|
||||
if (!first_arg)
|
||||
|
@ -780,7 +780,7 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
|
|||
break;
|
||||
found_numbered_port:;
|
||||
}
|
||||
for (auto it = cell->connections().begin(); it != cell->connections().end(); it++) {
|
||||
for (auto it = cell->connections().begin(); it != cell->connections().end(); ++it) {
|
||||
if (numbered_ports.count(it->first))
|
||||
continue;
|
||||
if (!first_arg)
|
||||
|
@ -812,7 +812,7 @@ void dump_case_body(std::ostream &f, std::string indent, RTLIL::CaseRule *cs, bo
|
|||
if (!omit_trailing_begin && number_of_stmts >= 2)
|
||||
f << stringf("%s" "begin\n", indent.c_str());
|
||||
|
||||
for (auto it = cs->actions.begin(); it != cs->actions.end(); it++) {
|
||||
for (auto it = cs->actions.begin(); it != cs->actions.end(); ++it) {
|
||||
if (it->first.size() == 0)
|
||||
continue;
|
||||
f << stringf("%s ", indent.c_str());
|
||||
|
@ -822,7 +822,7 @@ void dump_case_body(std::ostream &f, std::string indent, RTLIL::CaseRule *cs, bo
|
|||
f << stringf(";\n");
|
||||
}
|
||||
|
||||
for (auto it = cs->switches.begin(); it != cs->switches.end(); it++)
|
||||
for (auto it = cs->switches.begin(); it != cs->switches.end(); ++it)
|
||||
dump_proc_switch(f, indent + " ", *it);
|
||||
|
||||
if (!omit_trailing_begin && number_of_stmts == 0)
|
||||
|
@ -836,7 +836,7 @@ void dump_proc_switch(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw
|
|||
{
|
||||
if (sw->signal.size() == 0) {
|
||||
f << stringf("%s" "begin\n", indent.c_str());
|
||||
for (auto it = sw->cases.begin(); it != sw->cases.end(); it++) {
|
||||
for (auto it = sw->cases.begin(); it != sw->cases.end(); ++it) {
|
||||
if ((*it)->compare.size() == 0)
|
||||
dump_case_body(f, indent + " ", *it);
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ void dump_proc_switch(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw
|
|||
dump_sigspec(f, sw->signal);
|
||||
f << stringf(")\n");
|
||||
|
||||
for (auto it = sw->cases.begin(); it != sw->cases.end(); it++) {
|
||||
for (auto it = sw->cases.begin(); it != sw->cases.end(); ++it) {
|
||||
f << stringf("%s ", indent.c_str());
|
||||
if ((*it)->compare.size() == 0)
|
||||
f << stringf("default");
|
||||
|
@ -868,11 +868,11 @@ void dump_proc_switch(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw
|
|||
|
||||
void case_body_find_regs(RTLIL::CaseRule *cs)
|
||||
{
|
||||
for (auto it = cs->switches.begin(); it != cs->switches.end(); it++)
|
||||
for (auto it = cs->switches.begin(); it != cs->switches.end(); ++it)
|
||||
for (auto it2 = (*it)->cases.begin(); it2 != (*it)->cases.end(); it2++)
|
||||
case_body_find_regs(*it2);
|
||||
|
||||
for (auto it = cs->actions.begin(); it != cs->actions.end(); it++) {
|
||||
for (auto it = cs->actions.begin(); it != cs->actions.end(); ++it) {
|
||||
for (auto &c : it->first.chunks())
|
||||
if (c.wire != NULL)
|
||||
reg_wires.insert(c.wire->name);
|
||||
|
@ -883,7 +883,7 @@ void dump_process(std::ostream &f, std::string indent, RTLIL::Process *proc, boo
|
|||
{
|
||||
if (find_regs) {
|
||||
case_body_find_regs(&proc->root_case);
|
||||
for (auto it = proc->syncs.begin(); it != proc->syncs.end(); it++)
|
||||
for (auto it = proc->syncs.begin(); it != proc->syncs.end(); ++it)
|
||||
for (auto it2 = (*it)->actions.begin(); it2 != (*it)->actions.end(); it2++) {
|
||||
for (auto &c : it2->first.chunks())
|
||||
if (c.wire != NULL)
|
||||
|
@ -937,7 +937,7 @@ void dump_process(std::ostream &f, std::string indent, RTLIL::Process *proc, boo
|
|||
}
|
||||
}
|
||||
|
||||
for (auto it = sync->actions.begin(); it != sync->actions.end(); it++) {
|
||||
for (auto it = sync->actions.begin(); it != sync->actions.end(); ++it) {
|
||||
if (it->first.size() == 0)
|
||||
continue;
|
||||
f << stringf("%s ", indent.c_str());
|
||||
|
@ -958,7 +958,7 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
|
|||
active_module = module;
|
||||
|
||||
f << stringf("\n");
|
||||
for (auto it = module->processes.begin(); it != module->processes.end(); it++)
|
||||
for (auto it = module->processes.begin(); it != module->processes.end(); ++it)
|
||||
dump_process(f, indent + " ", it->second, true);
|
||||
|
||||
if (!noexpr)
|
||||
|
@ -996,7 +996,7 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
|
|||
bool keep_running = true;
|
||||
for (int port_id = 1; keep_running; port_id++) {
|
||||
keep_running = false;
|
||||
for (auto it = module->wires_.begin(); it != module->wires_.end(); it++) {
|
||||
for (auto it = module->wires_.begin(); it != module->wires_.end(); ++it) {
|
||||
RTLIL::Wire *wire = it->second;
|
||||
if (wire->port_id == port_id) {
|
||||
if (port_id != 1)
|
||||
|
@ -1009,19 +1009,19 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
|
|||
}
|
||||
f << stringf(");\n");
|
||||
|
||||
for (auto it = module->wires_.begin(); it != module->wires_.end(); it++)
|
||||
for (auto it = module->wires_.begin(); it != module->wires_.end(); ++it)
|
||||
dump_wire(f, indent + " ", it->second);
|
||||
|
||||
for (auto it = module->memories.begin(); it != module->memories.end(); it++)
|
||||
for (auto it = module->memories.begin(); it != module->memories.end(); ++it)
|
||||
dump_memory(f, indent + " ", it->second);
|
||||
|
||||
for (auto it = module->cells_.begin(); it != module->cells_.end(); it++)
|
||||
for (auto it = module->cells_.begin(); it != module->cells_.end(); ++it)
|
||||
dump_cell(f, indent + " ", it->second);
|
||||
|
||||
for (auto it = module->processes.begin(); it != module->processes.end(); it++)
|
||||
for (auto it = module->processes.begin(); it != module->processes.end(); ++it)
|
||||
dump_process(f, indent + " ", it->second);
|
||||
|
||||
for (auto it = module->connections().begin(); it != module->connections().end(); it++)
|
||||
for (auto it = module->connections().begin(); it != module->connections().end(); ++it)
|
||||
dump_conn(f, indent + " ", it->first, it->second);
|
||||
|
||||
f << stringf("%s" "endmodule\n", indent.c_str());
|
||||
|
@ -1133,7 +1133,7 @@ struct VerilogBackend : public Backend {
|
|||
extra_args(f, filename, args, argidx);
|
||||
|
||||
*f << stringf("/* Generated by %s */\n", yosys_version_str);
|
||||
for (auto it = design->modules_.begin(); it != design->modules_.end(); it++) {
|
||||
for (auto it = design->modules_.begin(); it != design->modules_.end(); ++it) {
|
||||
if (it->second->get_bool_attribute("\\blackbox") != blackboxes)
|
||||
continue;
|
||||
if (selected && !design->selected_whole_module(it->first)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue