aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-07-14 11:10:59 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-07-14 11:10:59 +0100
commit8ca7a6da2525463be5be4ee9f62cfae0acc06b01 (patch)
treeb3c2c800af28be09a988b53cba8c9ce0d233beb6
parent9b17fe385cf7e8d3025747b5f7c7822ac2d99920 (diff)
downloadnextpnr-8ca7a6da2525463be5be4ee9f62cfae0acc06b01.tar.gz
nextpnr-8ca7a6da2525463be5be4ee9f62cfae0acc06b01.tar.bz2
nextpnr-8ca7a6da2525463be5be4ee9f62cfae0acc06b01.zip
clang-format
-rw-r--r--common/nextpnr.cc11
-rw-r--r--common/nextpnr.h72
-rw-r--r--common/place_common.h6
-rw-r--r--common/router1.cc1
-rw-r--r--ice40/arch.cc104
-rw-r--r--ice40/arch.h55
6 files changed, 80 insertions, 169 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc
index 54df5de1..33230db0 100644
--- a/common/nextpnr.cc
+++ b/common/nextpnr.cc
@@ -21,16 +21,9 @@
NEXTPNR_NAMESPACE_BEGIN
-MutateContext BaseCtx::rwproxy(void)
-{
- return MutateContext(reinterpret_cast<Arch *>(this));
-}
-
-ReadContext BaseCtx::rproxy(void) const
-{
- return ReadContext(reinterpret_cast<const Arch *>(this));
-}
+MutateContext BaseCtx::rwproxy(void) { return MutateContext(reinterpret_cast<Arch *>(this)); }
+ReadContext BaseCtx::rproxy(void) const { return ReadContext(reinterpret_cast<const Arch *>(this)); }
assertion_failure::assertion_failure(std::string msg, std::string expr_str, std::string filename, int line)
: runtime_error("Assertion failure: " + msg + " (" + filename + ":" + std::to_string(line) + ")"), msg(msg),
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 <algorithm>
#include <assert.h>
+#include <boost/thread/shared_mutex.hpp>
#include <memory>
#include <stdexcept>
#include <stdint.h>
@@ -26,7 +27,6 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
-#include <boost/thread/shared_mutex.hpp>
#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<PipId> pipUiReload;
std::unordered_set<GroupId> 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;
diff --git a/common/place_common.h b/common/place_common.h
index 96ac48a9..dac2e607 100644
--- a/common/place_common.h
+++ b/common/place_common.h
@@ -29,8 +29,7 @@ NEXTPNR_NAMESPACE_BEGIN
typedef int64_t wirelen_t;
// Get the total estimated wirelength for a net
-template <typename T>
-wirelen_t get_net_wirelength(const T &proxy, const Context *ctx, const NetInfo *net, float &tns)
+template <typename T> wirelen_t get_net_wirelength(const T &proxy, const Context *ctx, const NetInfo *net, float &tns)
{
wirelen_t wirelength = 0;
int driver_x, driver_y;
@@ -81,8 +80,7 @@ wirelen_t get_net_wirelength(const T &proxy, const Context *ctx, const NetInfo *
}
// Return the wirelength of all nets connected to a cell
-template <typename T>
-wirelen_t get_cell_wirelength(const T &proxy, const Context *ctx, const CellInfo *cell)
+template <typename T> wirelen_t get_cell_wirelength(const T &proxy, const Context *ctx, const CellInfo *cell)
{
std::set<IdString> nets;
for (auto p : cell->ports) {
diff --git a/common/router1.cc b/common/router1.cc
index f7a7e8a2..dc75a153 100644
--- a/common/router1.cc
+++ b/common/router1.cc
@@ -136,7 +136,6 @@ struct Router
int thisVisitCnt = 0;
int thisVisitCntLimit = 0;
-
while (!queue.empty() && (thisVisitCntLimit == 0 || thisVisitCnt < thisVisitCntLimit)) {
QueuedWire qw = queue.top();
queue.pop();
diff --git a/ice40/arch.cc b/ice40/arch.cc
index 790167e9..8f2731c6 100644
--- a/ice40/arch.cc
+++ b/ice40/arch.cc
@@ -259,99 +259,43 @@ BelRange Arch::getBelsAtSameTile(BelId bel) const
// -----------------------------------------------------------------------
// Shorthands to ArchProxy
-BelId Arch::getBelByName(IdString name) const
-{
- return rproxy().getBelByName(name);
-}
+BelId Arch::getBelByName(IdString name) const { return rproxy().getBelByName(name); }
-void Arch::bindWire(WireId wire, IdString net, PlaceStrength strength)
-{
- rwproxy().bindWire(wire, net, strength);
-}
+void Arch::bindWire(WireId wire, IdString net, PlaceStrength strength) { rwproxy().bindWire(wire, net, strength); }
-void Arch::unbindWire(WireId wire)
-{
- rwproxy().unbindWire(wire);
-}
+void Arch::unbindWire(WireId wire) { rwproxy().unbindWire(wire); }
-void Arch::bindBel(BelId bel, IdString cell, PlaceStrength strength) {
- rwproxy().bindBel(bel, cell, strength);
-}
+void Arch::bindBel(BelId bel, IdString cell, PlaceStrength strength) { rwproxy().bindBel(bel, cell, strength); }
-void Arch::unbindBel(BelId bel)
-{
- rwproxy().unbindBel(bel);
-}
+void Arch::unbindBel(BelId bel) { rwproxy().unbindBel(bel); }
-bool Arch::checkBelAvail(BelId bel) const
-{
- return rproxy().checkBelAvail(bel);
-}
+bool Arch::checkBelAvail(BelId bel) const { return rproxy().checkBelAvail(bel); }
-IdString Arch::getBoundBelCell(BelId bel) const
-{
- return rproxy().getBoundBelCell(bel);
-}
+IdString Arch::getBoundBelCell(BelId bel) const { return rproxy().getBoundBelCell(bel); }
-IdString Arch::getConflictingBelCell(BelId bel) const
-{
- return rproxy().getConflictingBelCell(bel);
-}
+IdString Arch::getConflictingBelCell(BelId bel) const { return rproxy().getConflictingBelCell(bel); }
-WireId Arch::getWireByName(IdString name) const
-{
- return rproxy().getWireByName(name);
-}
+WireId Arch::getWireByName(IdString name) const { return rproxy().getWireByName(name); }
-WireId Arch::getWireBelPin(BelId bel, PortPin pin) const
-{
- return rproxy().getWireBelPin(bel, pin);
-}
+WireId Arch::getWireBelPin(BelId bel, PortPin pin) const { return rproxy().getWireBelPin(bel, pin); }
-bool Arch::checkWireAvail(WireId wire) const
-{
- return rproxy().checkWireAvail(wire);
-}
+bool Arch::checkWireAvail(WireId wire) const { return rproxy().checkWireAvail(wire); }
-IdString Arch::getBoundWireNet(WireId wire) const
-{
- return rproxy().getBoundWireNet(wire);
-}
+IdString Arch::getBoundWireNet(WireId wire) const { return rproxy().getBoundWireNet(wire); }
-IdString Arch::getConflictingWireNet(WireId wire) const
-{
- return rproxy().getConflictingWireNet(wire);
-}
+IdString Arch::getConflictingWireNet(WireId wire) const { return rproxy().getConflictingWireNet(wire); }
-PipId Arch::getPipByName(IdString name) const
-{
- return rproxy().getPipByName(name);
-}
+PipId Arch::getPipByName(IdString name) const { return rproxy().getPipByName(name); }
-void Arch::bindPip(PipId pip, IdString net, PlaceStrength strength)
-{
- return rwproxy().bindPip(pip, net, strength);
-}
+void Arch::bindPip(PipId pip, IdString net, PlaceStrength strength) { return rwproxy().bindPip(pip, net, strength); }
-void Arch::unbindPip(PipId pip)
-{
- return rwproxy().unbindPip(pip);
-}
+void Arch::unbindPip(PipId pip) { return rwproxy().unbindPip(pip); }
-bool Arch::checkPipAvail(PipId pip) const
-{
- return rproxy().checkPipAvail(pip);
-}
+bool Arch::checkPipAvail(PipId pip) const { return rproxy().checkPipAvail(pip); }
-IdString Arch::getBoundPipNet(PipId pip) const
-{
- return rproxy().getBoundPipNet(pip);
-}
+IdString Arch::getBoundPipNet(PipId pip) const { return rproxy().getBoundPipNet(pip); }
-IdString Arch::getConflictingPipNet(PipId pip) const
-{
- return rproxy().getConflictingPipNet(pip);
-}
+IdString Arch::getConflictingPipNet(PipId pip) const { return rproxy().getConflictingPipNet(pip); }
// -----------------------------------------------------------------------
@@ -630,8 +574,7 @@ std::vector<GraphicElement> ArchReadMethods::getDecalGraphics(DecalId decal) con
}
if (bel_type == TYPE_ICESTORM_RAM) {
- for (int i = 0; i < 2; i++)
- {
+ for (int i = 0; i < 2; i++) {
int tx = chip_info->bel_data[bel.index].x;
int ty = chip_info->bel_data[bel.index].y + i;
@@ -641,7 +584,7 @@ std::vector<GraphicElement> ArchReadMethods::getDecalGraphics(DecalId decal) con
el.x1 = chip_info->bel_data[bel.index].x + logic_cell_x1;
el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2;
el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1;
- el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + 7*logic_cell_pitch;
+ el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + 7 * logic_cell_pitch;
el.z = 0;
ret.push_back(el);
@@ -936,9 +879,6 @@ void ArchMutateMethods::unbindPip(PipId pip)
refreshUiWire(dst);
}
-CellInfo *ArchMutateMethods::getCell(IdString cell)
-{
- return parent_->cells.at(cell).get();
-}
+CellInfo *ArchMutateMethods::getCell(IdString cell) { return parent_->cells.at(cell).get(); }
NEXTPNR_NAMESPACE_END
diff --git a/ice40/arch.h b/ice40/arch.h
index 5d4eaedf..f41990c3 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -343,7 +343,8 @@ class Arch : public BaseCtx
// We let proxy methods access our state.
friend class ArchMutateMethods;
friend class ArchReadMethods;
-private:
+
+ private:
// All of the following...
std::vector<IdString> bel_to_cell;
std::vector<IdString> wire_to_net;
@@ -353,7 +354,7 @@ private:
mutable std::unordered_map<IdString, int> wire_by_name;
mutable std::unordered_map<IdString, int> pip_by_name;
-public:
+ public:
const ChipInfoPOD *chip_info;
const PackageInfoPOD *package_info;
@@ -410,10 +411,7 @@ public:
return id(chip_info->bel_data[bel.index].name.get());
}
- uint32_t getBelChecksum(BelId bel) const
- {
- return bel.index;
- }
+ uint32_t getBelChecksum(BelId bel) const { return bel.index; }
BelRange getBels() const
{
@@ -445,7 +443,6 @@ public:
return chip_info->bel_data[bel.index].type;
}
-
BelPin getBelPinUphill(WireId wire) const
{
BelPin ret;
@@ -549,7 +546,6 @@ public:
return range;
}
-
BelId getPackagePinBel(const std::string &pin) const;
std::string getBelPackagePin(BelId bel) const;
@@ -611,8 +607,9 @@ public:
};
// Read-only methods on Arch that require state access.
-class ArchReadMethods : public BaseReadCtx {
-private:
+class ArchReadMethods : public BaseReadCtx
+{
+ private:
const Arch *parent_;
const ChipInfoPOD *chip_info;
const std::vector<IdString> &bel_to_cell;
@@ -623,14 +620,15 @@ private:
std::unordered_map<IdString, int> &wire_by_name;
std::unordered_map<IdString, int> &pip_by_name;
-public:
- ~ArchReadMethods() noexcept { }
- ArchReadMethods(const Arch *parent) : BaseReadCtx(parent), parent_(parent),
- chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
- wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
- switches_locked(parent->switches_locked),
- bel_by_name(parent->bel_by_name), wire_by_name(parent->wire_by_name),
- pip_by_name(parent->pip_by_name) {}
+ public:
+ ~ArchReadMethods() noexcept {}
+ ArchReadMethods(const Arch *parent)
+ : BaseReadCtx(parent), parent_(parent), chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
+ wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
+ switches_locked(parent->switches_locked), bel_by_name(parent->bel_by_name),
+ wire_by_name(parent->wire_by_name), pip_by_name(parent->pip_by_name)
+ {
+ }
ArchReadMethods(ArchReadMethods &&other) noexcept : ArchReadMethods(other.parent_) {}
ArchReadMethods(const ArchReadMethods &other) : ArchReadMethods(other.parent_) {}
@@ -669,9 +667,11 @@ public:
};
// State mutating methods on Arch.
-class ArchMutateMethods : public BaseMutateCtx {
+class ArchMutateMethods : public BaseMutateCtx
+{
friend class MutateContext;
-private:
+
+ private:
Arch *parent_;
const ChipInfoPOD *chip_info;
std::vector<IdString> &bel_to_cell;
@@ -682,13 +682,14 @@ private:
std::unordered_map<IdString, int> &wire_by_name;
std::unordered_map<IdString, int> &pip_by_name;
-public:
- ArchMutateMethods(Arch *parent) : BaseMutateCtx(parent), parent_(parent),
- chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
- wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
- switches_locked(parent->switches_locked),
- bel_by_name(parent->bel_by_name), wire_by_name(parent->wire_by_name),
- pip_by_name(parent->pip_by_name) {}
+ public:
+ ArchMutateMethods(Arch *parent)
+ : BaseMutateCtx(parent), parent_(parent), chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
+ wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
+ switches_locked(parent->switches_locked), bel_by_name(parent->bel_by_name),
+ wire_by_name(parent->wire_by_name), pip_by_name(parent->pip_by_name)
+ {
+ }
ArchMutateMethods(ArchMutateMethods &&other) : ArchMutateMethods(other.parent_) {}
ArchMutateMethods(const ArchMutateMethods &other) : ArchMutateMethods(other.parent_) {}
~ArchMutateMethods() {}