Added support for attributes/properties types
This commit is contained in:
parent
ccbe2dd18d
commit
d5d8213871
@ -286,6 +286,41 @@ struct PipMap
|
|||||||
PlaceStrength strength = STRENGTH_NONE;
|
PlaceStrength strength = STRENGTH_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Property
|
||||||
|
{
|
||||||
|
bool is_string;
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
int num;
|
||||||
|
|
||||||
|
std::string::iterator begin() { return str.begin(); }
|
||||||
|
std::string::iterator end() { return str.end(); }
|
||||||
|
|
||||||
|
bool isString() const { return is_string; }
|
||||||
|
|
||||||
|
void setNumber(int val) { is_string = false; num = val; str = std::to_string(val); }
|
||||||
|
void setString(std::string val) { is_string = true; str = val; }
|
||||||
|
|
||||||
|
const char * c_str() const { return str.c_str(); }
|
||||||
|
operator std::string () const { return str; }
|
||||||
|
|
||||||
|
bool operator==(const std::string other) const
|
||||||
|
{
|
||||||
|
return str == other;
|
||||||
|
}
|
||||||
|
bool operator!=(const std::string other) const
|
||||||
|
{
|
||||||
|
return str != other;
|
||||||
|
}
|
||||||
|
|
||||||
|
Property& operator=(std::string other)
|
||||||
|
{
|
||||||
|
is_string = true;
|
||||||
|
str = other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct ClockConstraint;
|
struct ClockConstraint;
|
||||||
|
|
||||||
struct NetInfo : ArchNetInfo
|
struct NetInfo : ArchNetInfo
|
||||||
@ -295,7 +330,7 @@ struct NetInfo : ArchNetInfo
|
|||||||
|
|
||||||
PortRef driver;
|
PortRef driver;
|
||||||
std::vector<PortRef> users;
|
std::vector<PortRef> users;
|
||||||
std::unordered_map<IdString, std::string> attrs;
|
std::unordered_map<IdString, Property> attrs;
|
||||||
|
|
||||||
// wire -> uphill_pip
|
// wire -> uphill_pip
|
||||||
std::unordered_map<WireId, PipMap> wires;
|
std::unordered_map<WireId, PipMap> wires;
|
||||||
@ -328,7 +363,7 @@ struct CellInfo : ArchCellInfo
|
|||||||
int32_t udata;
|
int32_t udata;
|
||||||
|
|
||||||
std::unordered_map<IdString, PortInfo> ports;
|
std::unordered_map<IdString, PortInfo> ports;
|
||||||
std::unordered_map<IdString, std::string> attrs, params;
|
std::unordered_map<IdString, Property> attrs, params;
|
||||||
|
|
||||||
BelId bel;
|
BelId bel;
|
||||||
PlaceStrength belStrength = STRENGTH_NONE;
|
PlaceStrength belStrength = STRENGTH_NONE;
|
||||||
|
@ -122,7 +122,7 @@ BOOST_PYTHON_MODULE(MODULE_NAME)
|
|||||||
.value("PORT_INOUT", PORT_INOUT)
|
.value("PORT_INOUT", PORT_INOUT)
|
||||||
.export_values();
|
.export_values();
|
||||||
|
|
||||||
typedef std::unordered_map<IdString, std::string> AttrMap;
|
typedef std::unordered_map<IdString, Property> AttrMap;
|
||||||
typedef std::unordered_map<IdString, PortInfo> PortMap;
|
typedef std::unordered_map<IdString, PortInfo> PortMap;
|
||||||
typedef std::unordered_map<IdString, IdString> PinMap;
|
typedef std::unordered_map<IdString, IdString> PinMap;
|
||||||
typedef std::unordered_map<IdString, std::unique_ptr<Region>> RegionMap;
|
typedef std::unordered_map<IdString, std::unique_ptr<Region>> RegionMap;
|
||||||
|
@ -1896,7 +1896,7 @@ class Ecp5Packer
|
|||||||
iol->params[ctx->id("DELAY.DEL_VALUE")] =
|
iol->params[ctx->id("DELAY.DEL_VALUE")] =
|
||||||
std::to_string(lookup_delay(str_or_default(ci->params, ctx->id("DEL_MODE"), "USER_DEFINED")));
|
std::to_string(lookup_delay(str_or_default(ci->params, ctx->id("DEL_MODE"), "USER_DEFINED")));
|
||||||
if (ci->params.count(ctx->id("DEL_VALUE")) &&
|
if (ci->params.count(ctx->id("DEL_VALUE")) &&
|
||||||
ci->params.at(ctx->id("DEL_VALUE")).substr(0, 5) != "DELAY")
|
std::string(ci->params.at(ctx->id("DEL_VALUE"))).substr(0, 5) != "DELAY")
|
||||||
iol->params[ctx->id("DELAY.DEL_VALUE")] = ci->params.at(ctx->id("DEL_VALUE"));
|
iol->params[ctx->id("DELAY.DEL_VALUE")] = ci->params.at(ctx->id("DEL_VALUE"));
|
||||||
if (ci->ports.count(id_LOADN))
|
if (ci->ports.count(id_LOADN))
|
||||||
replace_port(ci, id_LOADN, iol, id_LOADN);
|
replace_port(ci, id_LOADN, iol, id_LOADN);
|
||||||
|
@ -1202,7 +1202,7 @@ static void pack_special(Context *ctx)
|
|||||||
? "1"
|
? "1"
|
||||||
: feedback_path == "PHASE_AND_DELAY"
|
: feedback_path == "PHASE_AND_DELAY"
|
||||||
? "2"
|
? "2"
|
||||||
: feedback_path == "EXTERNAL" ? "6" : feedback_path;
|
: feedback_path == "EXTERNAL" ? "6" : std::string(feedback_path);
|
||||||
if (!std::all_of(fbp_value.begin(), fbp_value.end(), isdigit))
|
if (!std::all_of(fbp_value.begin(), fbp_value.end(), isdigit))
|
||||||
log_error("PLL '%s' has unsupported FEEDBACK_PATH value '%s'\n", ci->name.c_str(ctx),
|
log_error("PLL '%s' has unsupported FEEDBACK_PATH value '%s'\n", ci->name.c_str(ctx),
|
||||||
feedback_path.c_str());
|
feedback_path.c_str());
|
||||||
|
@ -309,7 +309,7 @@ bool is_blackbox(JsonNode *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, JsonNode *param_node,
|
void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, JsonNode *param_node,
|
||||||
std::unordered_map<IdString, std::string> *dest, int param_id)
|
std::unordered_map<IdString, Property> *dest, int param_id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
JsonNode *param;
|
JsonNode *param;
|
||||||
@ -319,9 +319,9 @@ void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, Json
|
|||||||
|
|
||||||
pId = ctx->id(param_node->data_dict_keys[param_id]);
|
pId = ctx->id(param_node->data_dict_keys[param_id]);
|
||||||
if (param->type == 'N') {
|
if (param->type == 'N') {
|
||||||
(*dest)[pId] = std::to_string(param->data_number);
|
(*dest)[pId].setNumber(param->data_number);
|
||||||
} else if (param->type == 'S')
|
} else if (param->type == 'S')
|
||||||
(*dest)[pId] = param->data_string;
|
(*dest)[pId].setString(param->data_string);
|
||||||
else
|
else
|
||||||
log_error("JSON parameter type of \"%s\' of cell \'%s\' not supported\n", pId.c_str(ctx),
|
log_error("JSON parameter type of \"%s\' of cell \'%s\' not supported\n", pId.c_str(ctx),
|
||||||
cell->name.c_str(ctx));
|
cell->name.c_str(ctx));
|
||||||
@ -333,7 +333,7 @@ void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, Json
|
|||||||
}
|
}
|
||||||
|
|
||||||
void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNode *param_node,
|
void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNode *param_node,
|
||||||
std::unordered_map<IdString, std::string> *dest, int param_id)
|
std::unordered_map<IdString, Property> *dest, int param_id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
JsonNode *param;
|
JsonNode *param;
|
||||||
@ -343,9 +343,9 @@ void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNod
|
|||||||
|
|
||||||
pId = ctx->id(param_node->data_dict_keys[param_id]);
|
pId = ctx->id(param_node->data_dict_keys[param_id]);
|
||||||
if (param->type == 'N') {
|
if (param->type == 'N') {
|
||||||
(*dest)[pId] = std::to_string(param->data_number);
|
(*dest)[pId].setNumber(param->data_number);
|
||||||
} else if (param->type == 'S')
|
} else if (param->type == 'S')
|
||||||
(*dest)[pId] = param->data_string;
|
(*dest)[pId].setString(param->data_string);
|
||||||
else
|
else
|
||||||
log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx),
|
log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx),
|
||||||
net->name.c_str(ctx));
|
net->name.c_str(ctx));
|
||||||
|
@ -48,13 +48,16 @@ std::string get_name(IdString name, Context *ctx)
|
|||||||
return get_string(name.c_str(ctx));
|
return get_string(name.c_str(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool write_parameters(std::ostream &f, Context *ctx, const std::unordered_map<IdString, std::string> ¶meters, bool for_module=false)
|
bool write_parameters(std::ostream &f, Context *ctx, const std::unordered_map<IdString, Property> ¶meters, bool for_module=false)
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto ¶m : parameters) {
|
for (auto ¶m : parameters) {
|
||||||
f << stringf("%s\n", first ? "" : ",");
|
f << stringf("%s\n", first ? "" : ",");
|
||||||
f << stringf(" %s%s: ", for_module ? "" : " ", get_name(param.first,ctx).c_str());
|
f << stringf(" %s%s: ", for_module ? "" : " ", get_name(param.first,ctx).c_str());
|
||||||
|
if (param.second.isString())
|
||||||
f << get_string(param.second);
|
f << get_string(param.second);
|
||||||
|
else
|
||||||
|
f << param.second.num;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
return first;
|
return first;
|
||||||
|
Loading…
Reference in New Issue
Block a user