aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/frontend_base.h
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2019-11-13 18:52:13 +0000
committerDavid Shah <dave@ds0.me>2019-12-27 10:44:29 +0000
commit77cbd70a72997e659bcba70175761b9fb930c5c6 (patch)
tree7f1e6324889ce0305689a5eef9a0355057cd4317 /frontend/frontend_base.h
parent240561c370c03ad33b2ac397369659a0b9a54c18 (diff)
downloadnextpnr-77cbd70a72997e659bcba70175761b9fb930c5c6.tar.gz
nextpnr-77cbd70a72997e659bcba70175761b9fb930c5c6.tar.bz2
nextpnr-77cbd70a72997e659bcba70175761b9fb930c5c6.zip
frontend: JSON implementation of the generic framework
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'frontend/frontend_base.h')
-rw-r--r--frontend/frontend_base.h38
1 files changed, 20 insertions, 18 deletions
diff --git a/frontend/frontend_base.h b/frontend/frontend_base.h
index 35d4409c..426d9431 100644
--- a/frontend/frontend_base.h
+++ b/frontend/frontend_base.h
@@ -56,11 +56,11 @@
* PortType get_port_dir(const ModulePortDataType &port);
* gets the PortType direction of a module port
*
- * int get_port_offset(const ModulePortDataType &port);
- * gets the start bit number of a port
+ * int get_array_offset(const ModulePortDataType &port);
+ * gets the start bit number of a port or netname entry
*
- * bool is_port_upto(const ModulePortDataType &port);
- * returns true if a port is an "upto" type port
+ * bool is_array_upto(const ModulePortDataType &port);
+ * returns true if a port/net is an "upto" type port or netname entry
*
* const BitVectorDataType &get_port_bits(const ModulePortDataType &port);
* gets the bit vector of a module port
@@ -108,6 +108,14 @@ NEXTPNR_NAMESPACE_BEGIN
namespace {
+// Used for hierarchy resolution
+struct ModuleInfo
+{
+ bool is_top = false, is_blackbox = false, is_whitebox = false;
+ inline bool is_box() const { return is_blackbox || is_whitebox; }
+ std::unordered_set<IdString> instantiated_celltypes;
+};
+
template <typename FrontendType> struct GenericFrontend
{
GenericFrontend(Context *ctx, const FrontendType &impl) : ctx(ctx), impl(impl) {}
@@ -119,14 +127,6 @@ template <typename FrontendType> struct GenericFrontend
using netname_dat_t = typename FrontendType::NetnameDataType;
using bitvector_t = typename FrontendType::BitVectorDataType;
- // Used for hierarchy resolution
- struct ModuleInfo
- {
- const mod_dat_t *mod_data;
- bool is_top = false, is_blackbox = false, is_whitebox = false;
- inline bool is_box() const { return is_blackbox || is_whitebox; }
- std::unordered_set<IdString> instantiated_celltypes;
- };
std::unordered_map<IdString, ModuleInfo> mods;
IdString top;
@@ -137,7 +137,6 @@ template <typename FrontendType> struct GenericFrontend
impl.foreach_module([&](const std::string &name, const mod_dat_t &mod) {
IdString mod_id = ctx->id(name);
auto &mi = mods[mod_id];
- mi.mod_data = &mod;
impl.foreach_attr(mod, [&](const std::string &name, const Property &value) {
if (name == "top")
mi.is_top = (value.intval != 0);
@@ -147,7 +146,7 @@ template <typename FrontendType> struct GenericFrontend
mi.is_whitebox = (value.intval != 0);
});
impl.foreach_cell(mod, [&](const std::string &name, const cell_dat_t &cell) {
- mi.instantiated_cells.insert(ctx->id(impl.get_cell_type(cell)));
+ mi.instantiated_celltypes.insert(ctx->id(impl.get_cell_type(cell)));
});
});
// First of all, see if a top module has been manually specified
@@ -230,7 +229,7 @@ template <typename FrontendType> struct GenericFrontend
std::unordered_map<IdString, std::vector<int>> port_to_bus;
};
- void import_module(HierModuleState &m, mod_dat_t *data)
+ void import_module(HierModuleState &m, const mod_dat_t &data)
{
std::vector<NetInfo *> index_to_net;
// Import port connections; for submodules only
@@ -289,10 +288,10 @@ template <typename FrontendType> struct GenericFrontend
ctx->net_aliases[mergee->name] = base->name;
// Update flat index of nets
for (auto old_idx : net_old_indices.at(mergee->udata)) {
- net_old_indices.at(base).push_back(old_idx);
+ net_old_indices.at(base->udata).push_back(old_idx);
net_flatindex.at(old_idx) = base;
}
- net_old_indices.at(base).push_back(mergee->udata);
+ net_old_indices.at(base->udata).push_back(mergee->udata);
net_flatindex.at(mergee->udata) = base;
net_old_indices.at(mergee->udata).clear();
// Remove merged net from context
@@ -349,6 +348,9 @@ template <typename FrontendType> struct GenericFrontend
};
} // namespace
-template <typename FrontendType> void run_frontend(Context *ctx, const FrontendType &impl) {}
+template <typename FrontendType> void run_frontend(Context *ctx, const FrontendType &impl)
+{
+ GenericFrontend<FrontendType>(ctx, impl);
+}
NEXTPNR_NAMESPACE_END \ No newline at end of file