aboutsummaryrefslogtreecommitdiffstats
path: root/common/nextpnr.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r--common/nextpnr.h155
1 files changed, 19 insertions, 136 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 6228e653..50465869 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -19,7 +19,6 @@
#include <algorithm>
#include <assert.h>
-#include <boost/thread/shared_mutex.hpp>
#include <memory>
#include <stdexcept>
#include <stdint.h>
@@ -239,48 +238,21 @@ struct CellInfo
std::unordered_map<IdString, IdString> pins;
};
-struct UIUpdatesRequired
+struct BaseCtx
{
- bool allUIReload;
- bool frameUIReload;
- std::unordered_set<BelId> belUIReload;
- std::unordered_set<WireId> wireUIReload;
- std::unordered_set<PipId> pipUIReload;
- std::unordered_set<GroupId> groupUIReload;
-};
-
-class ReadContext;
-class MutateContext;
-class BaseReadCtx;
-class BaseMutateCtx;
-
-// Data that every architecture object should contain.
-class BaseCtx
-{
- friend class ReadContext;
- friend class MutateContext;
- friend class BaseReadCtx;
- friend class BaseMutateCtx;
-
- private:
- mutable boost::shared_mutex mtx_;
+ // --------------------------------------------------------------
- bool allUiReload = false;
- bool frameUiReload = false;
- std::unordered_set<BelId> belUiReload;
- std::unordered_set<WireId> wireUiReload;
- std::unordered_set<PipId> pipUiReload;
- std::unordered_set<GroupId> groupUiReload;
+ mutable std::unordered_map<std::string, int> *idstring_str_to_idx;
+ mutable std::vector<const std::string *> *idstring_idx_to_str;
- public:
IdString id(const std::string &s) const { return IdString(this, s); }
+
IdString id(const char *s) const { return IdString(this, s); }
- // TODO(q3k): These need to be made private.
+ // --------------------------------------------------------------
+
std::unordered_map<IdString, std::unique_ptr<NetInfo>> nets;
std::unordered_map<IdString, std::unique_ptr<CellInfo>> cells;
- mutable std::unordered_map<std::string, int> *idstring_str_to_idx;
- mutable std::vector<const std::string *> *idstring_idx_to_str;
BaseCtx()
{
@@ -288,8 +260,6 @@ class BaseCtx
idstring_idx_to_str = new std::vector<const std::string *>;
IdString::initialize_add(this, "", 0);
IdString::initialize_arch(this);
-
- allUiReload = true;
}
~BaseCtx()
@@ -304,67 +274,24 @@ class BaseCtx
// --------------------------------------------------------------
- // Get a readwrite proxy to arch - this will keep a readwrite lock on the
- // entire architecture until the proxy object goes out of scope.
- MutateContext rwproxy(void);
- // Get a read-only proxy to arch - this will keep a read lock on the
- // entire architecture until the proxy object goes out of scope. Other read
- // locks can be taken while this one still exists. Ie., the UI can draw
- // elements while the PnR is going a RO operation.
- ReadContext rproxy(void) const;
-};
-
-// State-accessing read-only methods that every architecture object should
-// contain.
-class BaseReadCtx
-{
- protected:
- const BaseCtx *base_;
-
- public:
- BaseReadCtx(const BaseCtx *base) : base_(base) {}
-};
-
-// State-accesssing read/write methods that every architecture object should
-// contain.
-class BaseMutateCtx
-{
- protected:
- BaseCtx *base_;
-
- public:
- BaseMutateCtx(BaseCtx *base) : base_(base) {}
-
- void refreshUi(void) { base_->allUiReload = true; }
+ bool allUiReload = false;
+ bool frameUiReload = false;
+ std::unordered_set<BelId> belUiReload;
+ std::unordered_set<WireId> wireUiReload;
+ std::unordered_set<PipId> pipUiReload;
+ std::unordered_set<GroupId> groupUiReload;
- void refreshUiFrame(void) { base_->frameUiReload = true; }
+ void refreshUi() { allUiReload = true; }
- void refreshUiBel(BelId bel) { base_->belUiReload.insert(bel); }
+ void refreshUiFrame() { frameUiReload = true; }
- void refreshUiWire(WireId wire) { base_->wireUiReload.insert(wire); }
+ void refreshUiBel(BelId bel) { belUiReload.insert(bel); }
- void refreshUiPip(PipId pip) { base_->pipUiReload.insert(pip); }
+ void refreshUiWire(WireId wire) { wireUiReload.insert(wire); }
- void refreshUiGroup(GroupId group) { base_->groupUiReload.insert(group); }
+ void refreshUiPip(PipId pip) { pipUiReload.insert(pip); }
- UIUpdatesRequired getUIUpdatesRequired(void)
- {
- UIUpdatesRequired req;
- req.allUIReload = base_->allUiReload;
- req.frameUIReload = base_->frameUiReload;
- req.belUIReload = base_->belUiReload;
- req.wireUIReload = base_->wireUiReload;
- req.pipUIReload = base_->pipUiReload;
- req.groupUIReload = base_->groupUiReload;
-
- base_->allUiReload = false;
- base_->frameUiReload = false;
- base_->belUiReload.clear();
- base_->wireUiReload.clear();
- base_->pipUiReload.clear();
- base_->groupUiReload.clear();
- return req;
- }
+ void refreshUiGroup(GroupId group) { groupUiReload.insert(group); }
};
NEXTPNR_NAMESPACE_END
@@ -373,50 +300,6 @@ NEXTPNR_NAMESPACE_END
NEXTPNR_NAMESPACE_BEGIN
-// Read proxy to access ReadMethods while holding lock on underlying BaseCtx.
-class ReadContext : public ArchReadMethods
-{
- friend class BaseCtx;
-
- private:
- boost::shared_mutex *lock_;
- ReadContext(const Arch *parent) : ArchReadMethods(parent), lock_(&parent->mtx_) { lock_->lock_shared(); }
-
- public:
- ~ReadContext()
- {
- if (lock_ != nullptr) {
- lock_->unlock_shared();
- }
- }
- ReadContext(ReadContext &&other) : ArchReadMethods(other), lock_(other.lock_) { other.lock_ = nullptr; }
-};
-
-// Read proxy to access MutateMethods while holding lock on underlying BaseCtx.
-class MutateContext : public ArchReadMethods, public ArchMutateMethods
-{
- friend class BaseCtx;
-
- private:
- boost::shared_mutex *lock_;
- MutateContext(Arch *parent) : ArchReadMethods(parent), ArchMutateMethods(parent), lock_(&parent->mtx_)
- {
- lock_->lock();
- }
-
- public:
- ~MutateContext()
- {
- if (lock_ != nullptr) {
- lock_->unlock();
- }
- }
- MutateContext(MutateContext &&other) : ArchReadMethods(other), ArchMutateMethods(other), lock_(other.lock_)
- {
- other.lock_ = nullptr;
- }
-};
-
struct Context : Arch
{
bool verbose = false;