Add upto and offset to JSON ports
authorMiodrag Milanovic <mmicko@gmail.com>
Fri, 21 Jun 2019 17:47:25 +0000 (19:47 +0200)
committerMiodrag Milanovic <mmicko@gmail.com>
Fri, 21 Jun 2019 17:47:25 +0000 (19:47 +0200)
backends/json/json.cc
frontends/json/jsonparse.cc

index 1781a28cd07fb4d7224452a8a63636cf6b3878e7..eb59e5eba3a919e0bc0fa1a542ccc9d2ca8e3899 100644 (file)
@@ -127,6 +127,10 @@ struct JsonWriter
                        f << stringf("        %s: {\n", get_name(n).c_str());
                        f << stringf("          \"direction\": \"%s\",\n", w->port_input ? w->port_output ? "inout" : "input" : "output");
                        f << stringf("          \"bits\": %s\n", get_bits(w).c_str());
+                       if (w->start_offset)
+                               f << stringf("          \"offset\": %d,\n", w->start_offset);
+                       if (w->upto)
+                               f << stringf("          \"upto\": 1,\n");
                        f << stringf("        }");
                        first = false;
                }
index b74d41dd2a936445f32d988f55ce6712025fc440..f5ae8eb72f96a842103bb205e0536a7e437418c7 100644 (file)
@@ -292,6 +292,18 @@ void json_import(Design *design, string &modname, JsonNode *node)
                        if (port_wire == nullptr)
                                port_wire = module->addWire(port_name, GetSize(port_bits_node->data_array));
 
+                       if (port_node->data_dict.count("upto") != 0) {
+                               JsonNode *val = port_node->data_dict.at("upto");
+                               if (val->type == 'N')
+                                       port_wire->upto = val->data_number != 0;
+                       }
+
+                       if (port_node->data_dict.count("offset") != 0) {
+                               JsonNode *val = port_node->data_dict.at("offset");
+                               if (val->type == 'N')
+                                       port_wire->start_offset = val->data_number;
+                       }
+
                        if (port_direction_node->data_string == "input") {
                                port_wire->port_input = true;
                        } else