aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-12-02 09:34:11 +0000
committerDavid Shah <dave@ds0.me>2020-12-02 09:34:11 +0000
commit5a291e4622b98b5648035a0bbc6b82f05ee63cdd (patch)
tree74568a61c435da6b4bb2feffa0df69f5980c49d1
parent868902fbdf0b476bdccf4d25cbb80ba602d2cc11 (diff)
downloadnextpnr-5a291e4622b98b5648035a0bbc6b82f05ee63cdd.tar.gz
nextpnr-5a291e4622b98b5648035a0bbc6b82f05ee63cdd.tar.bz2
nextpnr-5a291e4622b98b5648035a0bbc6b82f05ee63cdd.zip
nexus/pdc: Parse simple clock constraints
Signed-off-by: David Shah <dave@ds0.me>
-rw-r--r--nexus/pdc.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/nexus/pdc.cc b/nexus/pdc.cc
index 3efab69a..4aef354c 100644
--- a/nexus/pdc.cc
+++ b/nexus/pdc.cc
@@ -199,6 +199,10 @@ struct PDCParser
return cmd_get_ports(arguments);
else if (cmd == "get_cells")
return cmd_get_cells(arguments);
+ else if (cmd == "get_nets")
+ return cmd_get_nets(arguments);
+ else if (cmd == "create_clock")
+ return cmd_create_clock(arguments);
else if (cmd == "ldc_set_location")
return cmd_ldc_set_location(arguments);
else if (cmd == "ldc_set_port")
@@ -229,6 +233,25 @@ struct PDCParser
return args;
}
+ TCLValue cmd_get_nets(const std::vector<TCLValue> &arguments)
+ {
+ std::vector<TCLEntity> nets;
+ for (int i = 1; i < int(arguments.size()); i++) {
+ auto &arg = arguments.at(i);
+ if (!arg.is_string)
+ log_error("get_nets expected string arguments (line %d)\n", lineno);
+ std::string s = arg.str;
+ if (s.at(0) == '-')
+ log_error("unsupported argument '%s' to get_nets (line %d)\n", s.c_str(), lineno);
+ IdString id = ctx->id(s);
+ if (ctx->nets.count(id) || ctx->net_aliases.count(id))
+ nets.emplace_back(TCLEntity::ENTITY_NET, ctx->net_aliases.count(id) ? ctx->net_aliases.at(id) : id);
+ else
+ log_warning("get_nets argument '%s' matched no objects.\n", s.c_str());
+ }
+ return nets;
+ }
+
TCLValue cmd_get_ports(const std::vector<TCLValue> &arguments)
{
std::vector<TCLEntity> ports;
@@ -263,6 +286,44 @@ struct PDCParser
return cells;
}
+ TCLValue cmd_create_clock(const std::vector<TCLValue> &arguments)
+ {
+ float period = 10;
+ for (int i = 1; i < int(arguments.size()); i++) {
+ auto &arg = arguments.at(i);
+ if (arg.is_string) {
+ std::string s = arg.str;
+ if (s == "-period") {
+ i++;
+ auto &val = arguments.at(i);
+ if (!val.is_string)
+ log_error("expecting string argument to -period (line %d)\n", lineno);
+ try {
+ period = std::stof(val.str);
+ } catch (std::exception &e) {
+ log_error("invalid argument '%s' to -period (line %d)\n", val.str.c_str(), lineno);
+ }
+ } else if (s == "-name") {
+ i++;
+ } else {
+ log_error("unsupported argument '%s' to create_clock\n", s.c_str());
+ }
+ } else {
+ for (const auto &ety : arg.list) {
+ NetInfo *net = nullptr;
+ if (ety.type == TCLEntity::ENTITY_NET)
+ net = ctx->nets.at(ety.name).get();
+ else if (ety.type == TCLEntity::ENTITY_PORT)
+ net = ctx->ports.at(ety.name).net;
+ else
+ log_error("create_clock applies only to cells or IO ports (line %d)\n", lineno);
+ ctx->addClock(net->name, 1000.0f / period);
+ }
+ }
+ }
+ return std::string{};
+ }
+
TCLValue cmd_ldc_set_location(const std::vector<TCLValue> &arguments)
{
std::string site;