aboutsummaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2019-11-22 17:29:45 +0000
committerDavid Shah <dave@ds0.me>2019-12-27 10:44:30 +0000
commit14b18cb6fa8909cbe34bfb01c6ea43a2ccff9617 (patch)
treeb17d02c6c21fafee87e6e121a29424d13555cba9 /frontend
parent28279b18fe219c182a97efa992f022c8d243ae28 (diff)
downloadnextpnr-14b18cb6fa8909cbe34bfb01c6ea43a2ccff9617.tar.gz
nextpnr-14b18cb6fa8909cbe34bfb01c6ea43a2ccff9617.tar.bz2
nextpnr-14b18cb6fa8909cbe34bfb01c6ea43a2ccff9617.zip
frontend: Support for loading settings and nextpnr state
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'frontend')
-rw-r--r--frontend/frontend_base.h18
-rw-r--r--frontend/json_frontend.cc10
2 files changed, 27 insertions, 1 deletions
diff --git a/frontend/frontend_base.h b/frontend/frontend_base.h
index d55e0329..c23e2196 100644
--- a/frontend/frontend_base.h
+++ b/frontend/frontend_base.h
@@ -76,6 +76,10 @@
* calls Func(const std::string &name, const Property &value);
* for each parameter of a cell
*
+ * void foreach_setting(const ModuleDataType &obj, Func) const;
+ * calls Func(const std::string &name, const Property &value);
+ * for each module-level setting
+ *
* void foreach_port_dir(const CellDataType &cell, Func) const;
* calls Func(const std::string &name, PortType dir);
* for each port direction of a cell
@@ -261,11 +265,23 @@ template <typename FrontendType> struct GenericFrontend
// Just create a list of ports for netname resolution
impl.foreach_port(data,
[&](const std::string &name, const mod_port_dat_t &) { m.port_to_bus[ctx->id(name)]; });
+ // Import module-level attributes
+ impl.foreach_attr(
+ data, [&](const std::string &name, const Property &value) { ctx->attrs[ctx->id(name)] = value; });
+ // Import settings
+ impl.foreach_setting(data, [&](const std::string &name, const Property &value) {
+ ctx->settings[ctx->id(name)] = value;
+ });
}
import_module_netnames(m, data);
import_module_cells(m, data);
- if (m.is_toplevel)
+ if (m.is_toplevel) {
import_toplevel_ports(m, data);
+ // Mark design as loaded through nextpnr
+ ctx->settings[ctx->id("synth")] = 1;
+ // Process nextpnr-specific attributes
+ ctx->attributesToArchInfo();
+ }
}
// Multiple labels might refer to the same net. Resolve conflicts for the primary name thus:
diff --git a/frontend/json_frontend.cc b/frontend/json_frontend.cc
index 0debd9f2..d2e6248e 100644
--- a/frontend/json_frontend.cc
+++ b/frontend/json_frontend.cc
@@ -134,6 +134,16 @@ struct JsonFrontendImpl
}
}
+ template <typename TFunc> void foreach_setting(const Json &obj, TFunc Func) const
+ {
+ const auto &settings = obj["settings"];
+ if (settings.is_null())
+ return;
+ for (const auto &setting : settings.object_items()) {
+ Func(setting.first, parse_property(setting.second));
+ }
+ }
+
template <typename TFunc> void foreach_port_dir(const CellDataType &cell, TFunc Func) const
{
for (const auto &pdir : cell["port_directions"].object_items())