1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#ifndef LIBTRELLIS_DATABASE_HPP
#define LIBTRELLIS_DATABASE_HPP
#include <string>
#include <cstdint>
#include <vector>
#include <unordered_map>
#include <memory>
using namespace std;
namespace Trellis {
// This MUST be called before any operations (such as creating a Chip or reading a bitstream)
// that require database access.
void load_database(string root);
// Locator for a given FPGA (formed of family and device)
struct DeviceLocator {
string family;
string device;
string variant;
};
// Locator for a given tile type (formed of family, device and tile type)
struct TileLocator {
inline TileLocator() {};
inline TileLocator(string f, string d, string t) : family(f), device(d), tiletype(t) {};
string family;
string device;
string tiletype;
};
inline bool operator==(const TileLocator &a, const TileLocator &b) {
return (a.family == b.family) && (a.device == b.device) && (a.tiletype == b.tiletype);
}
// Search the device list by part name
DeviceLocator find_device_by_name(string name);
// Search the device list by part name
DeviceLocator find_device_by_name_and_variant(string name, string variant);
// Search the device list by ID
DeviceLocator find_device_by_idcode(uint32_t idcode);
// Search the device list by frames
DeviceLocator find_device_by_frames(uint32_t frames);
struct ChipInfo;
// Obtain basic information about a device
ChipInfo get_chip_info(const DeviceLocator &part);
struct Ecp5GlobalsInfo;
// Obtain global network information for a chip
Ecp5GlobalsInfo get_global_info_ecp5(const DeviceLocator &part);
// Obtain the tilegrid for a part
struct TileInfo;
vector<TileInfo> get_device_tilegrid(const DeviceLocator &part);
// Obtain the BitDatabase for a device/tile combination
// BitDatabases are a singleton
class TileBitDatabase;
shared_ptr<TileBitDatabase> get_tile_bitdata(const TileLocator &tile);
}
// Hash function for TileLocator
namespace std {
template<> struct hash<Trellis::TileLocator> {
public:
inline size_t operator()(const Trellis::TileLocator &tile) const {
hash<string> hash_fn;
return hash_fn(tile.family) + hash_fn(tile.device) + hash_fn(tile.tiletype);
}
};
}
#endif //LIBTRELLIS_DATABASE_HPP
|