| 1 |
/* |
| 2 |
* nextpnr -- Next Generation Place and Route |
| 3 |
* |
| 4 |
* Copyright (C) 2024 The Project Peppercorn Authors. |
| 5 |
* |
| 6 |
* Permission to use, copy, modify, and/or distribute this software for any |
| 7 |
* purpose with or without fee is hereby granted, provided that the above |
| 8 |
* copyright notice and this permission notice appear in all copies. |
| 9 |
* |
| 10 |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 17 |
* |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef GATEMATE_CONFIG_H |
| 21 |
#define GATEMATE_CONFIG_H |
| 22 |
|
| 23 |
#include <map> |
| 24 |
#include "nextpnr.h" |
| 25 |
|
| 26 |
NEXTPNR_NAMESPACE_BEGIN |
| 27 |
|
| 28 |
struct ConfigWord |
| 29 |
{ |
| 30 |
std::string name; |
| 31 |
std::vector<bool> value; |
| 32 |
inline bool operator==(const ConfigWord &other) const { return other.name == name && other.value == value; } |
| 33 |
}; |
| 34 |
|
| 35 |
std::ostream &operator<<(std::ostream &out, const ConfigWord &cw); |
| 36 |
|
| 37 |
struct TileConfig |
| 38 |
{ |
| 39 |
std::vector<ConfigWord> cwords; |
| 40 |
std::map<std::string, std::vector<bool>> added; |
| 41 |
|
| 42 |
void add_word(const std::string &name, const std::vector<bool> &value, const char *c = nullptr); |
| 43 |
|
| 44 |
std::string to_string() const; |
| 45 |
|
| 46 |
bool empty() const; |
| 47 |
}; |
| 48 |
|
| 49 |
std::ostream &operator<<(std::ostream &out, const TileConfig &tc); |
| 50 |
|
| 51 |
struct CfgLoc |
| 52 |
{ |
| 53 |
int die; |
| 54 |
int x; |
| 55 |
int y; |
| 56 |
|
| 57 |
inline bool operator==(const CfgLoc &other) const { return other.die == die && other.x == x && other.y == y; } |
| 58 |
inline bool operator!=(const CfgLoc &other) const { return other.die != die || x != other.x || y == other.y; } |
| 59 |
|
| 60 |
inline bool operator<(const CfgLoc &other) const |
| 61 |
{ |
| 62 |
return die < other.die || |
| 63 |
((die == other.die && y < other.y) || (die == other.die && y == other.y && x < other.x)); |
| 64 |
} |
| 65 |
}; |
| 66 |
|
| 67 |
class ChipConfig |
| 68 |
{ |
| 69 |
public: |
| 70 |
std::string chip_name; |
| 71 |
std::string chip_package; |
| 72 |
std::map<CfgLoc, TileConfig> tiles; |
| 73 |
std::map<CfgLoc, TileConfig> brams; |
| 74 |
std::map<int, TileConfig> serdes; |
| 75 |
std::map<int, TileConfig> configs; |
| 76 |
|
| 77 |
// Block RAM initialisation |
| 78 |
std::map<CfgLoc, std::vector<uint8_t>> bram_data; |
| 79 |
}; |
| 80 |
|
| 81 |
std::ostream &operator<<(std::ostream &out, const ChipConfig &cc); |
| 82 |
|
| 83 |
NEXTPNR_NAMESPACE_END |
| 84 |
|
| 85 |
#endif |