mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Fix EDIF: portRef member 0 is always the MSB bit
This commit is contained in:
parent
1390e9a0a7
commit
850f8299a9
|
@ -317,10 +317,7 @@ struct EdifBackend : public Backend {
|
||||||
*f << stringf(" (port (array %s %d) (direction %s))\n", EDIF_DEFR(wire->name, port_rename, b[0], b[1]), wire->width, dir);
|
*f << stringf(" (port (array %s %d) (direction %s))\n", EDIF_DEFR(wire->name, port_rename, b[0], b[1]), wire->width, dir);
|
||||||
for (int i = 0; i < wire->width; i++) {
|
for (int i = 0; i < wire->width; i++) {
|
||||||
RTLIL::SigSpec sig = sigmap(RTLIL::SigSpec(wire, i));
|
RTLIL::SigSpec sig = sigmap(RTLIL::SigSpec(wire, i));
|
||||||
if (wire->upto)
|
net_join_db[sig].insert(stringf("(portRef (member %s %d))", EDIF_REF(wire->name), GetSize(wire)-i-1));
|
||||||
net_join_db[sig].insert(stringf("(portRef (member %s %d))", EDIF_REF(wire->name), GetSize(wire)-i-1));
|
|
||||||
else
|
|
||||||
net_join_db[sig].insert(stringf("(portRef (member %s %d))", EDIF_REF(wire->name), i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,11 +360,11 @@ struct EdifBackend : public Backend {
|
||||||
else if (sig.size() == 1)
|
else if (sig.size() == 1)
|
||||||
net_join_db[sig[i]].insert(stringf("(portRef %s (instanceRef %s))", EDIF_REF(p.first), EDIF_REF(cell->name)));
|
net_join_db[sig[i]].insert(stringf("(portRef %s (instanceRef %s))", EDIF_REF(p.first), EDIF_REF(cell->name)));
|
||||||
else {
|
else {
|
||||||
int member_idx = i;
|
int member_idx = GetSize(sig)-i-1;
|
||||||
auto m = design->module(cell->type);
|
auto m = design->module(cell->type);
|
||||||
if (m) {
|
if (m) {
|
||||||
auto w = m->wire(p.first);
|
auto w = m->wire(p.first);
|
||||||
if (w && w->upto)
|
if (w)
|
||||||
member_idx = GetSize(w)-i-1;
|
member_idx = GetSize(w)-i-1;
|
||||||
}
|
}
|
||||||
net_join_db[sig[i]].insert(stringf("(portRef (member %s %d) (instanceRef %s))",
|
net_join_db[sig[i]].insert(stringf("(portRef (member %s %d) (instanceRef %s))",
|
||||||
|
|
|
@ -5,6 +5,7 @@ import numpy as np
|
||||||
|
|
||||||
enable_upto = True
|
enable_upto = True
|
||||||
enable_offset = True
|
enable_offset = True
|
||||||
|
enable_hierarchy = True
|
||||||
|
|
||||||
def make_module(f, modname, width, subs):
|
def make_module(f, modname, width, subs):
|
||||||
print("module %s (A, B, C, X, Y, Z);" % modname, file=f)
|
print("module %s (A, B, C, X, Y, Z);" % modname, file=f)
|
||||||
|
@ -60,13 +61,16 @@ def make_module(f, modname, width, subs):
|
||||||
print("endmodule", file=f)
|
print("endmodule", file=f)
|
||||||
|
|
||||||
with open("test_top.v", "w") as f:
|
with open("test_top.v", "w") as f:
|
||||||
make_module(f, "sub1", 2, {})
|
if enable_hierarchy:
|
||||||
make_module(f, "sub2", 3, {})
|
make_module(f, "sub1", 2, {})
|
||||||
make_module(f, "sub3", 4, {})
|
make_module(f, "sub2", 3, {})
|
||||||
make_module(f, "sub4", 8, {"sub1": 2, "sub2": 3, "sub3": 4})
|
make_module(f, "sub3", 4, {})
|
||||||
make_module(f, "sub5", 8, {"sub1": 2, "sub2": 3, "sub3": 4})
|
make_module(f, "sub4", 8, {"sub1": 2, "sub2": 3, "sub3": 4})
|
||||||
make_module(f, "sub6", 8, {"sub1": 2, "sub2": 3, "sub3": 4})
|
make_module(f, "sub5", 8, {"sub1": 2, "sub2": 3, "sub3": 4})
|
||||||
make_module(f, "top", 32, {"sub4": 8, "sub5": 8, "sub6": 8})
|
make_module(f, "sub6", 8, {"sub1": 2, "sub2": 3, "sub3": 4})
|
||||||
|
make_module(f, "top", 32, {"sub4": 8, "sub5": 8, "sub6": 8})
|
||||||
|
else:
|
||||||
|
make_module(f, "top", 32, {})
|
||||||
|
|
||||||
os.system("set -x; ../../yosys -p 'prep -top top; write_edif -pvector par test_syn.edif' test_top.v")
|
os.system("set -x; ../../yosys -p 'prep -top top; write_edif -pvector par test_syn.edif' test_top.v")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue