aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/json
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-09 19:33:35 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-09 19:33:44 +0200
commite15620ccd4e5062a999f51bc5f3ee53739586561 (patch)
treef76326b9e86b0bcd868d5851ac258f4be9afe174 /frontend/json
parent8cabb39d6d6270f3f721c903d20f7b2cf8fe79a4 (diff)
downloadnextpnr-e15620ccd4e5062a999f51bc5f3ee53739586561.tar.gz
nextpnr-e15620ccd4e5062a999f51bc5f3ee53739586561.tar.bz2
nextpnr-e15620ccd4e5062a999f51bc5f3ee53739586561.zip
json: Parse cell attributes
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'frontend/json')
-rw-r--r--frontend/json/jsonparse.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc
index 7c87bc8f..761ad47e 100644
--- a/frontend/json/jsonparse.cc
+++ b/frontend/json/jsonparse.cc
@@ -312,9 +312,9 @@ bool is_blackbox(JsonNode *node)
return true;
}
-void json_import_cell_attributes(Design *design, string &modname,
- CellInfo *cell, JsonNode *param_node,
- int param_id)
+void json_import_cell_params(Design *design, string &modname, CellInfo *cell,
+ JsonNode *param_node,
+ dict<IdString, std::string> *dest, int param_id)
{
//
JsonNode *param;
@@ -324,9 +324,9 @@ void json_import_cell_attributes(Design *design, string &modname,
pId = param_node->data_dict_keys[param_id];
if (param->type == 'N') {
- cell->params[pId] = std::to_string(param->data_number);
+ (*dest)[pId] = std::to_string(param->data_number);
} else if (param->type == 'S')
- cell->params[pId] = param->data_string;
+ (*dest)[pId] = param->data_string;
else
log_error(
"JSON parameter type of \"%s\' of cell \'%s\' not supported\n",
@@ -529,7 +529,7 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
void json_import_cell(Design *design, string modname, JsonNode *cell_node,
string cell_name)
{
- JsonNode *cell_type, *param_node;
+ JsonNode *cell_type, *param_node, *attr_node;
cell_type = cell_node->data_dict.at("type");
if (cell_type == NULL)
@@ -557,7 +557,24 @@ void json_import_cell(Design *design, string modname, JsonNode *cell_node,
for (int paramid = 0; paramid < GetSize(param_node->data_dict_keys);
paramid++) {
- json_import_cell_attributes(design, modname, cell, param_node, paramid);
+ json_import_cell_params(design, modname, cell, param_node,
+ &cell->params, paramid);
+ }
+
+ attr_node = cell_node->data_dict.at("attributes");
+ if (attr_node->type != 'D')
+ log_error("JSON attribute list of \'%s\' is not a data dictionary\n",
+ cell->name.c_str());
+
+ //
+ // Loop through all attributes, adding them into the
+ // design to annotate the cell
+ //
+ for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys);
+ attrid++) {
+
+ json_import_cell_params(design, modname, cell, attr_node, &cell->attrs,
+ attrid);
}
//