35 float phv_scale_factor = 1.0;
36 bool no_tagalong =
false;
37 bool tof2lab44_workaround =
false;
54 static const Device &get() {
55 BUG_CHECK(instance_ !=
nullptr,
"Target device not initialized!");
59 static Device_t currentDevice() {
return Device::get().device_type(); }
60 static cstring name() {
return Device::get().get_name(); }
62 static const PhvSpec &phvSpec() {
return Device::get().getPhvSpec(); }
63 static const PardeSpec &pardeSpec() {
return Device::get().getPardeSpec(); }
74 unsigned XorByteSlots;
77 static const GatewaySpec &gatewaySpec() {
return Device::get().getGatewaySpec(); }
80 std::vector<cstring> CmpUnits;
85 int MaxInstructionConstWidth;
86 int MinInstructionConstValue;
87 int MaxInstructionConstValue;
93 cstring cmpUnit(
unsigned idx)
const;
95 static const StatefulAluSpec &statefulAluSpec() {
return Device::get().getStatefulAluSpec(); }
96 static const ArchSpec &archSpec() {
return Device::get().getArchSpec(); }
97 static const MauPowerSpec &mauPowerSpec() {
return Device::get().getMauPowerSpec(); }
98 static const MauSpec &mauSpec() {
return Device::get().getMauSpec(); }
99 static const IXBarSpec &ixbarSpec() {
return Device::get().getMauSpec().getIXBarSpec(); }
100 static const IMemSpec &imemSpec() {
return Device::get().getMauSpec().getIMemSpec(); }
101 static int numPipes() {
return Device::get().getNumPipes(); }
102 static int numStages() {
103 return (numStagesRuntimeOverride_ != 0) ? numStagesRuntimeOverride_
104 : Device::get().getNumStages();
106 static void overrideNumStages(
int num);
107 static int numLongBranchTags() {
return Device::get().getLongBranchTags(); }
108 static bool hasLongBranches() {
return numLongBranchTags() > 0; }
109 static int alwaysRunIMemAddr() {
return Device::get().getAlwaysRunIMemAddr(); }
110 static bool hasAlwaysRunInstr() {
return alwaysRunIMemAddr() >= 0; }
111 static unsigned maxCloneId(gress_t gress) {
return Device::get().getMaxCloneId(gress); }
112 static gress_t maxGress() {
return Device::get().getMaxGress(); }
113 static RangeIter<gress_t> allGresses() {
return Range(INGRESS, maxGress()); }
114 static unsigned maxResubmitId() {
return Device::get().getMaxResubmitId(); }
115 static unsigned maxDigestId() {
return Device::get().getMaxDigestId(); }
117 static int mirrorTypeWidth() {
return Device::get().getMirrorTypeWidth(); }
118 static int cloneSessionIdWidth() {
return Device::get().getCloneSessionIdWidth(); }
119 static int queueIdWidth() {
return Device::get().getQueueIdWidth(); }
120 static int portBitWidth() {
return Device::get().getPortBitWidth(); }
121 static int maxParserMatchBits() {
return Device::get().getMaxParserMatchBits(); }
122 static unsigned maxDigestSizeInBytes() {
return Device::get().getMaxDigestSizeInBytes(); }
123 static int numParsersPerPipe() {
return 18; }
124 static int numMaxChannels() {
return Device::get().getNumMaxChannels(); }
125 static int numClots() {
return pardeSpec().numClotsPerGress(); }
126 static int isMemoryCoreSplit() {
return Device::get().getIfMemoryCoreSplit(); }
127 static bool hasCompareInstructions() {
return Device::get().getHasCompareInstructions(); }
128 static int numLogTablesPerStage() {
return Device::get().getNumLogTablesPerStage(); }
129 static bool hasIngressDeparser() {
return Device::get().getHasIngressDeparser(); }
130 static bool hasEgressParser() {
return Device::get().getHasEgressParser(); }
131 static bool hasGhostThread() {
return Device::get().getHasGhostThread(); }
132 static bool threadsSharePipe(gress_t a, gress_t b) {
133 return Device::get().getThreadsSharePipe(a, b);
135 static bool hasMirrorIOSelect() {
return Device::get().getHasMirrorIOSelect(); }
136 static bool hasMetadataPOV() {
return Device::get().getHasMetadataPOV(); }
137 static int sramMinPackEntries() {
return Device::get().getSramMinPackEntries(); }
138 static int sramMaxPackEntries() {
return Device::get().getSramMaxPackEntries(); }
139 static int sramMaxPackEntriesPerRow() {
return Device::get().getSramMaxPackEntriesPerRow(); }
144 static int sramColumnAdjust() {
return Device::get().getSramColumnAdjust(); }
145 static int metaGlobalTimestampStart() {
return Device::get().getMetaGlobalTimestampStart(); }
146 static int metaGlobalTimestampLen() {
return Device::get().getMetaGlobalTimestampLen(); }
147 static int metaGlobalVersionStart() {
return Device::get().getMetaGlobalVersionStart(); }
148 static int metaGlobalVersionLen() {
return Device::get().getMetaGlobalVersionLen(); }
149 static unsigned int egressIntrinsicMetadataMinLen() {
150 return Device::get().getEgressIntrinsicMetadataMinLen();
154 explicit Device(
Options options, cstring name) : options_(options), name_(name) {}
156 virtual Device_t device_type()
const = 0;
157 virtual cstring get_name()
const = 0;
159 virtual const PhvSpec &getPhvSpec()
const = 0;
160 virtual const PardeSpec &getPardeSpec()
const = 0;
161 virtual const GatewaySpec &getGatewaySpec()
const = 0;
163 virtual const MauPowerSpec &getMauPowerSpec()
const = 0;
164 virtual const MauSpec &getMauSpec()
const = 0;
165 virtual const ArchSpec &getArchSpec()
const = 0;
166 virtual int getNumPipes()
const = 0;
167 virtual int getNumPortsPerPipe()
const = 0;
168 virtual int getNumChannelsPerPort()
const = 0;
169 virtual int getNumStages()
const = 0;
170 virtual int getLongBranchTags()
const = 0;
171 virtual int getAlwaysRunIMemAddr()
const = 0;
172 virtual unsigned getMaxCloneId(gress_t)
const = 0;
173 virtual gress_t getMaxGress()
const = 0;
174 virtual unsigned getMaxResubmitId()
const = 0;
175 virtual unsigned getMaxDigestId()
const = 0;
176 virtual unsigned getMaxDigestSizeInBytes()
const = 0;
177 virtual int getMirrorTypeWidth()
const = 0;
178 virtual int getCloneSessionIdWidth()
const = 0;
179 virtual int getQueueIdWidth()
const = 0;
180 virtual int getPortBitWidth()
const = 0;
181 virtual int getMaxParserMatchBits()
const = 0;
182 virtual int getNumMaxChannels()
const = 0;
183 virtual bool getIfMemoryCoreSplit()
const = 0;
184 virtual bool getHasCompareInstructions()
const = 0;
185 virtual int getNumLogTablesPerStage()
const = 0;
186 virtual bool getHasIngressDeparser()
const = 0;
187 virtual bool getHasEgressParser()
const = 0;
188 virtual bool getHasGhostThread()
const = 0;
189 virtual bool getThreadsSharePipe(gress_t a, gress_t b)
const = 0;
190 virtual bool getHasMirrorIOSelect()
const = 0;
191 virtual bool getHasMetadataPOV()
const = 0;
192 virtual int getSramMinPackEntries()
const = 0;
193 virtual int getSramMaxPackEntries()
const = 0;
194 virtual int getSramMaxPackEntriesPerRow()
const = 0;
195 virtual int getSramColumnAdjust()
const = 0;
196 virtual int getMetaGlobalTimestampStart()
const = 0;
197 virtual int getMetaGlobalTimestampLen()
const = 0;
198 virtual int getMetaGlobalVersionStart()
const = 0;
199 virtual int getMetaGlobalVersionLen()
const = 0;
200 virtual unsigned int getEgressIntrinsicMetadataMinLen()
const = 0;
203 static Device *instance_;
204 static int numStagesRuntimeOverride_;
208class TofinoDevice :
public Device {
216 explicit TofinoDevice(
Options options)
217 : Device(options,
"Tofino"_cs),
218 phv_(options.phv_scale_factor, options.no_tagalong),
220 Device::Device_t device_type()
const override {
return Device::TOFINO; }
221 cstring get_name()
const override {
return "Tofino"_cs; }
222 int getNumPipes()
const override {
return 4; }
223 int getNumPortsPerPipe()
const override {
return 4; }
224 int getNumChannelsPerPort()
const override {
return 18; }
225 int getNumStages()
const override {
return 12; }
226 int getLongBranchTags()
const override {
return 0; }
227 int getAlwaysRunIMemAddr()
const override {
return -1; }
228 unsigned getMaxCloneId(gress_t gress)
const override {
238 gress_t getMaxGress()
const override {
return EGRESS; }
239 unsigned getMaxResubmitId()
const override {
return 8; }
240 unsigned getMaxDigestId()
const override {
return 8; }
241 int getMirrorTypeWidth()
const override {
return 3; }
242 int getCloneSessionIdWidth()
const override {
return 10; }
243 int getQueueIdWidth()
const override {
return 5; }
244 int getPortBitWidth()
const override {
return 9; }
245 int getMaxParserMatchBits()
const override {
return 32; }
246 int getNumMaxChannels()
const override {
247 return getNumPipes() * getNumPortsPerPipe() * getNumChannelsPerPort();
249 unsigned getMaxDigestSizeInBytes()
const override {
return (384 / 8); }
251 const PhvSpec &getPhvSpec()
const override {
return phv_; }
252 const PardeSpec &getPardeSpec()
const override {
return parde_; }
253 const GatewaySpec &getGatewaySpec()
const override;
255 const MauPowerSpec &getMauPowerSpec()
const override {
return mau_power_; }
256 const MauSpec &getMauSpec()
const override {
return mau_; }
257 const ArchSpec &getArchSpec()
const override {
return arch_; }
258 bool getIfMemoryCoreSplit()
const override {
return false; }
259 bool getHasCompareInstructions()
const override {
return false; }
260 int getNumLogTablesPerStage()
const override {
return 16; }
261 bool getHasIngressDeparser()
const override {
return true; }
262 bool getHasEgressParser()
const override {
return true; }
263 bool getHasGhostThread()
const override {
return false; };
264 bool getThreadsSharePipe(gress_t, gress_t)
const override {
return true; }
265 bool getHasMirrorIOSelect()
const override {
return false; }
266 bool getHasMetadataPOV()
const override {
return false; }
267 int getSramMinPackEntries()
const override {
return 1; }
268 int getSramMaxPackEntries()
const override {
return 9; }
269 int getSramMaxPackEntriesPerRow()
const override {
return 5; }
270 int getMetaGlobalTimestampStart()
const override {
return 432; }
271 int getMetaGlobalTimestampLen()
const override {
return 48; }
272 int getMetaGlobalVersionStart()
const override {
return 480; }
273 int getMetaGlobalVersionLen()
const override {
return 32; }
274 int getSramColumnAdjust()
const override {
return 2; }
275 unsigned int getEgressIntrinsicMetadataMinLen()
const override {
return 2; }
278class JBayDevice :
public Device {
286#ifdef EMU_OVERRIDE_STAGE_COUNT
287 const int NUM_MAU_STAGES = EMU_OVERRIDE_STAGE_COUNT;
289 const int NUM_MAU_STAGES = 20;
293 explicit JBayDevice(
Options options)
294 : Device(options,
"Tofino2"_cs),
295 phv_(options.phv_scale_factor),
296 parde_(options.tof2lab44_workaround) {}
297 Device::Device_t device_type()
const override {
return Device::JBAY; }
298 cstring get_name()
const override {
return "Tofino2"_cs; }
299 int getNumPipes()
const override {
return 4; }
300 int getNumPortsPerPipe()
const override {
return 4; }
301 int getNumChannelsPerPort()
const override {
return 18; }
302 int getNumStages()
const override {
return NUM_MAU_STAGES; }
303 int getLongBranchTags()
const override {
return 8; }
304 int getAlwaysRunIMemAddr()
const override {
return 63; }
305 unsigned getMaxCloneId(gress_t )
const override {
return 16; }
306 gress_t getMaxGress()
const override {
return GHOST; }
307 unsigned getMaxResubmitId()
const override {
return 8; }
308 unsigned getMaxDigestId()
const override {
return 8; }
309 unsigned getMaxDigestSizeInBytes()
const override {
return (384 / 8); }
310 int getMirrorTypeWidth()
const override {
return 4; }
311 int getCloneSessionIdWidth()
const override {
return 8; }
312 int getQueueIdWidth()
const override {
return 7; }
313 int getPortBitWidth()
const override {
return 9; }
314 int getMaxParserMatchBits()
const override {
return 32; }
315 int getNumMaxChannels()
const override {
316 return getNumPipes() * getNumPortsPerPipe() * getNumChannelsPerPort();
319 const PhvSpec &getPhvSpec()
const override {
return phv_; }
320 const PardeSpec &getPardeSpec()
const override {
return parde_; }
321 const GatewaySpec &getGatewaySpec()
const override;
323 const MauSpec &getMauSpec()
const override {
return mau_; }
324 const MauPowerSpec &getMauPowerSpec()
const override {
return mau_power_; }
325 const ArchSpec &getArchSpec()
const override {
return arch_; }
326 bool getIfMemoryCoreSplit()
const override {
return true; }
327 bool getHasCompareInstructions()
const override {
return true; }
328 int getNumLogTablesPerStage()
const override {
return 16; }
329 bool getHasIngressDeparser()
const override {
return true; }
330 bool getHasEgressParser()
const override {
return true; }
331 bool getHasGhostThread()
const override {
return true; };
332 bool getThreadsSharePipe(gress_t, gress_t)
const override {
return true; }
333 bool getHasMirrorIOSelect()
const override {
return true; }
334 bool getHasMetadataPOV()
const override {
return true; }
335 int getSramMinPackEntries()
const override {
return 1; }
336 int getSramMaxPackEntries()
const override {
return 9; }
337 int getSramMaxPackEntriesPerRow()
const override {
return 5; }
338 int getMetaGlobalTimestampStart()
const override {
return 400; }
339 int getMetaGlobalTimestampLen()
const override {
return 48; }
340 int getMetaGlobalVersionStart()
const override {
return 448; }
341 int getMetaGlobalVersionLen()
const override {
return 32; }
342 int getSramColumnAdjust()
const override {
return 2; }
343 unsigned int getEgressIntrinsicMetadataMinLen()
const override {
return 8; }