clangformat
This commit is contained in:
parent
7d62c89fd5
commit
85fc356fc1
@ -205,10 +205,7 @@ struct DecalXY
|
|||||||
DecalId decal;
|
DecalId decal;
|
||||||
float x = 0, y = 0;
|
float x = 0, y = 0;
|
||||||
|
|
||||||
bool operator==(const DecalXY &other) const
|
bool operator==(const DecalXY &other) const { return (decal == other.decal && x == other.x && y == other.y); }
|
||||||
{
|
|
||||||
return (decal == other.decal && x == other.x && y == other.y);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BelPin
|
struct BelPin
|
||||||
|
@ -75,16 +75,18 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("help") || argc == 1) {
|
if (vm.count("help") || argc == 1) {
|
||||||
std::cout << boost::filesystem::basename(argv[0]) << " -- Next Generation Place and Route (git "
|
std::cout << boost::filesystem::basename(argv[0])
|
||||||
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
<< " -- Next Generation Place and Route (git "
|
||||||
|
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
std::cout << options << "\n";
|
std::cout << options << "\n";
|
||||||
return argc != 1;
|
return argc != 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("version")) {
|
if (vm.count("version")) {
|
||||||
std::cout << boost::filesystem::basename(argv[0]) << " -- Next Generation Place and Route (git "
|
std::cout << boost::filesystem::basename(argv[0])
|
||||||
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
<< " -- Next Generation Place and Route (git "
|
||||||
|
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BoundingBox() : x0_(pinf), y0_(pinf), x1_(ninf), y1_(ninf) {}
|
BoundingBox() : x0_(pinf), y0_(pinf), x1_(ninf), y1_(ninf) {}
|
||||||
|
|
||||||
BoundingBox(const BoundingBox &other) : x0_(other.x0_), y0_(other.y0_), x1_(other.x1_), y1_(other.y1_) {}
|
BoundingBox(const BoundingBox &other) : x0_(other.x0_), y0_(other.y0_), x1_(other.x1_), y1_(other.y1_) {}
|
||||||
@ -83,7 +82,7 @@ template <typename CoordinateT, typename ElementT> class QuadTreeNode
|
|||||||
CoordinateT y0() const { return y0_; }
|
CoordinateT y0() const { return y0_; }
|
||||||
CoordinateT x1() const { return x1_; }
|
CoordinateT x1() const { return x1_; }
|
||||||
CoordinateT y1() const { return y1_; }
|
CoordinateT y1() const { return y1_; }
|
||||||
|
|
||||||
void setX0(CoordinateT v) { x0_ = v; }
|
void setX0(CoordinateT v) { x0_ = v; }
|
||||||
void setY0(CoordinateT v) { y0_ = v; }
|
void setY0(CoordinateT v) { y0_ = v; }
|
||||||
void setX1(CoordinateT v) { x1_ = v; }
|
void setX1(CoordinateT v) { x1_ = v; }
|
||||||
|
@ -25,7 +25,6 @@ NEXTPNR_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
namespace TreeModel {
|
namespace TreeModel {
|
||||||
|
|
||||||
|
|
||||||
// converts 'aa123bb432' -> ['aa', '123', 'bb', '432']
|
// converts 'aa123bb432' -> ['aa', '123', 'bb', '432']
|
||||||
std::vector<QString> IdStringList::alphaNumSplit(const QString &str)
|
std::vector<QString> IdStringList::alphaNumSplit(const QString &str)
|
||||||
{
|
{
|
||||||
@ -48,7 +47,7 @@ std::vector<QString> IdStringList::alphaNumSplit(const QString &str)
|
|||||||
|
|
||||||
current_part.push_back(c);
|
current_part.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.push_back(current_part);
|
res.push_back(current_part);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@ -69,7 +68,7 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements)
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For any elements that are in managed_ but not in new, delete them.
|
// For any elements that are in managed_ but not in new, delete them.
|
||||||
for (auto &pair : managed_) {
|
for (auto &pair : managed_) {
|
||||||
if (element_set.count(pair.first) != 0) {
|
if (element_set.count(pair.first) != 0) {
|
||||||
@ -92,7 +91,7 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort new children
|
// Sort new children
|
||||||
qSort(children_.begin(), children_.end(), [&](const Item *a, const Item *b){
|
qSort(children_.begin(), children_.end(), [&](const Item *a, const Item *b) {
|
||||||
auto parts_a = alphaNumSplit(a->name());
|
auto parts_a = alphaNumSplit(a->name());
|
||||||
auto parts_b = alphaNumSplit(b->name());
|
auto parts_b = alphaNumSplit(b->name());
|
||||||
|
|
||||||
@ -104,7 +103,7 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements)
|
|||||||
for (size_t i = 0; i < parts_a.size(); i++) {
|
for (size_t i = 0; i < parts_a.size(); i++) {
|
||||||
auto &part_a = parts_a.at(i);
|
auto &part_a = parts_a.at(i);
|
||||||
auto &part_b = parts_b.at(i);
|
auto &part_b = parts_b.at(i);
|
||||||
|
|
||||||
bool a_is_number, b_is_number;
|
bool a_is_number, b_is_number;
|
||||||
int a_number = part_a.toInt(&a_is_number);
|
int a_number = part_a.toInt(&a_is_number);
|
||||||
int b_number = part_b.toInt(&b_is_number);
|
int b_number = part_b.toInt(&b_is_number);
|
||||||
@ -138,7 +137,7 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdStringList::search(QList<Item*> &results, QString text, int limit)
|
void IdStringList::search(QList<Item *> &results, QString text, int limit)
|
||||||
{
|
{
|
||||||
for (const auto &child : children_) {
|
for (const auto &child : children_) {
|
||||||
if (limit != -1 && results.size() > limit)
|
if (limit != -1 && results.size() > limit)
|
||||||
@ -149,10 +148,7 @@ void IdStringList::search(QList<Item*> &results, QString text, int limit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Model::Model(QObject *parent) : QAbstractItemModel(parent), root_(new Item("Elements", nullptr)) {}
|
||||||
Model::Model(QObject *parent) :
|
|
||||||
QAbstractItemModel(parent),
|
|
||||||
root_(new Item("Elements", nullptr)) {}
|
|
||||||
|
|
||||||
Model::~Model() {}
|
Model::~Model() {}
|
||||||
|
|
||||||
@ -176,7 +172,8 @@ void Model::loadContext(Context *ctx)
|
|||||||
belMap[std::pair<int, int>(loc.x, loc.y)].push_back(bel);
|
belMap[std::pair<int, int>(loc.x, loc.y)].push_back(bel);
|
||||||
}
|
}
|
||||||
auto belGetter = [](Context *ctx, BelId id) { return ctx->getBelName(id); };
|
auto belGetter = [](Context *ctx, BelId id) { return ctx->getBelName(id); };
|
||||||
bel_root_ = std::unique_ptr<BelXYRoot>(new BelXYRoot(ctx, "Bels", root_.get(), belMap, belGetter, ElementType::BEL));
|
bel_root_ = std::unique_ptr<BelXYRoot>(
|
||||||
|
new BelXYRoot(ctx, "Bels", root_.get(), belMap, belGetter, ElementType::BEL));
|
||||||
|
|
||||||
std::map<std::pair<int, int>, std::vector<WireId>> wireMap;
|
std::map<std::pair<int, int>, std::vector<WireId>> wireMap;
|
||||||
for (int i = 0; i < ctx->chip_info->num_wires; i++) {
|
for (int i = 0; i < ctx->chip_info->num_wires; i++) {
|
||||||
@ -186,7 +183,8 @@ void Model::loadContext(Context *ctx)
|
|||||||
wireMap[std::pair<int, int>(wire->x, wire->y)].push_back(wireid);
|
wireMap[std::pair<int, int>(wire->x, wire->y)].push_back(wireid);
|
||||||
}
|
}
|
||||||
auto wireGetter = [](Context *ctx, WireId id) { return ctx->getWireName(id); };
|
auto wireGetter = [](Context *ctx, WireId id) { return ctx->getWireName(id); };
|
||||||
wire_root_ = std::unique_ptr<WireXYRoot>(new WireXYRoot(ctx, "Wires", root_.get(), wireMap, wireGetter, ElementType::WIRE));
|
wire_root_ = std::unique_ptr<WireXYRoot>(
|
||||||
|
new WireXYRoot(ctx, "Wires", root_.get(), wireMap, wireGetter, ElementType::WIRE));
|
||||||
|
|
||||||
std::map<std::pair<int, int>, std::vector<PipId>> pipMap;
|
std::map<std::pair<int, int>, std::vector<PipId>> pipMap;
|
||||||
for (int i = 0; i < ctx->chip_info->num_pips; i++) {
|
for (int i = 0; i < ctx->chip_info->num_pips; i++) {
|
||||||
@ -196,7 +194,8 @@ void Model::loadContext(Context *ctx)
|
|||||||
pipMap[std::pair<int, int>(pip->x, pip->y)].push_back(pipid);
|
pipMap[std::pair<int, int>(pip->x, pip->y)].push_back(pipid);
|
||||||
}
|
}
|
||||||
auto pipGetter = [](Context *ctx, PipId id) { return ctx->getPipName(id); };
|
auto pipGetter = [](Context *ctx, PipId id) { return ctx->getPipName(id); };
|
||||||
pip_root_ = std::unique_ptr<PipXYRoot>(new PipXYRoot(ctx, "Pips", root_.get(), pipMap, pipGetter, ElementType::PIP));
|
pip_root_ = std::unique_ptr<PipXYRoot>(
|
||||||
|
new PipXYRoot(ctx, "Pips", root_.get(), pipMap, pipGetter, ElementType::PIP));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -284,7 +283,6 @@ Qt::ItemFlags Model::flags(const QModelIndex &index) const
|
|||||||
return Qt::ItemIsEnabled | (node->type() != ElementType::NONE ? Qt::ItemIsSelectable : Qt::NoItemFlags);
|
return Qt::ItemIsEnabled | (node->type() != ElementType::NONE ? Qt::ItemIsSelectable : Qt::NoItemFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Model::fetchMore(const QModelIndex &parent)
|
void Model::fetchMore(const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
if (ctx_ == nullptr)
|
if (ctx_ == nullptr)
|
||||||
@ -296,15 +294,12 @@ void Model::fetchMore(const QModelIndex &parent)
|
|||||||
nodeFromIndex(parent)->fetchMore();
|
nodeFromIndex(parent)->fetchMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::canFetchMore(const QModelIndex &parent) const
|
bool Model::canFetchMore(const QModelIndex &parent) const { return nodeFromIndex(parent)->canFetchMore(); }
|
||||||
{
|
|
||||||
return nodeFromIndex(parent)->canFetchMore();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QModelIndex> Model::search(QString text)
|
QList<QModelIndex> Model::search(QString text)
|
||||||
{
|
{
|
||||||
const int limit = 500;
|
const int limit = 500;
|
||||||
QList<Item*> list;
|
QList<Item *> list;
|
||||||
cell_root_->search(list, text, limit);
|
cell_root_->search(list, text, limit);
|
||||||
net_root_->search(list, text, limit);
|
net_root_->search(list, text, limit);
|
||||||
bel_root_->search(list, text, limit);
|
bel_root_->search(list, text, limit);
|
||||||
|
@ -60,14 +60,10 @@ class Item
|
|||||||
// Children that are loaded into memory.
|
// Children that are loaded into memory.
|
||||||
QList<Item *> children_;
|
QList<Item *> children_;
|
||||||
|
|
||||||
void addChild(Item *child)
|
void addChild(Item *child) { children_.append(child); }
|
||||||
{
|
|
||||||
children_.append(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Item(QString name, Item *parent) :
|
Item(QString name, Item *parent) : name_(name), parent_(parent)
|
||||||
name_(name), parent_(parent)
|
|
||||||
{
|
{
|
||||||
// Register in parent if exists.
|
// Register in parent if exists.
|
||||||
if (parent_ != nullptr) {
|
if (parent_ != nullptr) {
|
||||||
@ -90,7 +86,7 @@ class Item
|
|||||||
|
|
||||||
// indexOf gets index of child in children array.
|
// indexOf gets index of child in children array.
|
||||||
int indexOf(const Item *child) const
|
int indexOf(const Item *child) const
|
||||||
{
|
{
|
||||||
// Dropping the const for indexOf to work.
|
// Dropping the const for indexOf to work.
|
||||||
return children_.indexOf((Item *)child, 0);
|
return children_.indexOf((Item *)child, 0);
|
||||||
}
|
}
|
||||||
@ -115,23 +111,19 @@ class IdStringItem : public Item
|
|||||||
ElementType type_;
|
ElementType type_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IdStringItem(Context *ctx, IdString str, Item *parent, ElementType type) :
|
IdStringItem(Context *ctx, IdString str, Item *parent, ElementType type)
|
||||||
Item(QString(str.c_str(ctx)), parent), id_(str), type_(type) {}
|
: Item(QString(str.c_str(ctx)), parent), id_(str), type_(type)
|
||||||
|
|
||||||
virtual IdString id() const override
|
|
||||||
{
|
{
|
||||||
return id_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ElementType type() const override
|
virtual IdString id() const override { return id_; }
|
||||||
{
|
|
||||||
return type_;
|
virtual ElementType type() const override { return type_; }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// IdString list is a static list of IdStrings which can be set/updates from
|
// IdString list is a static list of IdStrings which can be set/updates from
|
||||||
// a vector of IdStrings. It will render each IdStrings as a child, with the
|
// a vector of IdStrings. It will render each IdStrings as a child, with the
|
||||||
// list sorted in a smart way.
|
// list sorted in a smart way.
|
||||||
class IdStringList : public Item
|
class IdStringList : public Item
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -144,33 +136,27 @@ class IdStringList : public Item
|
|||||||
public:
|
public:
|
||||||
// Create an IdStringList at given partent that will contain elements of
|
// Create an IdStringList at given partent that will contain elements of
|
||||||
// the given type.
|
// the given type.
|
||||||
IdStringList(QString name, Item *parent, ElementType type) :
|
IdStringList(QString name, Item *parent, ElementType type) : Item(name, parent), child_type_(type) {}
|
||||||
Item(name, parent), child_type_(type) {}
|
|
||||||
|
|
||||||
// Split a name into alpha/non-alpha parts, which is then used for sorting
|
// Split a name into alpha/non-alpha parts, which is then used for sorting
|
||||||
// of children.
|
// of children.
|
||||||
static std::vector<QString> alphaNumSplit(const QString &str);
|
static std::vector<QString> alphaNumSplit(const QString &str);
|
||||||
|
|
||||||
// getById finds a child for the given IdString.
|
// getById finds a child for the given IdString.
|
||||||
IdStringItem *getById(IdString id) const
|
IdStringItem *getById(IdString id) const { return managed_.at(id).get(); }
|
||||||
{
|
|
||||||
return managed_.at(id).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
// (Re-)create children from a list of IdStrings.
|
// (Re-)create children from a list of IdStrings.
|
||||||
void updateElements(Context *ctx, std::vector<IdString> elements);
|
void updateElements(Context *ctx, std::vector<IdString> elements);
|
||||||
|
|
||||||
// Find children that contain the given text.
|
// Find children that contain the given text.
|
||||||
void search(QList<Item*> &results, QString text, int limit);
|
void search(QList<Item *> &results, QString text, int limit);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ElementList is a dynamic list of ElementT (BelId,WireId,...) that are
|
// ElementList is a dynamic list of ElementT (BelId,WireId,...) that are
|
||||||
// automatically generated based on an overall map of elements.
|
// automatically generated based on an overall map of elements.
|
||||||
// ElementList is emitted from ElementXYRoot, and contains the actual
|
// ElementList is emitted from ElementXYRoot, and contains the actual
|
||||||
// Bels/Wires/Pips underneath it.
|
// Bels/Wires/Pips underneath it.
|
||||||
template <typename ElementT>
|
template <typename ElementT> class ElementList : public Item
|
||||||
class ElementList : public Item
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// A map from tile (X,Y) to list of ElementTs in that tile.
|
// A map from tile (X,Y) to list of ElementTs in that tile.
|
||||||
@ -193,23 +179,18 @@ class ElementList : public Item
|
|||||||
|
|
||||||
// Gets elements that this list should create from the map. This pointer is
|
// Gets elements that this list should create from the map. This pointer is
|
||||||
// short-lived (as it will change when the map mutates.
|
// short-lived (as it will change when the map mutates.
|
||||||
const std::vector<ElementT> *elements() const
|
const std::vector<ElementT> *elements() const { return &map_->at(std::make_pair(x_, y_)); }
|
||||||
{
|
|
||||||
return &map_->at(std::make_pair(x_, y_));
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElementList(Context *ctx, QString name, Item *parent, ElementMap *map, int x, int y, ElementGetter getter, ElementType type) :
|
ElementList(Context *ctx, QString name, Item *parent, ElementMap *map, int x, int y, ElementGetter getter,
|
||||||
Item(name, parent), ctx_(ctx), map_(map), x_(x), y_(y), getter_(getter), child_type_(type)
|
ElementType type)
|
||||||
|
: Item(name, parent), ctx_(ctx), map_(map), x_(x), y_(y), getter_(getter), child_type_(type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lazy loading of elements.
|
// Lazy loading of elements.
|
||||||
|
|
||||||
virtual bool canFetchMore() const override
|
virtual bool canFetchMore() const override { return (size_t)children_.size() < elements()->size(); }
|
||||||
{
|
|
||||||
return (size_t)children_.size() < elements()->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fetchMore(int count)
|
void fetchMore(int count)
|
||||||
{
|
{
|
||||||
@ -229,16 +210,14 @@ class ElementList : public Item
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void fetchMore() override
|
virtual void fetchMore() override { fetchMore(100); }
|
||||||
{
|
|
||||||
fetchMore(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// getById finds a child for the given IdString.
|
// getById finds a child for the given IdString.
|
||||||
boost::optional<Item*> getById(IdString id)
|
boost::optional<Item *> getById(IdString id)
|
||||||
{
|
{
|
||||||
// Search requires us to load all our elements...
|
// Search requires us to load all our elements...
|
||||||
while (canFetchMore()) fetchMore();
|
while (canFetchMore())
|
||||||
|
fetchMore();
|
||||||
|
|
||||||
auto res = managed_.find(id);
|
auto res = managed_.find(id);
|
||||||
if (res != managed_.end()) {
|
if (res != managed_.end()) {
|
||||||
@ -248,14 +227,15 @@ class ElementList : public Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find children that contain the given text.
|
// Find children that contain the given text.
|
||||||
void search(QList<Item*> &results, QString text, int limit)
|
void search(QList<Item *> &results, QString text, int limit)
|
||||||
{
|
{
|
||||||
// Last chance to bail out from loading entire tree into memory.
|
// Last chance to bail out from loading entire tree into memory.
|
||||||
if (limit != -1 && results.size() > limit)
|
if (limit != -1 && results.size() > limit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Search requires us to load all our elements...
|
// Search requires us to load all our elements...
|
||||||
while (canFetchMore()) fetchMore();
|
while (canFetchMore())
|
||||||
|
fetchMore();
|
||||||
|
|
||||||
for (const auto &child : children_) {
|
for (const auto &child : children_) {
|
||||||
if (limit != -1 && results.size() > limit)
|
if (limit != -1 && results.size() > limit)
|
||||||
@ -270,8 +250,7 @@ class ElementList : public Item
|
|||||||
// It can take any of {BelId,WireId,PipId} and create a tree that
|
// It can take any of {BelId,WireId,PipId} and create a tree that
|
||||||
// hierarchizes them by X and Y tile positions, when given a map from X,Y to
|
// hierarchizes them by X and Y tile positions, when given a map from X,Y to
|
||||||
// list of ElementTs in that tile.
|
// list of ElementTs in that tile.
|
||||||
template <typename ElementT>
|
template <typename ElementT> class ElementXYRoot : public Item
|
||||||
class ElementXYRoot : public Item
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// A map from tile (X,Y) to list of ElementTs in that tile.
|
// A map from tile (X,Y) to list of ElementTs in that tile.
|
||||||
@ -279,7 +258,6 @@ class ElementXYRoot : public Item
|
|||||||
// A method that converts an ElementT to an IdString.
|
// A method that converts an ElementT to an IdString.
|
||||||
using ElementGetter = std::function<IdString(Context *, ElementT)>;
|
using ElementGetter = std::function<IdString(Context *, ElementT)>;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Context *ctx_;
|
Context *ctx_;
|
||||||
// X-index children that we manage the memory for.
|
// X-index children that we manage the memory for.
|
||||||
@ -293,8 +271,8 @@ class ElementXYRoot : public Item
|
|||||||
ElementType child_type_;
|
ElementType child_type_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElementXYRoot(Context *ctx, QString name, Item *parent, ElementMap map, ElementGetter getter, ElementType type) :
|
ElementXYRoot(Context *ctx, QString name, Item *parent, ElementMap map, ElementGetter getter, ElementType type)
|
||||||
Item(name, parent), ctx_(ctx), map_(map), getter_(getter), child_type_(type)
|
: Item(name, parent), ctx_(ctx), map_(map), getter_(getter), child_type_(type)
|
||||||
{
|
{
|
||||||
// Create all X and Y label Items/ElementLists.
|
// Create all X and Y label Items/ElementLists.
|
||||||
|
|
||||||
@ -320,7 +298,8 @@ class ElementXYRoot : public Item
|
|||||||
|
|
||||||
for (auto j : y_present) {
|
for (auto j : y_present) {
|
||||||
// Create Y list ElementList.
|
// Create Y list ElementList.
|
||||||
auto item2 = new ElementList<ElementT>(ctx_, QString("Y%1").arg(j), item, &map_, i, j, getter_, child_type_);
|
auto item2 =
|
||||||
|
new ElementList<ElementT>(ctx_, QString("Y%1").arg(j), item, &map_, i, j, getter_, child_type_);
|
||||||
// Pre-populate list with one element, other Qt will never ask for more.
|
// Pre-populate list with one element, other Qt will never ask for more.
|
||||||
item2->fetchMore(1);
|
item2->fetchMore(1);
|
||||||
managed_lists_.push_back(std::move(std::unique_ptr<ElementList<ElementT>>(item2)));
|
managed_lists_.push_back(std::move(std::unique_ptr<ElementList<ElementT>>(item2)));
|
||||||
@ -329,7 +308,7 @@ class ElementXYRoot : public Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getById finds a child for the given IdString.
|
// getById finds a child for the given IdString.
|
||||||
boost::optional<Item*> getById(IdString id)
|
boost::optional<Item *> getById(IdString id)
|
||||||
{
|
{
|
||||||
// For now, scan linearly all ElementLists.
|
// For now, scan linearly all ElementLists.
|
||||||
// TODO(q3k) fix this once we have tree API from arch
|
// TODO(q3k) fix this once we have tree API from arch
|
||||||
@ -343,7 +322,7 @@ class ElementXYRoot : public Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find children that contain the given text.
|
// Find children that contain the given text.
|
||||||
void search(QList<Item*> &results, QString text, int limit)
|
void search(QList<Item *> &results, QString text, int limit)
|
||||||
{
|
{
|
||||||
for (auto &l : managed_lists_) {
|
for (auto &l : managed_lists_) {
|
||||||
if (limit != -1 && results.size() > limit)
|
if (limit != -1 && results.size() > limit)
|
||||||
@ -374,13 +353,13 @@ class Model : public QAbstractItemModel
|
|||||||
const Item *parent = node->parent();
|
const Item *parent = node->parent();
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
return createIndex(parent->indexOf(node), 0, node);
|
return createIndex(parent->indexOf(node), 0, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QModelIndex> search(QString text);
|
QList<QModelIndex> search(QString text);
|
||||||
|
|
||||||
boost::optional<Item*> nodeForIdType(ElementType type, IdString id) const
|
boost::optional<Item *> nodeForIdType(ElementType type, IdString id) const
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ElementType::BEL:
|
case ElementType::BEL:
|
||||||
@ -397,7 +376,7 @@ class Model : public QAbstractItemModel
|
|||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override QAbstractItemModel methods
|
// Override QAbstractItemModel methods
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||||
@ -410,7 +389,6 @@ class Model : public QAbstractItemModel
|
|||||||
bool canFetchMore(const QModelIndex &parent) const Q_DECL_OVERRIDE;
|
bool canFetchMore(const QModelIndex &parent) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Tree elements that we manage the memory for.
|
// Tree elements that we manage the memory for.
|
||||||
std::unique_ptr<Item> root_;
|
std::unique_ptr<Item> root_;
|
||||||
std::unique_ptr<BelXYRoot> bel_root_;
|
std::unique_ptr<BelXYRoot> bel_root_;
|
||||||
|
@ -317,15 +317,15 @@ PortType Arch::getBelPinType(BelId bel, PortPin pin) const
|
|||||||
return PortType(bel_wires[i].type);
|
return PortType(bel_wires[i].type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int b = 0, e = num_bel_wires-1;
|
int b = 0, e = num_bel_wires - 1;
|
||||||
while (b <= e) {
|
while (b <= e) {
|
||||||
int i = (b+e) / 2;
|
int i = (b + e) / 2;
|
||||||
if (bel_wires[i].port == pin)
|
if (bel_wires[i].port == pin)
|
||||||
return PortType(bel_wires[i].type);
|
return PortType(bel_wires[i].type);
|
||||||
if (bel_wires[i].port > pin)
|
if (bel_wires[i].port > pin)
|
||||||
e = i-1;
|
e = i - 1;
|
||||||
else
|
else
|
||||||
b = i+1;
|
b = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,17 +349,17 @@ WireId Arch::getBelPinWire(BelId bel, PortPin pin) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int b = 0, e = num_bel_wires-1;
|
int b = 0, e = num_bel_wires - 1;
|
||||||
while (b <= e) {
|
while (b <= e) {
|
||||||
int i = (b+e) / 2;
|
int i = (b + e) / 2;
|
||||||
if (bel_wires[i].port == pin) {
|
if (bel_wires[i].port == pin) {
|
||||||
ret.index = bel_wires[i].wire_index;
|
ret.index = bel_wires[i].wire_index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bel_wires[i].port > pin)
|
if (bel_wires[i].port > pin)
|
||||||
e = i-1;
|
e = i - 1;
|
||||||
else
|
else
|
||||||
b = i+1;
|
b = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,9 +531,9 @@ struct Arch : BaseCtx
|
|||||||
DelayInfo delay;
|
DelayInfo delay;
|
||||||
NPNR_ASSERT(wire != WireId());
|
NPNR_ASSERT(wire != WireId());
|
||||||
if (fast_part)
|
if (fast_part)
|
||||||
delay.delay = chip_info->wire_data[wire.index].fast_delay;
|
delay.delay = chip_info->wire_data[wire.index].fast_delay;
|
||||||
else
|
else
|
||||||
delay.delay = chip_info->wire_data[wire.index].slow_delay;
|
delay.delay = chip_info->wire_data[wire.index].slow_delay;
|
||||||
return delay;
|
return delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,8 +566,9 @@ void write_asc(const Context *ctx, std::ostream &out)
|
|||||||
set_config(ti, config.at(y).at(x),
|
set_config(ti, config.at(y).at(x),
|
||||||
"Cascade.IPCON_LC0" + std::to_string(lc_idx) + "_inmux02_5", true);
|
"Cascade.IPCON_LC0" + std::to_string(lc_idx) + "_inmux02_5", true);
|
||||||
else
|
else
|
||||||
set_config(ti, config.at(y).at(x), "Cascade.MULT" + std::to_string(int(tile - TILE_DSP0)) +
|
set_config(ti, config.at(y).at(x),
|
||||||
"_LC0" + std::to_string(lc_idx) + "_inmux02_5",
|
"Cascade.MULT" + std::to_string(int(tile - TILE_DSP0)) + "_LC0" +
|
||||||
|
std::to_string(lc_idx) + "_inmux02_5",
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,16 +144,18 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
if (vm.count("help") || argc == 1) {
|
if (vm.count("help") || argc == 1) {
|
||||||
help:
|
help:
|
||||||
std::cout << boost::filesystem::basename(argv[0]) << " -- Next Generation Place and Route (git "
|
std::cout << boost::filesystem::basename(argv[0])
|
||||||
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
<< " -- Next Generation Place and Route (git "
|
||||||
|
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
std::cout << options << "\n";
|
std::cout << options << "\n";
|
||||||
return argc != 1;
|
return argc != 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("version")) {
|
if (vm.count("version")) {
|
||||||
std::cout << boost::filesystem::basename(argv[0]) << " -- Next Generation Place and Route (git "
|
std::cout << boost::filesystem::basename(argv[0])
|
||||||
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
<< " -- Next Generation Place and Route (git "
|
||||||
|
"sha1 " GIT_COMMIT_HASH_STR ")\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,12 +662,12 @@ static void pack_special(Context *ctx)
|
|||||||
|
|
||||||
auto feedback_path = packed->params[ctx->id("FEEDBACK_PATH")];
|
auto feedback_path = packed->params[ctx->id("FEEDBACK_PATH")];
|
||||||
packed->params[ctx->id("FEEDBACK_PATH")] =
|
packed->params[ctx->id("FEEDBACK_PATH")] =
|
||||||
feedback_path == "DELAY" ? "0" : feedback_path == "SIMPLE"
|
feedback_path == "DELAY"
|
||||||
? "1"
|
? "0"
|
||||||
: feedback_path == "PHASE_AND_DELAY"
|
: feedback_path == "SIMPLE" ? "1"
|
||||||
? "2"
|
: feedback_path == "PHASE_AND_DELAY"
|
||||||
: feedback_path == "EXTERNAL" ? "6"
|
? "2"
|
||||||
: feedback_path;
|
: feedback_path == "EXTERNAL" ? "6" : feedback_path;
|
||||||
packed->params[ctx->id("PLLTYPE")] = std::to_string(sb_pll40_type(ctx, ci));
|
packed->params[ctx->id("PLLTYPE")] = std::to_string(sb_pll40_type(ctx, ci));
|
||||||
|
|
||||||
NetInfo *pad_packagepin_net = nullptr;
|
NetInfo *pad_packagepin_net = nullptr;
|
||||||
|
@ -164,8 +164,6 @@ class PlacementLegaliser
|
|||||||
|
|
||||||
ctx->assignArchInfo();
|
ctx->assignArchInfo();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return legalised_carries && replaced_cells;
|
return legalised_carries && replaced_cells;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,9 +462,9 @@ void json_import_ports(Context *ctx, const string &modname, const std::vector<Id
|
|||||||
|
|
||||||
ground_net(ctx, net.get());
|
ground_net(ctx, net.get());
|
||||||
log_info(" Floating wire node value, "
|
log_info(" Floating wire node value, "
|
||||||
"\'%s\' of port \'%s\' "
|
"\'%s\' of port \'%s\' "
|
||||||
"in cell \'%s\' of module \'%s\'\n, converted to zero driver",
|
"in cell \'%s\' of module \'%s\'\n, converted to zero driver",
|
||||||
wire_node->data_string.c_str(), port_name.c_str(), obj_name.c_str(), modname.c_str());
|
wire_node->data_string.c_str(), port_name.c_str(), obj_name.c_str(), modname.c_str());
|
||||||
|
|
||||||
} else
|
} else
|
||||||
log_error(" Unknown fixed type wire node "
|
log_error(" Unknown fixed type wire node "
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "quadtree.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
#include "quadtree.h"
|
|
||||||
|
|
||||||
USING_NEXTPNR_NAMESPACE
|
USING_NEXTPNR_NAMESPACE
|
||||||
|
|
||||||
@ -28,18 +28,12 @@ using QT = QuadTree<int, int>;
|
|||||||
class QuadTreeTest : public ::testing::Test
|
class QuadTreeTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual void SetUp()
|
virtual void SetUp() { qt_ = new QT(QT::BoundingBox(0, 0, width_, height_)); }
|
||||||
{
|
virtual void TearDown() { delete qt_; }
|
||||||
qt_ = new QT(QT::BoundingBox(0, 0, width_, height_));
|
|
||||||
}
|
|
||||||
virtual void TearDown()
|
|
||||||
{
|
|
||||||
delete qt_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int width_ = 100;
|
int width_ = 100;
|
||||||
int height_ = 100;
|
int height_ = 100;
|
||||||
QT *qt_;
|
QT *qt_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test that we're doing bound checking correctly.
|
// Test that we're doing bound checking correctly.
|
||||||
@ -66,7 +60,7 @@ TEST_F(QuadTreeTest, insert_count)
|
|||||||
int x1 = x0 + w;
|
int x1 = x0 + w;
|
||||||
int y1 = y0 + h;
|
int y1 = y0 + h;
|
||||||
ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i));
|
ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i));
|
||||||
ASSERT_EQ(qt_->size(), i+1);
|
ASSERT_EQ(qt_->size(), i + 1);
|
||||||
}
|
}
|
||||||
// Add 100000 random points.
|
// Add 100000 random points.
|
||||||
for (unsigned int i = 0; i < 100000; i++) {
|
for (unsigned int i = 0; i < 100000; i++) {
|
||||||
@ -75,7 +69,7 @@ TEST_F(QuadTreeTest, insert_count)
|
|||||||
int x1 = x0;
|
int x1 = x0;
|
||||||
int y1 = y0;
|
int y1 = y0;
|
||||||
ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i));
|
ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i));
|
||||||
ASSERT_EQ(qt_->size(), i+10001);
|
ASSERT_EQ(qt_->size(), i + 10001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,8 +85,8 @@ TEST_F(QuadTreeTest, insert_retrieve_same)
|
|||||||
int y0 = rng.rng(height_);
|
int y0 = rng.rng(height_);
|
||||||
int w = rng.rng(width_ - x0);
|
int w = rng.rng(width_ - x0);
|
||||||
int h = rng.rng(width_ - y0);
|
int h = rng.rng(width_ - y0);
|
||||||
int x1 = x0 + w/4;
|
int x1 = x0 + w / 4;
|
||||||
int y1 = y0 + h/4;
|
int y1 = y0 + h / 4;
|
||||||
ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i));
|
ASSERT_TRUE(qt_->insert(QT::BoundingBox(x0, y0, x1, y1), i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,12 +97,12 @@ TEST_F(QuadTreeTest, insert_retrieve_same)
|
|||||||
int y0 = rng.rng(height_);
|
int y0 = rng.rng(height_);
|
||||||
int w = rng.rng(width_ - x0);
|
int w = rng.rng(width_ - x0);
|
||||||
int h = rng.rng(width_ - y0);
|
int h = rng.rng(width_ - y0);
|
||||||
int x1 = x0 + w/4;
|
int x1 = x0 + w / 4;
|
||||||
int y1 = y0 + h/4;
|
int y1 = y0 + h / 4;
|
||||||
|
|
||||||
// try to find something in the middle of the square
|
// try to find something in the middle of the square
|
||||||
int x = (x1-x0)/2+x0;
|
int x = (x1 - x0) / 2 + x0;
|
||||||
int y = (y1-y0)/2+y0;
|
int y = (y1 - y0) / 2 + y0;
|
||||||
|
|
||||||
auto res = qt_->get(x, y);
|
auto res = qt_->get(x, y);
|
||||||
// Somewhat arbirary test to make sure we don't return obscene
|
// Somewhat arbirary test to make sure we don't return obscene
|
||||||
|
Loading…
Reference in New Issue
Block a user