| 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 HIMBAECHEL_GATEMATE_H |
| 21 |
#define HIMBAECHEL_GATEMATE_H |
| 22 |
|
| 23 |
#include "extra_data.h" |
| 24 |
#include "himbaechel_api.h" |
| 25 |
#include "log.h" |
| 26 |
#include "nextpnr.h" |
| 27 |
#include "util.h" |
| 28 |
|
| 29 |
#include "himbaechel_helpers.h" |
| 30 |
|
| 31 |
NEXTPNR_NAMESPACE_BEGIN |
| 32 |
|
| 33 |
enum MultiDieStrategy |
| 34 |
{ |
| 35 |
CLOCK_MIRROR, |
| 36 |
REUSE_CLK1, |
| 37 |
FULL_USE, |
| 38 |
}; |
| 39 |
|
| 40 |
struct GateMateImpl : HimbaechelAPI |
| 41 |
{ |
| 42 |
~GateMateImpl(); |
| 43 |
po::options_description getUArchOptions() override; |
| 44 |
void init_database(Arch *arch) override; |
| 45 |
|
| 46 |
void init(Context *ctx) override; |
| 47 |
|
| 48 |
void pack() override; |
| 49 |
|
| 50 |
void prePlace() override; |
| 51 |
void postPlace() override; |
| 52 |
void preRoute() override; |
| 53 |
void postRoute() override; |
| 54 |
|
| 55 |
virtual std::string getDefaultRouter() const override { return "router2"; }; |
| 56 |
|
| 57 |
BoundingBox getRouteBoundingBox(WireId src, WireId dst) const override; |
| 58 |
void expandBoundingBox(BoundingBox &bb) const override; |
| 59 |
bool checkPipAvail(PipId pip) const override; |
| 60 |
bool checkPipAvailForNet(PipId pip, const NetInfo *net) const override { return checkPipAvail(pip); }; |
| 61 |
|
| 62 |
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override; |
| 63 |
delay_t estimateDelay(WireId src, WireId dst) const override; |
| 64 |
delay_t predictDelay(BelId src_bel, IdString src_pin, BelId dst_bel, IdString dst_pin) const override; |
| 65 |
bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayQuad &delay) const override; |
| 66 |
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const override; |
| 67 |
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const override; |
| 68 |
|
| 69 |
void drawBel(std::vector<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override; |
| 70 |
|
| 71 |
bool getClusterPlacement(ClusterId cluster, BelId root_bel, |
| 72 |
std::vector<std::pair<CellInfo *, BelId>> &placement) const override; |
| 73 |
|
| 74 |
IdString getBelBucketForCellType(IdString cell_type) const override; |
| 75 |
bool isValidBelForCellType(IdString cell_type, BelId bel) const override; |
| 76 |
BelBucketId getBelBucketForBel(BelId bel) const override; |
| 77 |
|
| 78 |
Loc getRelativeConstraint(Loc &root_loc, IdString id) const; |
| 79 |
|
| 80 |
void configurePlacerHeap(PlacerHeapCfg &cfg) override; |
| 81 |
|
| 82 |
bool isPipInverting(PipId pip) const override; |
| 83 |
|
| 84 |
GroupId getResourceKeyForPip(PipId pip) const override; |
| 85 |
int getResourceValueForPip(PipId pip) const override; |
| 86 |
bool isGroupResource(GroupId group) const override; |
| 87 |
|
| 88 |
const GateMateTileExtraDataPOD *tile_extra_data(int tile) const; |
| 89 |
const GateMateBelExtraDataPOD *bel_extra_data(BelId bel) const; |
| 90 |
const GateMatePipExtraDataPOD *pip_extra_data(PipId pip) const; |
| 91 |
|
| 92 |
int get_dff_config(CellInfo *dff) const; |
| 93 |
int get_ram_config(CellInfo *ram) const; |
| 94 |
|
| 95 |
std::set<IdString> available_pads; |
| 96 |
std::map<BelId, const PadInfoPOD *> bel_to_pad; |
| 97 |
pool<IdString> ddr_nets; |
| 98 |
dict<std::pair<IdString, int>, Loc> locations; |
| 99 |
int dies; |
| 100 |
int preferred_die; |
| 101 |
pool<IdString> multiplier_a_passthru_lowers; |
| 102 |
pool<IdString> multiplier_a_passthru_uppers; |
| 103 |
pool<IdString> multiplier_zero_drivers; |
| 104 |
std::vector<bool> used_cpes; |
| 105 |
std::vector<uint32_t> pip_data; |
| 106 |
std::vector<uint32_t> pip_mask; |
| 107 |
int fpga_mode; |
| 108 |
int timing_mode; |
| 109 |
std::map<const NetInfo *, int> global_signals; |
| 110 |
dict<std::pair<IdString, int>, NetInfo *> global_mapping; |
| 111 |
dict<std::pair<IdString, int>, IdString> global_clk_mapping; |
| 112 |
std::vector<CellInfo *> clkin; |
| 113 |
std::vector<CellInfo *> glbout; |
| 114 |
std::vector<CellInfo *> pll; |
| 115 |
pool<IdString> ignore; |
| 116 |
MultiDieStrategy strategy; |
| 117 |
dict<int, IdString> index_to_die; |
| 118 |
dict<IdString, int> die_to_index; |
| 119 |
dict<IdString, dict<IdString, IdString>> pass_backtrace; |
| 120 |
pool<IdString> scopenames; |
| 121 |
pool<IdString> scopenames_used; |
| 122 |
|
| 123 |
private: |
| 124 |
bool getChildPlacement(const BaseClusterInfo *cluster, Loc root_loc, |
| 125 |
std::vector<std::pair<CellInfo *, BelId>> &placement) const; |
| 126 |
|
| 127 |
void write_bitstream(const std::string &device, const std::string &filename); |
| 128 |
|
| 129 |
void parse_ccf(const std::string &filename); |
| 130 |
|
| 131 |
void assign_cell_info(); |
| 132 |
void route_clock(); |
| 133 |
void route_mult(); |
| 134 |
void reassign_bridges(NetInfo *net, const dict<WireId, PipMap> &net_wires, WireId wire, |
| 135 |
dict<WireId, IdString> &wire_to_net, int &num); |
| 136 |
void reassign_cplines(NetInfo *net, const dict<WireId, PipMap> &net_wires, WireId wire, |
| 137 |
dict<WireId, IdString> &wire_to_net, int &num, IdString in_port); |
| 138 |
void repack(); |
| 139 |
|
| 140 |
bool get_delay_from_tmg_db(IdString id, DelayQuad &delay) const; |
| 141 |
void get_setuphold_from_tmg_db(IdString id_setup, IdString id_hold, DelayPair &setup, DelayPair &hold) const; |
| 142 |
void get_setuphold_from_tmg_db(IdString id_setuphold, DelayPair &setup, DelayPair &hold) const; |
| 143 |
|
| 144 |
struct GateMateCellInfo |
| 145 |
{ |
| 146 |
// slice info |
| 147 |
const NetInfo *ff_en = nullptr, *ff_clk = nullptr, *ff_sr = nullptr; |
| 148 |
int config = 0; |
| 149 |
int signal_used = -1; |
| 150 |
bool used = false; |
| 151 |
}; |
| 152 |
std::vector<GateMateCellInfo> fast_cell_info; |
| 153 |
std::map<BelId, std::map<IdString, const GateMateBelPinConstraintPOD *>> pin_to_constr; |
| 154 |
std::map<IdString, const GateMateTimingExtraDataPOD *> timing; |
| 155 |
dict<IdString, int> ram_signal_clk; |
| 156 |
IdString forced_die; |
| 157 |
bool use_cp_for_clk; |
| 158 |
bool use_cp_for_cpe; |
| 159 |
bool use_bridges; |
| 160 |
}; |
| 161 |
|
| 162 |
NEXTPNR_NAMESPACE_END |
| 163 |
#endif |