Create compile-able demo that doesn't do anything
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
daa4885820
commit
2255870446
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/demo
|
15
database.cc
Normal file
15
database.cc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "database.h"
|
||||||
|
|
||||||
|
Chip::Chip(std::string)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjRange Chip::getBels() const
|
||||||
|
{
|
||||||
|
return ObjRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
IdString Chip::getObjName(ObjId obj) const
|
||||||
|
{
|
||||||
|
return "*unknown*";
|
||||||
|
}
|
@ -1,13 +1,20 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
// replace with proper IdString later
|
// replace with proper IdString later
|
||||||
typedef std::string IdString;
|
typedef std::string IdString;
|
||||||
|
|
||||||
|
// replace with haslib later
|
||||||
|
template<typename T> using pool = std::unordered_set<T>;
|
||||||
|
template<typename T, typename U> using dict = std::unordered_map<T, U>;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
// Arch-specific declarations
|
// Arch-specific declarations
|
||||||
|
|
||||||
#ifdef ARCH_ICE40
|
|
||||||
struct ObjId
|
struct ObjId
|
||||||
{
|
{
|
||||||
uint8_t tile_x = 0, tile_y = 0;
|
uint8_t tile_x = 0, tile_y = 0;
|
||||||
@ -18,16 +25,34 @@ struct ObjId
|
|||||||
}
|
}
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
template<> struct hash<ObjId>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const ObjId &obj) const noexcept
|
||||||
|
{
|
||||||
|
std::size_t result = std::hash<int>{}(obj.index);
|
||||||
|
result ^= std::hash<int>{}(obj.tile_x) + 0x9e3779b9 + (result << 6) + (result >> 2);
|
||||||
|
result ^= std::hash<int>{}(obj.tile_y) + 0x9e3779b9 + (result << 6) + (result >> 2);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
struct ObjIterator
|
struct ObjIterator
|
||||||
{
|
{
|
||||||
// ...
|
ObjId *ptr = nullptr;
|
||||||
ObjId operator*() const;
|
|
||||||
|
void operator++() { ptr++; }
|
||||||
|
bool operator!=(const ObjIterator &other) const { return ptr != other.ptr; }
|
||||||
|
ObjId operator*() const { return *ptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ObjRange
|
struct ObjRange
|
||||||
{
|
{
|
||||||
ObjIterator begin();
|
ObjIterator b, e;
|
||||||
ObjIterator end();
|
ObjIterator begin() const { return b; }
|
||||||
|
ObjIterator end() const { return e; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BelPin
|
struct BelPin
|
||||||
@ -38,14 +63,18 @@ struct BelPin
|
|||||||
|
|
||||||
struct BelPinIterator
|
struct BelPinIterator
|
||||||
{
|
{
|
||||||
// ...
|
BelPin *ptr = nullptr;
|
||||||
BelPin operator*() const;
|
|
||||||
|
void operator++() { ptr++; }
|
||||||
|
bool operator!=(const BelPinIterator &other) const { return ptr != other.ptr; }
|
||||||
|
BelPin operator*() const { return *ptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BelPinRange
|
struct BelPinRange
|
||||||
{
|
{
|
||||||
BelPinIterator begin();
|
BelPinIterator b, e;
|
||||||
BelPinIterator end();
|
BelPinIterator begin() const { return b; }
|
||||||
|
BelPinIterator end() const { return e; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GuiLine
|
struct GuiLine
|
||||||
@ -84,7 +113,6 @@ struct Chip
|
|||||||
BelPin getBelPinUphill(ObjId wire) const;
|
BelPin getBelPinUphill(ObjId wire) const;
|
||||||
BelPinRange getBelPinsDownhill(ObjId wire) const;
|
BelPinRange getBelPinsDownhill(ObjId wire) const;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
// Generic declarations
|
// Generic declarations
|
||||||
@ -132,12 +160,12 @@ struct CellInfo
|
|||||||
|
|
||||||
struct Design
|
struct Design
|
||||||
{
|
{
|
||||||
struct Chip;
|
struct Chip chip;
|
||||||
|
|
||||||
Design(std::string chipCfg) : Chip(chipCfg) {
|
Design(std::string chipCfg) : chip(chipCfg) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
dict<IdString, *NetInfo> nets;
|
dict<IdString, NetInfo*> nets;
|
||||||
dict<IdString, *CellInfo> cells;
|
dict<IdString, CellInfo*> cells;
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user