Debian Codegraph @

himbaechel/uarch/ng-ultra/ng_ultra.h

raw
1 /*
2 * nextpnr -- Next Generation Place and Route
3 *
4 * Copyright (C) 2024 The Project Beyond 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_NG_ULTRA_H
21 #define HIMBAECHEL_NG_ULTRA_H
22 #include <deque>
23
24 #include "extra_data.h"
25 #include "himbaechel_api.h"
26 #include "log.h"
27 #include "nextpnr.h"
28 #include "util.h"
29
30 #include "himbaechel_helpers.h"
31
32 #ifdef GTEST_API_
33 #define TESTABLE_PRIVATE public
34 #else
35 #define TESTABLE_PRIVATE private
36 #endif
37
38 NEXTPNR_NAMESPACE_BEGIN
39
40 struct NgUltraImpl : HimbaechelAPI
41 {
42 ~NgUltraImpl();
43 po::options_description getUArchOptions() override;
44 void init_database(Arch *arch) override;
45
46 void init(Context *ctx) override;
47
48 bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
49 IdString getBelBucketForCellType(IdString cell_type) const override;
50 bool isValidBelForCellType(IdString cell_type, BelId bel) const override;
51 BelBucketId getBelBucketForBel(BelId bel) const override;
52
53 // Flow management
54 void pack() override;
55 void postPlace() override;
56 void postRoute() override;
57
58 void configurePlacerHeap(PlacerHeapCfg &cfg) override;
59
60 bool getClusterPlacement(ClusterId cluster, BelId root_bel,
61 std::vector<std::pair<CellInfo *, BelId>> &placement) const override;
62 bool getChildPlacement(const BaseClusterInfo *cluster, Loc root_loc,
63 std::vector<std::pair<CellInfo *, BelId>> &placement) const;
64
65 BoundingBox getRouteBoundingBox(WireId src, WireId dst) const override;
66 delay_t estimateDelay(WireId src, WireId dst) const override;
67 delay_t predictDelay(BelId src_bel, IdString src_pin, BelId dst_bel, IdString dst_pin) const override;
68
69 bool checkPipAvail(PipId pip) const override { return blocked_pips.count(pip) == 0; }
70 bool checkPipAvailForNet(PipId pip, const NetInfo *net) const override { return checkPipAvail(pip); };
71
72 void expandBoundingBox(BoundingBox &bb) const override;
73
74 void drawBel(std::vector<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override;
75
76 public:
77 int tile_lobe(int tile) const;
78 TileTypeExtra tile_type(int tile) const;
79 IdString tile_name_id(int tile) const;
80 std::string tile_name(int tile) const;
81
82 const dict<IdString, pool<IdString>> &get_fabric_lowskew_sinks();
83 bool is_fabric_lowskew_sink(const PortRef &ref);
84 bool is_ring_clock_sink(const PortRef &ref);
85 bool is_ring_over_tile_clock_sink(const PortRef &ref);
86 bool is_tube_clock_sink(const PortRef &ref);
87
88 bool is_ring_clock_source(const PortRef &ref);
89 bool is_tube_clock_source(const PortRef &ref);
90
91 const NGUltraPipExtraDataPOD *pip_extra_data(PipId pip) const;
92 const NGUltraBelExtraDataPOD *bel_extra_data(BelId bel) const;
93
94 dict<IdString, BelId> iom_bels;
95 dict<std::string, std::string> bank_voltage;
96 dict<BelId, IdString> global_capable_bels;
97 dict<std::string, BelId> locations;
98 dict<std::string, Loc> tile_locations;
99 dict<int, std::vector<GckConfig>> gck_per_lobe;
100
101 pool<PipId> blocked_pips;
102 dict<IdString, std::pair<IdString, IdString>> bank_to_ckg;
103 dict<BelId, IdString> unused_wfg;
104 dict<BelId, IdString> unused_pll;
105 dict<BelId, BelId> dsp_cascade;
106
107 /* clang-format off */
108 TESTABLE_PRIVATE:
109 void write_bitstream_json(const std::string &filename);
110 /* clang-format on */
111 void parse_csv(const std::string &filename);
112 void remove_constants();
113 bool update_bff_to_csc(CellInfo *cell, BelId bel, PipId dst_pip);
114 bool update_bff_to_scc(CellInfo *cell, BelId bel, PipId dst_pip);
115 void disable_beyond_fe_s_output(BelId bel);
116
117 void fixup_crossbars();
118
119 // Misc utility functions
120 bool get_mux_data(BelId bel, IdString port, uint8_t *value);
121 bool get_mux_data(WireId wire, uint8_t *value);
122
123 const NGUltraTileInstExtraDataPOD *tile_extra_data(int tile) const;
124 };
125
126 NEXTPNR_NAMESPACE_END
127 #endif