diff options
author | David Shah <davey1576@gmail.com> | 2018-06-13 10:21:31 +0200 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-06-13 10:21:31 +0200 |
commit | ddf549b117987c1e52412b58531c48a6050b51d1 (patch) | |
tree | 872ab4fe3a07da5a9f242ed67ac4b2d5a9837f26 /frontend/json | |
parent | a34c790b6a3e529fd8deae490d848d0d6d22e83d (diff) | |
download | nextpnr-ddf549b117987c1e52412b58531c48a6050b51d1.tar.gz nextpnr-ddf549b117987c1e52412b58531c48a6050b51d1.tar.bz2 nextpnr-ddf549b117987c1e52412b58531c48a6050b51d1.zip |
frontend/son: Insert generic IO buffers for top level IO
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'frontend/json')
-rw-r--r-- | frontend/json/jsonparse.cc | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index 9f4c67c2..df3a298e 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -622,7 +622,7 @@ void json_import_cell(Design *design, string modname, JsonNode *cell_node, pr.cell = cell; pr.port = name; if (net != nullptr) { - if (type == PORT_IN) { + if (type == PORT_IN || type == PORT_INOUT) { net->users.push_back(pr); } else if (type == PORT_OUT) { assert(net->driver.cell == nullptr); @@ -637,7 +637,7 @@ void json_import_cell(Design *design, string modname, JsonNode *cell_node, } static void insert_iobuf(Design *design, NetInfo *net, PortType type, - string name) + const string &name) { // Instantiate a architecture-independent IO buffer connected to a given // net, of a given type, and named after the IO port. @@ -650,6 +650,7 @@ static void insert_iobuf(Design *design, NetInfo *net, PortType type, std::copy(net->attrs.begin(), net->attrs.end(), std::inserter(iobuf->attrs, iobuf->attrs.begin())); if (type == PORT_IN) { + log_info("processing input port %s\n", name.c_str()); iobuf->type = "$nextpnr_ibuf"; iobuf->ports["O"] = PortInfo{"O", net, PORT_OUT}; @@ -657,14 +658,16 @@ static void insert_iobuf(Design *design, NetInfo *net, PortType type, net->driver.port = "O"; net->driver.cell = iobuf; } else if (type == PORT_OUT) { - iobuf->type == "$nextpnr_obuf"; + log_info("processing output port %s\n", name.c_str()); + iobuf->type = "$nextpnr_obuf"; iobuf->ports["I"] = PortInfo{"I", net, PORT_IN}; PortRef ref; ref.cell = iobuf; ref.port = "I"; net->users.push_back(ref); } else if (type == PORT_INOUT) { - iobuf->type == "$nextpnr_iobuf"; + log_info("processing inout port %s\n", name.c_str()); + iobuf->type = "$nextpnr_iobuf"; iobuf->ports["I"] = PortInfo{"I", nullptr, PORT_IN}; if (net->driver.cell != NULL) { // Split the input and output nets for bidir ports @@ -690,6 +693,14 @@ static void insert_iobuf(Design *design, NetInfo *net, PortType type, design->cells[iobuf->name] = iobuf; } +void json_import_toplevel_port(Design *design, const string &modname, const string& portname, JsonNode *node) { + JsonNode *dir_node = node->data_dict.at("direction"); + JsonNode *nets_node = node->data_dict.at("bits"); + json_import_ports(design, modname, "Top Level IO", portname, dir_node, nets_node, [design](PortType type, const std::string &name, NetInfo *net){ + insert_iobuf(design, net, type, name); + }); +} + void json_import(Design *design, string modname, JsonNode *node) { if (is_blackbox(node)) @@ -715,6 +726,21 @@ void json_import(Design *design, string modname, JsonNode *node) } } + if (node->data_dict.count("ports")) { + JsonNode *ports_parent = node->data_dict.at("ports"); + + // N.B. ports must be imported after cells for tristate behaviour + // to be correct + // Loop through all ports + for (int portid = 0; portid < GetSize(ports_parent->data_dict_keys); + portid++) { + JsonNode *here, *param_node; + + here = ports_parent->data_dict.at( + ports_parent->data_dict_keys[portid]); + json_import_toplevel_port(design, modname, ports_parent->data_dict_keys[portid], here); + } + } check_all_nets_driven(design); } |