aboutsummaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-19 11:12:18 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-19 11:12:18 +0200
commite3519ddfcdfa0e0d3a2942ecf4802c3751db0e17 (patch)
tree08ad8d84423d97eb2976d244867e41a6b4bb2825 /frontend
parentec2792764a3d7df9f9382400d4ba52f416462fa4 (diff)
downloadnextpnr-e3519ddfcdfa0e0d3a2942ecf4802c3751db0e17.tar.gz
nextpnr-e3519ddfcdfa0e0d3a2942ecf4802c3751db0e17.tar.bz2
nextpnr-e3519ddfcdfa0e0d3a2942ecf4802c3751db0e17.zip
ice40: Adding support for tristate IO
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'frontend')
-rw-r--r--frontend/json/jsonparse.cc41
1 files changed, 24 insertions, 17 deletions
diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc
index cacc57ea..b3d6f718 100644
--- a/frontend/json/jsonparse.cc
+++ b/frontend/json/jsonparse.cc
@@ -663,7 +663,11 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type,
log_info("processing input port %s\n", name.c_str());
iobuf->type = ctx->id("$nextpnr_ibuf");
iobuf->ports[ctx->id("O")] = PortInfo{ctx->id("O"), net, PORT_OUT};
-
+ // Special case: input, etc, directly drives inout
+ if (net->driver.cell != nullptr) {
+ assert(net->driver.cell->type == ctx->id("$nextpnr_iobuf"));
+ net = net->driver.cell->ports.at(ctx->id("I")).net;
+ }
assert(net->driver.cell == nullptr);
net->driver.port = ctx->id("O");
net->driver.cell = iobuf;
@@ -679,20 +683,22 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type,
log_info("processing inout port %s\n", name.c_str());
iobuf->type = ctx->id("$nextpnr_iobuf");
iobuf->ports[ctx->id("I")] = PortInfo{ctx->id("I"), nullptr, PORT_IN};
- if (net->driver.cell != NULL) {
- // Split the input and output nets for bidir ports
- NetInfo *net2 = new NetInfo();
- net2->name = ctx->id("$" + net->name.str(ctx) + "$iobuf_i");
- net2->driver = net->driver;
+
+ // Split the input and output nets for bidir ports
+ NetInfo *net2 = new NetInfo();
+ net2->name = ctx->id("$" + net->name.str(ctx) + "$iobuf_i");
+ net2->driver = net->driver;
+ if (net->driver.cell != nullptr) {
net2->driver.cell->ports[net2->driver.port].net = net2;
net->driver.cell = nullptr;
- ctx->nets[net2->name] = net2;
- iobuf->ports[ctx->id("I")].net = net2;
- PortRef ref;
- ref.cell = iobuf;
- ref.port = ctx->id("I");
- net2->users.push_back(ref);
}
+ ctx->nets[net2->name] = net2;
+ iobuf->ports[ctx->id("I")].net = net2;
+ PortRef ref;
+ ref.cell = iobuf;
+ ref.port = ctx->id("I");
+ net2->users.push_back(ref);
+
iobuf->ports[ctx->id("O")] = PortInfo{ctx->id("O"), net, PORT_OUT};
assert(net->driver.cell == nullptr);
net->driver.port = ctx->id("O");
@@ -742,11 +748,12 @@ void json_import(Context *ctx, string modname, JsonNode *node)
int netid = bits->data_array.at(i)->data_number;
if (netid >= netnames.size())
netnames.resize(netid + 1);
- netnames.at(netid) = ctx->id(
- basename +
- (num_bits == 1 ? "" : std::string("[") +
- std::to_string(i) +
- std::string("]")));
+ netnames.at(netid) =
+ ctx->id(basename +
+ (num_bits == 1 ? ""
+ : std::string("[") +
+ std::to_string(i) +
+ std::string("]")));
}
}
}