35 std::vector<Table *> tables;
36 std::set<Stage **> all_refs;
61 selector_adr_bus_use, overflow_bus_use;
63 bitvec action_bus_use_bit_mask;
65 bitvec imem_use[ACTION_IMEM_SLOTS];
67 unsigned long_branch_thread[3] = {0};
68 unsigned long_branch_terminate = 0;
75 USE_METER_LPF_RED = 16,
77 USE_WIDE_SELECTOR = 64,
78 USE_STATEFUL_DIVIDE = 128
80 int table_use[2], group_table_use[2];
82 enum { NONE = 0, CONCURRENT = 1, ACTION_DEP = 2, MATCH_DEP = 3 } stage_dep[2];
83 bitvec match_use[3], action_use[3], action_set[3];
89 int mpr_stage_id[3] = {0};
90 int mpr_always_run = 0;
91 int mpr_bus_dep_glob_exec[3] = {0};
92 int mpr_bus_dep_long_branch[3] = {0};
100 int pass1_logical_id = -1, pass1_tcam_id = -1;
103 static std::map<int, std::pair<bool, int>> teop;
106 Stage_data(
int stage,
bool egress_only)
108 sram_use(Target::SRAM_ROWS(egress_only ? EGRESS : INGRESS), Target::SRAM_UNITS_PER_ROW()),
109 stm_hbus_use(Target::SRAM_ROWS(egress_only ? EGRESS : INGRESS),
110 Target::SRAM_HBUS_SECTIONS_PER_STAGE(), Target::SRAM_HBUSSES_PER_ROW()),
111 tcam_use(Target::TCAM_ROWS(), Target::TCAM_UNITS_PER_ROW()),
112 tcam_match_bus_use(Target::TCAM_ROWS(), Target::TCAM_MATCH_BUSSES()),
113 local_tind_use(Target::LOCAL_TIND_UNITS()),
114 hash_table_use(Target::EXACT_HASH_TABLES()),
115 hash_group_use(Target::EXACT_HASH_GROUPS()),
116 action_unit_use(Target::ARAM_UNITS_PER_STAGE()),
117 dp_unit_use(Target::DP_UNITS_PER_STAGE()) {}
118 Stage_data(
const Stage_data &) =
delete;
119 Stage_data(Stage_data &&) =
default;
123class Stage :
public Stage_data {
125 static unsigned char action_bus_slot_map[ACTION_DATA_BUS_BYTES];
126 static unsigned char action_bus_slot_size[ACTION_DATA_BUS_SLOTS];
128 explicit Stage(
int stageno,
bool egress_only);
129 Stage(
const Stage &) =
delete;
132 template <
class TARGET>
133 void output(
json::map &ctxt_json,
bool egress_only =
false);
134 template <
class REGS>
135 void fixup_regs(REGS ®s);
136 template <
class REGS>
137 void gen_configuration_cache_common(REGS ®s,
json::vector &cfg_cache);
138 template <
class REGS>
139 void gen_configuration_cache(REGS ®s,
json::vector &cfg_cache);
140 template <
class REGS>
141 void gen_gfm_json_info(REGS ®s, std::ostream &out);
142 template <
class REGS>
143 void gen_mau_stage_characteristics(REGS ®s,
json::vector &stg_characteristics);
144 template <
class REGS>
145 void gen_mau_stage_extension(REGS ®s,
json::map &extend);
146 template <
class REGS>
147 void write_regs(REGS ®s,
bool egress_only);
148 template <
class TARGET>
149 void write_common_regs(
typename TARGET::mau_regs ®s);
150 template <
class REGS>
151 void write_teop_regs(REGS ®s);
152 int adr_dist_delay(gress_t gress)
const;
153 int meter_alu_delay(gress_t gress,
bool uses_divmod)
const;
154 int pipelength(gress_t gress)
const;
155 int pred_cycle(gress_t gress)
const;
156 int tcam_delay(gress_t gress)
const;
157 int cycles_contribute_to_latency(gress_t gress);
158 void verify_have_mpr(std::string key,
int line_number);
159 static int first_table(gress_t gress);
160 static unsigned end_of_pipe() {
return Target::END_OF_PIPE(); }
161 static Stage *stage(gress_t gress,
int stageno);
162 void log_hashes(std::ofstream &out)
const;
163 bitvec imem_use_all()
const;
166class AsmStage :
public Section {
167 void start(
int lineno, VECTOR(
value_t) args);
172 void propagate_group_table_use();
174 unsigned compute_latency(gress_t gress);
177 std::vector<Stage> pipe;
178 static AsmStage singleton_object;
179 bitvec stages_seen[NUM_GRESS_T];
183 static int numstages() {
return singleton_object.pipe.size(); }
184 static std::vector<Stage> &stages(gress_t gress) {
return singleton_object.pipe; }
187 void reset_stage(
Stage &stage) {
188 for (
auto &tbl : stage.tables) tbl->all->clear();
189 stage.tables.clear();
190 stage.all_refs.clear();
191 stage.sram_use.clear();
192 stage.sram_search_bus_use.clear();
193 stage.stm_hbus_use.clear();
194 stage.match_result_bus_use.clear();
195 stage.mapram_use.clear();
196 stage.tcam_use.clear();
197 stage.tcam_match_bus_use.clear();
198 stage.tcam_byte_group_use.clear();
199 stage.gw_unit_use.clear();
200 stage.gw_payload_use.clear();
201 stage.logical_id_use.clear();
202 stage.physical_id_use.clear();
203 stage.tcam_id_use.clear();
204 stage.ixbar_use.clear();
205 stage.tcam_ixbar_input.clear();
206 stage.hash_table_use.clear();
207 stage.hash_group_use.clear();
208 stage.hash_dist_use.clear();
209 stage.action_bus_use.clear();
210 stage.action_data_use.clear();
211 stage.meter_bus_use.clear();
212 stage.stats_bus_use.clear();
213 stage.selector_adr_bus_use.clear();
214 stage.overflow_bus_use.clear();
215 stage.idletime_bus_use.clear();
216 stage.imem_addr_use.clear();
217 stage.long_branch_use.clear();
221 stages_seen[INGRESS].clear();
222 stages_seen[EGRESS].clear();
223 for (
auto &stage : pipe) reset_stage(stage);