3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-23 15:42:32 +00:00
This commit is contained in:
Emil J. Tywoniak 2026-06-05 12:04:19 +02:00
parent 3d27e83d0f
commit 3424c00cd0
63 changed files with 2635 additions and 503 deletions

View file

@ -130,9 +130,16 @@ struct JsonWriter
}
}
void write_parameters(const dict<IdString, Const> &parameters, bool for_module=false)
void write_parameters(const dict<IdString, Const> &parameters, bool for_module=false, const RTLIL::AttrObject *src_obj=nullptr)
{
bool first = true;
// Emit the typed src field first if present — it lives outside the
// attribute dict after the typed-src migration.
if (src_obj && src_obj->src_id() != Twine::Null && design) {
f << stringf("\n %s%s: ", for_module ? "" : " ", get_name(RTLIL::ID::src));
write_parameter_value(RTLIL::Const(src_obj->get_src_attribute(&design->src_twines)));
first = false;
}
for (auto &param : parameters) {
f << stringf("%s\n", first ? "" : ",");
f << stringf(" %s%s: ", for_module ? "" : " ", get_name(param.first));
@ -158,7 +165,7 @@ struct JsonWriter
f << stringf(" %s: {\n", get_name(module->name));
f << stringf(" \"attributes\": {");
write_parameters(module->attributes, /*for_module=*/true);
write_parameters(module->attributes, /*for_module=*/true, module);
f << stringf("\n },\n");
if (module->parameter_default_values.size()) {
@ -210,7 +217,7 @@ struct JsonWriter
write_parameters(c->parameters);
f << stringf("\n },\n");
f << stringf(" \"attributes\": {");
write_parameters(c->attributes);
write_parameters(c->attributes, false, c);
f << stringf("\n },\n");
if (c->known()) {
f << stringf(" \"port_directions\": {");
@ -248,7 +255,7 @@ struct JsonWriter
f << stringf(" %s: {\n", get_name(it.second->name));
f << stringf(" \"hide_name\": %s,\n", it.second->name[0] == '$' ? "1" : "0");
f << stringf(" \"attributes\": {");
write_parameters(it.second->attributes);
write_parameters(it.second->attributes, false, it.second);
f << stringf("\n },\n");
f << stringf(" \"width\": %d,\n", it.second->width);
f << stringf(" \"start_offset\": %d,\n", it.second->start_offset);
@ -275,7 +282,7 @@ struct JsonWriter
if (w->is_signed)
f << stringf(" \"signed\": %d,\n", w->is_signed);
f << stringf(" \"attributes\": {");
write_parameters(w->attributes);
write_parameters(w->attributes, false, w);
f << stringf("\n }\n");
f << stringf(" }");
first = false;