Added JSON upto and offset
authorClifford Wolf <clifford@clifford.at>
Fri, 21 Jun 2019 13:22:17 +0000 (15:22 +0200)
committerClifford Wolf <clifford@clifford.at>
Fri, 21 Jun 2019 13:22:17 +0000 (15:22 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
backends/json/json.cc
frontends/json/jsonparse.cc

index 5022d5da169ba67ba435193ccb92ff8452c8ede1..1781a28cd07fb4d7224452a8a63636cf6b3878e7 100644 (file)
@@ -189,6 +189,10 @@ struct JsonWriter
                        f << stringf("        %s: {\n", get_name(w->name).c_str());
                        f << stringf("          \"hide_name\": %s,\n", w->name[0] == '$' ? "1" : "0");
                        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("          \"attributes\": {");
                        write_parameters(w->attributes);
                        f << stringf("\n          }\n");
index 82361ea9bf1b2f4aa50c22be5dae6905a675335f..344b8c2c8492155035ff684679e7b5282029e021 100644 (file)
@@ -372,6 +372,18 @@ void json_import(Design *design, string &modname, JsonNode *node)
                        if (wire == nullptr)
                                wire = module->addWire(net_name, GetSize(bits_node->data_array));
 
+                       if (net_node->data_dict.count("upto") != 0) {
+                               JsonNode *val = net_node->data_dict.at("offset");
+                               if (val->type == 'N')
+                                       wire->upto = val->data_number != 0;
+                       }
+
+                       if (net_node->data_dict.count("offset") != 0) {
+                               JsonNode *val = net_node->data_dict.at("offset");
+                               if (val->type == 'N')
+                                       wire->start_offset = val->data_number;
+                       }
+
                        for (int i = 0; i < GetSize(bits_node->data_array); i++)
                        {
                                JsonNode *bitval_node = bits_node->data_array.at(i);