Preserve ports
This commit is contained in:
parent
ff257a0929
commit
92da4a91de
@ -548,6 +548,9 @@ struct BaseCtx
|
||||
std::unordered_map<IdString, std::unique_ptr<NetInfo>> nets;
|
||||
std::unordered_map<IdString, std::unique_ptr<CellInfo>> cells;
|
||||
|
||||
// Top-level ports
|
||||
std::unordered_map<IdString, PortInfo> ports;
|
||||
|
||||
// Floorplanning regions
|
||||
std::unordered_map<IdString, std::unique_ptr<Region>> region;
|
||||
|
||||
|
@ -717,6 +717,12 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, const string
|
||||
assert(false);
|
||||
}
|
||||
ctx->cells[iobuf->name] = std::move(iobuf);
|
||||
|
||||
PortInfo pinfo;
|
||||
pinfo.name = net->name;
|
||||
pinfo.net = net;
|
||||
pinfo.type = type;
|
||||
ctx->ports[net->name] = pinfo;
|
||||
}
|
||||
|
||||
void json_import_toplevel_port(Context *ctx, const string &modname, const std::vector<IdString> &netnames,
|
||||
|
@ -76,11 +76,20 @@ void write_module(std::ostream &f, Context *ctx)
|
||||
write_parameters(f, ctx, ctx->attrs, true);
|
||||
f << stringf("\n },\n");
|
||||
f << stringf(" \"ports\": {");
|
||||
// TODO: Top level ports
|
||||
bool first = true;
|
||||
for (auto &pair : ctx->ports) {
|
||||
auto &c = pair.second;
|
||||
f << stringf("%s\n", first ? "" : ",");
|
||||
f << stringf(" %s: {\n", get_name(c.name, ctx).c_str());
|
||||
f << stringf(" \"direction\": \"%s\",\n", c.type == PORT_IN ? "input" : c.type == PORT_INOUT ? "inout" : "output");
|
||||
f << stringf(" \"bits\": [ %d ]\n", pair.first.index);
|
||||
f << stringf(" }");
|
||||
first = false;
|
||||
}
|
||||
f << stringf("\n },\n");
|
||||
|
||||
f << stringf(" \"cells\": {");
|
||||
bool first = true;
|
||||
first = true;
|
||||
for (auto &pair : ctx->cells) {
|
||||
auto &c = pair.second;
|
||||
f << stringf("%s\n", first ? "" : ",");
|
||||
|
Loading…
Reference in New Issue
Block a user