From 7081cca01654030f9a3b731cebf36e68590e3ed1 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 11 Jul 2018 14:03:23 +0200 Subject: Add GUI Decals API Signed-off-by: Clifford Wolf --- common/nextpnr.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 37e193b9..0b41ff81 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -155,6 +155,12 @@ NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_BEGIN +struct DecalXY +{ + DecalId decal; + float x = 0, y = 0; +}; + struct BelPin { BelId bel; @@ -273,6 +279,60 @@ struct Context : Arch // -------------------------------------------------------------- + std::vector getFrameGraphics() const __attribute__ ((deprecated)) { + std::vector ret; + DecalXY decalxy = getFrameDecal(); + ret = getDecalGraphics(decalxy.decal); + for (auto &it : ret) { + it.x1 += decalxy.x; + it.x2 += decalxy.x; + it.y1 += decalxy.y; + it.y2 += decalxy.y; + } + return ret; + } + + std::vector getBelGraphics(BelId bel) const __attribute__ ((deprecated)) { + std::vector ret; + DecalXY decalxy = getBelDecal(bel); + ret = getDecalGraphics(decalxy.decal); + for (auto &it : ret) { + it.x1 += decalxy.x; + it.x2 += decalxy.x; + it.y1 += decalxy.y; + it.y2 += decalxy.y; + } + return ret; + } + + std::vector getWireGraphics(WireId wire) const __attribute__ ((deprecated)) { + std::vector ret; + DecalXY decalxy = getWireDecal(wire); + ret = getDecalGraphics(decalxy.decal); + for (auto &it : ret) { + it.x1 += decalxy.x; + it.x2 += decalxy.x; + it.y1 += decalxy.y; + it.y2 += decalxy.y; + } + return ret; + } + + std::vector getPipGraphics(PipId pip) const __attribute__ ((deprecated)) { + std::vector ret; + DecalXY decalxy = getPipDecal(pip); + ret = getDecalGraphics(decalxy.decal); + for (auto &it : ret) { + it.x1 += decalxy.x; + it.x2 += decalxy.x; + it.y1 += decalxy.y; + it.y2 += decalxy.y; + } + return ret; + } + + // -------------------------------------------------------------- + uint64_t rngstate = 0x3141592653589793; uint64_t rng64() -- cgit v1.2.3 From 09735694b28f9d1807dad5cb52232b4a40b48a77 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 11 Jul 2018 14:39:42 +0200 Subject: Fixed MSVC build --- common/nextpnr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 0b41ff81..bf3a5c28 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -279,7 +279,7 @@ struct Context : Arch // -------------------------------------------------------------- - std::vector getFrameGraphics() const __attribute__ ((deprecated)) { + NPNR_DEPRECATED std::vector getFrameGraphics() const { std::vector ret; DecalXY decalxy = getFrameDecal(); ret = getDecalGraphics(decalxy.decal); @@ -292,7 +292,7 @@ struct Context : Arch return ret; } - std::vector getBelGraphics(BelId bel) const __attribute__ ((deprecated)) { + NPNR_DEPRECATED std::vector getBelGraphics(BelId bel) const { std::vector ret; DecalXY decalxy = getBelDecal(bel); ret = getDecalGraphics(decalxy.decal); @@ -305,7 +305,7 @@ struct Context : Arch return ret; } - std::vector getWireGraphics(WireId wire) const __attribute__ ((deprecated)) { + NPNR_DEPRECATED std::vector getWireGraphics(WireId wire) const { std::vector ret; DecalXY decalxy = getWireDecal(wire); ret = getDecalGraphics(decalxy.decal); @@ -318,7 +318,7 @@ struct Context : Arch return ret; } - std::vector getPipGraphics(PipId pip) const __attribute__ ((deprecated)) { + NPNR_DEPRECATED std::vector getPipGraphics(PipId pip) const { std::vector ret; DecalXY decalxy = getPipDecal(pip); ret = getDecalGraphics(decalxy.decal); -- cgit v1.2.3 From 2a01b5e4d326f697636c592b7589080f88d5fa2c Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 11 Jul 2018 17:02:13 +0200 Subject: New refreshUi API Signed-off-by: Clifford Wolf --- common/nextpnr.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index bf3a5c28..856d8993 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -259,6 +259,39 @@ struct BaseCtx delete idstring_str_to_idx; delete idstring_idx_to_str; } + + // -------------------------------------------------------------- + + bool allUiReload = false; + bool frameUiReload = false; + std::unordered_set belUiReload; + std::unordered_set wireUiReload; + std::unordered_set pipUiReload; + + void refreshUi() + { + allUiReload = true; + } + + void refreshUiFrame() + { + frameUiReload = true; + } + + void refreshUiBel(BelId bel) + { + belUiReload.insert(bel); + } + + void refreshUiWire(WireId wire) + { + wireUiReload.insert(wire); + } + + void refreshUiPip(PipId pip) + { + pipUiReload.insert(pip); + } }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 7df67c91b38433e8a1002f8e9f53926aafaa4d1b Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 11 Jul 2018 18:04:09 +0200 Subject: Add ctx->route() API Signed-off-by: Clifford Wolf --- common/nextpnr.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 856d8993..09bd1554 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -260,6 +260,10 @@ struct BaseCtx delete idstring_idx_to_str; } + Context *getCtx() { return reinterpret_cast(this); } + + const Context *getCtx() const { return reinterpret_cast(this); } + // -------------------------------------------------------------- bool allUiReload = false; @@ -366,6 +370,11 @@ struct Context : Arch // -------------------------------------------------------------- + // provided by router1.cc + bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay); + + // -------------------------------------------------------------- + uint64_t rngstate = 0x3141592653589793; uint64_t rng64() -- cgit v1.2.3 From a436035424368b3d424822c7b72f99044c93dafd Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 12 Jul 2018 17:22:29 +0200 Subject: Add Groups API Signed-off-by: Clifford Wolf --- common/nextpnr.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 09bd1554..a162b85c 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -271,6 +271,7 @@ struct BaseCtx std::unordered_set belUiReload; std::unordered_set wireUiReload; std::unordered_set pipUiReload; + std::unordered_set groupUiReload; void refreshUi() { @@ -296,6 +297,11 @@ struct BaseCtx { pipUiReload.insert(pip); } + + void refreshUiGroup(GroupId group) + { + groupUiReload.insert(group); + } }; NEXTPNR_NAMESPACE_END @@ -368,6 +374,19 @@ struct Context : Arch return ret; } + NPNR_DEPRECATED std::vector getGroupGraphics(GroupId group) const { + std::vector ret; + DecalXY decalxy = getGroupDecal(group); + ret = getDecalGraphics(decalxy.decal); + for (auto &it : ret) { + it.x1 += decalxy.x; + it.x2 += decalxy.x; + it.y1 += decalxy.y; + it.y2 += decalxy.y; + } + return ret; + } + // -------------------------------------------------------------- // provided by router1.cc -- cgit v1.2.3 From 13e7cd868111300577c36a3fd45ba698ce926160 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 12 Jul 2018 21:04:47 +0200 Subject: Add GraphicElement style enum Signed-off-by: Clifford Wolf --- common/nextpnr.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index a162b85c..00a939a9 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -136,7 +136,7 @@ NEXTPNR_NAMESPACE_BEGIN struct GraphicElement { - enum + enum type_t { G_NONE, G_LINE, @@ -145,6 +145,14 @@ struct GraphicElement G_LABEL } type = G_NONE; + enum style_t + { + G_FRAME, + G_HIDDEN, + G_INACTIVE, + G_ACTIVE, + } style = G_FRAME; + float x1 = 0, y1 = 0, x2 = 0, y2 = 0, z = 0; std::string text; }; -- cgit v1.2.3 From b8a42ff53b1fbb6e03d169d14e58180a750f4cad Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 12 Jul 2018 22:04:13 +0200 Subject: Updates from clang-format Signed-off-by: Clifford Wolf --- common/nextpnr.h | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 00a939a9..5e8c2362 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -268,9 +268,9 @@ struct BaseCtx delete idstring_idx_to_str; } - Context *getCtx() { return reinterpret_cast(this); } + Context *getCtx() { return reinterpret_cast(this); } - const Context *getCtx() const { return reinterpret_cast(this); } + const Context *getCtx() const { return reinterpret_cast(this); } // -------------------------------------------------------------- @@ -281,35 +281,17 @@ struct BaseCtx std::unordered_set pipUiReload; std::unordered_set groupUiReload; - void refreshUi() - { - allUiReload = true; - } + void refreshUi() { allUiReload = true; } - void refreshUiFrame() - { - frameUiReload = true; - } + void refreshUiFrame() { frameUiReload = true; } - void refreshUiBel(BelId bel) - { - belUiReload.insert(bel); - } + void refreshUiBel(BelId bel) { belUiReload.insert(bel); } - void refreshUiWire(WireId wire) - { - wireUiReload.insert(wire); - } + void refreshUiWire(WireId wire) { wireUiReload.insert(wire); } - void refreshUiPip(PipId pip) - { - pipUiReload.insert(pip); - } + void refreshUiPip(PipId pip) { pipUiReload.insert(pip); } - void refreshUiGroup(GroupId group) - { - groupUiReload.insert(group); - } + void refreshUiGroup(GroupId group) { groupUiReload.insert(group); } }; NEXTPNR_NAMESPACE_END @@ -330,7 +312,8 @@ struct Context : Arch // -------------------------------------------------------------- - NPNR_DEPRECATED std::vector getFrameGraphics() const { + NPNR_DEPRECATED std::vector getFrameGraphics() const + { std::vector ret; DecalXY decalxy = getFrameDecal(); ret = getDecalGraphics(decalxy.decal); @@ -343,7 +326,8 @@ struct Context : Arch return ret; } - NPNR_DEPRECATED std::vector getBelGraphics(BelId bel) const { + NPNR_DEPRECATED std::vector getBelGraphics(BelId bel) const + { std::vector ret; DecalXY decalxy = getBelDecal(bel); ret = getDecalGraphics(decalxy.decal); @@ -356,7 +340,8 @@ struct Context : Arch return ret; } - NPNR_DEPRECATED std::vector getWireGraphics(WireId wire) const { + NPNR_DEPRECATED std::vector getWireGraphics(WireId wire) const + { std::vector ret; DecalXY decalxy = getWireDecal(wire); ret = getDecalGraphics(decalxy.decal); @@ -369,7 +354,8 @@ struct Context : Arch return ret; } - NPNR_DEPRECATED std::vector getPipGraphics(PipId pip) const { + NPNR_DEPRECATED std::vector getPipGraphics(PipId pip) const + { std::vector ret; DecalXY decalxy = getPipDecal(pip); ret = getDecalGraphics(decalxy.decal); @@ -382,7 +368,8 @@ struct Context : Arch return ret; } - NPNR_DEPRECATED std::vector getGroupGraphics(GroupId group) const { + NPNR_DEPRECATED std::vector getGroupGraphics(GroupId group) const + { std::vector ret; DecalXY decalxy = getGroupDecal(group); ret = getDecalGraphics(decalxy.decal); -- cgit v1.2.3 From 499951cb65ff31fe15aa360a6b44371b13815d66 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Thu, 12 Jul 2018 21:30:36 +0100 Subject: Remove legacy graphics API For now we do not optimize the OpenGL renderer against the new decal API, but this can be done in the future. --- common/nextpnr.h | 72 -------------------------------------------------------- 1 file changed, 72 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 5e8c2362..50465869 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -312,78 +312,6 @@ struct Context : Arch // -------------------------------------------------------------- - NPNR_DEPRECATED std::vector getFrameGraphics() const - { - std::vector ret; - DecalXY decalxy = getFrameDecal(); - ret = getDecalGraphics(decalxy.decal); - for (auto &it : ret) { - it.x1 += decalxy.x; - it.x2 += decalxy.x; - it.y1 += decalxy.y; - it.y2 += decalxy.y; - } - return ret; - } - - NPNR_DEPRECATED std::vector getBelGraphics(BelId bel) const - { - std::vector ret; - DecalXY decalxy = getBelDecal(bel); - ret = getDecalGraphics(decalxy.decal); - for (auto &it : ret) { - it.x1 += decalxy.x; - it.x2 += decalxy.x; - it.y1 += decalxy.y; - it.y2 += decalxy.y; - } - return ret; - } - - NPNR_DEPRECATED std::vector getWireGraphics(WireId wire) const - { - std::vector ret; - DecalXY decalxy = getWireDecal(wire); - ret = getDecalGraphics(decalxy.decal); - for (auto &it : ret) { - it.x1 += decalxy.x; - it.x2 += decalxy.x; - it.y1 += decalxy.y; - it.y2 += decalxy.y; - } - return ret; - } - - NPNR_DEPRECATED std::vector getPipGraphics(PipId pip) const - { - std::vector ret; - DecalXY decalxy = getPipDecal(pip); - ret = getDecalGraphics(decalxy.decal); - for (auto &it : ret) { - it.x1 += decalxy.x; - it.x2 += decalxy.x; - it.y1 += decalxy.y; - it.y2 += decalxy.y; - } - return ret; - } - - NPNR_DEPRECATED std::vector getGroupGraphics(GroupId group) const - { - std::vector ret; - DecalXY decalxy = getGroupDecal(group); - ret = getDecalGraphics(decalxy.decal); - for (auto &it : ret) { - it.x1 += decalxy.x; - it.x2 += decalxy.x; - it.y1 += decalxy.y; - it.y2 += decalxy.y; - } - return ret; - } - - // -------------------------------------------------------------- - // provided by router1.cc bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay); -- cgit v1.2.3 From a8c84e90a39c54174dd24b5b76bd17aed8311481 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Fri, 13 Jul 2018 20:53:52 +0100 Subject: Make GUI nice and smooth. --- common/nextpnr.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 50465869..efcab9fc 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -238,6 +238,16 @@ struct CellInfo std::unordered_map pins; }; +struct UIUpdatesRequired +{ + bool allUIReload; + bool frameUIReload; + std::unordered_set belUIReload; + std::unordered_set wireUIReload; + std::unordered_set pipUIReload; + std::unordered_set groupUIReload; +}; + struct BaseCtx { // -------------------------------------------------------------- @@ -260,6 +270,8 @@ struct BaseCtx idstring_idx_to_str = new std::vector; IdString::initialize_add(this, "", 0); IdString::initialize_arch(this); + + allUiReload = true; } ~BaseCtx() @@ -292,6 +304,25 @@ struct BaseCtx void refreshUiPip(PipId pip) { pipUiReload.insert(pip); } void refreshUiGroup(GroupId group) { groupUiReload.insert(group); } + + UIUpdatesRequired getUIUpdatesRequired(void) + { + UIUpdatesRequired req; + req.allUIReload = allUiReload; + req.frameUIReload = frameUiReload; + req.belUIReload = belUiReload; + req.wireUIReload = wireUiReload; + req.pipUIReload = pipUiReload; + req.groupUIReload = groupUiReload; + + allUiReload = false; + frameUiReload = false; + belUiReload.clear(); + wireUiReload.clear(); + pipUiReload.clear(); + groupUiReload.clear(); + return req; + } }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 9b17fe385cf7e8d3025747b5f7c7822ac2d99920 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 11:10:31 +0100 Subject: Refactor proxies to nextpnr. --- common/nextpnr.h | 170 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 138 insertions(+), 32 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index efcab9fc..c3fb913c 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -26,6 +26,7 @@ #include #include #include +#include #ifndef NEXTPNR_H #define NEXTPNR_H @@ -248,21 +249,37 @@ struct UIUpdatesRequired std::unordered_set groupUIReload; }; -struct BaseCtx +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_; - mutable std::unordered_map *idstring_str_to_idx; - mutable std::vector *idstring_idx_to_str; + bool allUiReload = false; + bool frameUiReload = false; + std::unordered_set belUiReload; + std::unordered_set wireUiReload; + std::unordered_set pipUiReload; + std::unordered_set groupUiReload; +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> nets; std::unordered_map> cells; + mutable std::unordered_map *idstring_str_to_idx; + mutable std::vector *idstring_idx_to_str; BaseCtx() { @@ -286,41 +303,83 @@ struct BaseCtx // -------------------------------------------------------------- - bool allUiReload = false; - bool frameUiReload = false; - std::unordered_set belUiReload; - std::unordered_set wireUiReload; - std::unordered_set pipUiReload; - std::unordered_set groupUiReload; + // 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; + +}; - void refreshUi() { allUiReload = true; } +// 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; + } - void refreshUiFrame() { frameUiReload = true; } + void refreshUiFrame(void) + { + base_->frameUiReload = true; + } - void refreshUiBel(BelId bel) { belUiReload.insert(bel); } + void refreshUiBel(BelId bel) + { + base_->belUiReload.insert(bel); + } - void refreshUiWire(WireId wire) { wireUiReload.insert(wire); } + void refreshUiWire(WireId wire) + { + base_->wireUiReload.insert(wire); + } - void refreshUiPip(PipId pip) { pipUiReload.insert(pip); } + void refreshUiPip(PipId pip) + { + base_->pipUiReload.insert(pip); + } - void refreshUiGroup(GroupId group) { groupUiReload.insert(group); } + void refreshUiGroup(GroupId group) + { + base_->groupUiReload.insert(group); + } UIUpdatesRequired getUIUpdatesRequired(void) { UIUpdatesRequired req; - req.allUIReload = allUiReload; - req.frameUIReload = frameUiReload; - req.belUIReload = belUiReload; - req.wireUIReload = wireUiReload; - req.pipUIReload = pipUiReload; - req.groupUIReload = groupUiReload; - - allUiReload = false; - frameUiReload = false; - belUiReload.clear(); - wireUiReload.clear(); - pipUiReload.clear(); - groupUiReload.clear(); + 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; } }; @@ -331,6 +390,53 @@ 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; -- cgit v1.2.3 From 8ca7a6da2525463be5be4ee9f62cfae0acc06b01 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 11:10:59 +0100 Subject: clang-format --- common/nextpnr.h | 72 ++++++++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 46 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index c3fb913c..6228e653 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #ifndef NEXTPNR_H #define NEXTPNR_H @@ -261,7 +261,8 @@ class BaseCtx friend class MutateContext; friend class BaseReadCtx; friend class BaseMutateCtx; -private: + + private: mutable boost::shared_mutex mtx_; bool allUiReload = false; @@ -271,7 +272,7 @@ private: std::unordered_set pipUiReload; std::unordered_set groupUiReload; -public: + public: IdString id(const std::string &s) const { return IdString(this, s); } IdString id(const char *s) const { return IdString(this, s); } @@ -311,16 +312,16 @@ public: // 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: + protected: const BaseCtx *base_; -public: + + public: BaseReadCtx(const BaseCtx *base) : base_(base) {} }; @@ -328,41 +329,23 @@ public: // contain. class BaseMutateCtx { -protected: + protected: BaseCtx *base_; -public: + public: BaseMutateCtx(BaseCtx *base) : base_(base) {} - void refreshUi(void) - { - base_->allUiReload = true; - } + void refreshUi(void) { base_->allUiReload = true; } - void refreshUiFrame(void) - { - base_->frameUiReload = true; - } + void refreshUiFrame(void) { base_->frameUiReload = true; } - void refreshUiBel(BelId bel) - { - base_->belUiReload.insert(bel); - } + void refreshUiBel(BelId bel) { base_->belUiReload.insert(bel); } - void refreshUiWire(WireId wire) - { - base_->wireUiReload.insert(wire); - } + void refreshUiWire(WireId wire) { base_->wireUiReload.insert(wire); } - void refreshUiPip(PipId pip) - { - base_->pipUiReload.insert(pip); - } + void refreshUiPip(PipId pip) { base_->pipUiReload.insert(pip); } - void refreshUiGroup(GroupId group) - { - base_->groupUiReload.insert(group); - } + void refreshUiGroup(GroupId group) { base_->groupUiReload.insert(group); } UIUpdatesRequired getUIUpdatesRequired(void) { @@ -394,49 +377,46 @@ NEXTPNR_NAMESPACE_BEGIN class ReadContext : public ArchReadMethods { friend class BaseCtx; -private: + + private: boost::shared_mutex *lock_; - ReadContext(const Arch *parent) : ArchReadMethods(parent), lock_(&parent->mtx_) - { - lock_->lock_shared(); - } -public: + 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; - } + 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: + + private: boost::shared_mutex *lock_; MutateContext(Arch *parent) : ArchReadMethods(parent), ArchMutateMethods(parent), lock_(&parent->mtx_) { lock_->lock(); } -public: + + public: ~MutateContext() { if (lock_ != nullptr) { lock_->unlock(); } } - MutateContext(MutateContext &&other): ArchReadMethods(other), ArchMutateMethods(other), lock_(other.lock_) + MutateContext(MutateContext &&other) : ArchReadMethods(other), ArchMutateMethods(other), lock_(other.lock_) { other.lock_ = nullptr; } }; - struct Context : Arch { bool verbose = false; -- cgit v1.2.3 From d9c3c117a38c8bc42cfb96255b4762965bc1611b Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 18:50:34 +0100 Subject: Revert "clang-format" This reverts commit 8ca7a6da2525463be5be4ee9f62cfae0acc06b01. --- common/nextpnr.h | 72 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 26 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 6228e653..c3fb913c 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include #include #include +#include #ifndef NEXTPNR_H #define NEXTPNR_H @@ -261,8 +261,7 @@ class BaseCtx friend class MutateContext; friend class BaseReadCtx; friend class BaseMutateCtx; - - private: +private: mutable boost::shared_mutex mtx_; bool allUiReload = false; @@ -272,7 +271,7 @@ class BaseCtx std::unordered_set pipUiReload; std::unordered_set groupUiReload; - public: +public: IdString id(const std::string &s) const { return IdString(this, s); } IdString id(const char *s) const { return IdString(this, s); } @@ -312,16 +311,16 @@ class BaseCtx // 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: +protected: const BaseCtx *base_; - - public: +public: BaseReadCtx(const BaseCtx *base) : base_(base) {} }; @@ -329,23 +328,41 @@ class BaseReadCtx // contain. class BaseMutateCtx { - protected: +protected: BaseCtx *base_; - public: +public: BaseMutateCtx(BaseCtx *base) : base_(base) {} - void refreshUi(void) { base_->allUiReload = true; } + void refreshUi(void) + { + base_->allUiReload = true; + } - void refreshUiFrame(void) { base_->frameUiReload = true; } + void refreshUiFrame(void) + { + base_->frameUiReload = true; + } - void refreshUiBel(BelId bel) { base_->belUiReload.insert(bel); } + void refreshUiBel(BelId bel) + { + base_->belUiReload.insert(bel); + } - void refreshUiWire(WireId wire) { base_->wireUiReload.insert(wire); } + void refreshUiWire(WireId wire) + { + base_->wireUiReload.insert(wire); + } - void refreshUiPip(PipId pip) { base_->pipUiReload.insert(pip); } + void refreshUiPip(PipId pip) + { + base_->pipUiReload.insert(pip); + } - void refreshUiGroup(GroupId group) { base_->groupUiReload.insert(group); } + void refreshUiGroup(GroupId group) + { + base_->groupUiReload.insert(group); + } UIUpdatesRequired getUIUpdatesRequired(void) { @@ -377,46 +394,49 @@ NEXTPNR_NAMESPACE_BEGIN class ReadContext : public ArchReadMethods { friend class BaseCtx; - - private: +private: boost::shared_mutex *lock_; - ReadContext(const Arch *parent) : ArchReadMethods(parent), lock_(&parent->mtx_) { lock_->lock_shared(); } - - public: + 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; } + 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: +private: boost::shared_mutex *lock_; MutateContext(Arch *parent) : ArchReadMethods(parent), ArchMutateMethods(parent), lock_(&parent->mtx_) { lock_->lock(); } - - public: +public: ~MutateContext() { if (lock_ != nullptr) { lock_->unlock(); } } - MutateContext(MutateContext &&other) : ArchReadMethods(other), ArchMutateMethods(other), lock_(other.lock_) + MutateContext(MutateContext &&other): ArchReadMethods(other), ArchMutateMethods(other), lock_(other.lock_) { other.lock_ = nullptr; } }; + struct Context : Arch { bool verbose = false; -- cgit v1.2.3 From b0c05c7f751cf68165849a8f28d389541456f956 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 18:50:37 +0100 Subject: Revert "Refactor proxies to nextpnr." This reverts commit 9b17fe385cf7e8d3025747b5f7c7822ac2d99920. --- common/nextpnr.h | 170 +++++++++++-------------------------------------------- 1 file changed, 32 insertions(+), 138 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index c3fb913c..efcab9fc 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -26,7 +26,6 @@ #include #include #include -#include #ifndef NEXTPNR_H #define NEXTPNR_H @@ -249,37 +248,21 @@ struct UIUpdatesRequired std::unordered_set groupUIReload; }; -class ReadContext; -class MutateContext; -class BaseReadCtx; -class BaseMutateCtx; - -// Data that every architecture object should contain. -class BaseCtx +struct 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 belUiReload; - std::unordered_set wireUiReload; - std::unordered_set pipUiReload; - std::unordered_set groupUiReload; + mutable std::unordered_map *idstring_str_to_idx; + mutable std::vector *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> nets; std::unordered_map> cells; - mutable std::unordered_map *idstring_str_to_idx; - mutable std::vector *idstring_idx_to_str; BaseCtx() { @@ -303,83 +286,41 @@ public: // -------------------------------------------------------------- - // 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) {} + bool allUiReload = false; + bool frameUiReload = false; + std::unordered_set belUiReload; + std::unordered_set wireUiReload; + std::unordered_set pipUiReload; + std::unordered_set groupUiReload; - void refreshUi(void) - { - base_->allUiReload = true; - } + void refreshUi() { allUiReload = true; } - void refreshUiFrame(void) - { - base_->frameUiReload = true; - } + void refreshUiFrame() { frameUiReload = true; } - void refreshUiBel(BelId bel) - { - base_->belUiReload.insert(bel); - } + void refreshUiBel(BelId bel) { belUiReload.insert(bel); } - void refreshUiWire(WireId wire) - { - base_->wireUiReload.insert(wire); - } + void refreshUiWire(WireId wire) { wireUiReload.insert(wire); } - void refreshUiPip(PipId pip) - { - base_->pipUiReload.insert(pip); - } + void refreshUiPip(PipId pip) { pipUiReload.insert(pip); } - void refreshUiGroup(GroupId group) - { - base_->groupUiReload.insert(group); - } + void refreshUiGroup(GroupId group) { groupUiReload.insert(group); } 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(); + req.allUIReload = allUiReload; + req.frameUIReload = frameUiReload; + req.belUIReload = belUiReload; + req.wireUIReload = wireUiReload; + req.pipUIReload = pipUiReload; + req.groupUIReload = groupUiReload; + + allUiReload = false; + frameUiReload = false; + belUiReload.clear(); + wireUiReload.clear(); + pipUiReload.clear(); + groupUiReload.clear(); return req; } }; @@ -390,53 +331,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; -- cgit v1.2.3 From 36b4e3382dc552fcd1b078bdd246dc14379394a1 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 18:50:50 +0100 Subject: Revert "Make GUI nice and smooth." This reverts commit a8c84e90a39c54174dd24b5b76bd17aed8311481. --- common/nextpnr.h | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index efcab9fc..50465869 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -238,16 +238,6 @@ struct CellInfo std::unordered_map pins; }; -struct UIUpdatesRequired -{ - bool allUIReload; - bool frameUIReload; - std::unordered_set belUIReload; - std::unordered_set wireUIReload; - std::unordered_set pipUIReload; - std::unordered_set groupUIReload; -}; - struct BaseCtx { // -------------------------------------------------------------- @@ -270,8 +260,6 @@ struct BaseCtx idstring_idx_to_str = new std::vector; IdString::initialize_add(this, "", 0); IdString::initialize_arch(this); - - allUiReload = true; } ~BaseCtx() @@ -304,25 +292,6 @@ struct BaseCtx void refreshUiPip(PipId pip) { pipUiReload.insert(pip); } void refreshUiGroup(GroupId group) { groupUiReload.insert(group); } - - UIUpdatesRequired getUIUpdatesRequired(void) - { - UIUpdatesRequired req; - req.allUIReload = allUiReload; - req.frameUIReload = frameUiReload; - req.belUIReload = belUiReload; - req.wireUIReload = wireUiReload; - req.pipUIReload = pipUiReload; - req.groupUIReload = groupUiReload; - - allUiReload = false; - frameUiReload = false; - belUiReload.clear(); - wireUiReload.clear(); - pipUiReload.clear(); - groupUiReload.clear(); - return req; - } }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3