47 static const Device &get() {
48 BUG_CHECK(instance_ !=
nullptr,
"Target device not initialized!");
52 static Device_t currentDevice() {
return Device::get().device_type(); }
53 static cstring name() {
return Device::get().get_name(); }
55 static const PhvSpec &phvSpec() {
return Device::get().getPhvSpec(); }
56 static const PardeSpec &pardeSpec() {
return Device::get().getPardeSpec(); }
58 static const GatewaySpec &gatewaySpec() {
return Device::get().getGatewaySpec(); }
60 static const StatefulAluSpec &statefulAluSpec() {
return Device::get().getStatefulAluSpec(); }
61 static const ArchSpec &archSpec() {
return Device::get().getArchSpec(); }
62 static const MauPowerSpec &mauPowerSpec() {
return Device::get().getMauPowerSpec(); }
63 static const MauSpec &mauSpec() {
return Device::get().getMauSpec(); }
64 static const IXBarSpec &ixbarSpec() {
return Device::get().getMauSpec().getIXBarSpec(); }
65 static const IMemSpec &imemSpec() {
return Device::get().getMauSpec().getIMemSpec(); }
66 static int numPipes() {
return Device::get().getNumPipes(); }
67 static int numStages() {
68 return numStagesRuntimeOverride_ ? numStagesRuntimeOverride_ : Device::get().getNumStages();
70 static void overrideNumStages(
int num);
71 static int numLongBranchTags() {
return Device::get().getLongBranchTags(); }
72 static bool hasLongBranches() {
return numLongBranchTags() > 0; }
73 static int alwaysRunIMemAddr() {
return Device::get().getAlwaysRunIMemAddr(); }
74 static bool hasAlwaysRunInstr() {
return alwaysRunIMemAddr() >= 0; }
75 static unsigned maxCloneId(gress_t gress) {
return Device::get().getMaxCloneId(gress); }
76 static gress_t maxGress() {
return Device::get().getMaxGress(); }
78 static unsigned maxResubmitId() {
return Device::get().getMaxResubmitId(); }
79 static unsigned maxDigestId() {
return Device::get().getMaxDigestId(); }
81 static int mirrorTypeWidth() {
return Device::get().getMirrorTypeWidth(); }
82 static int cloneSessionIdWidth() {
return Device::get().getCloneSessionIdWidth(); }
83 static int queueIdWidth() {
return Device::get().getQueueIdWidth(); }
84 static int portBitWidth() {
return Device::get().getPortBitWidth(); }
85 static int maxParserMatchBits() {
return Device::get().getMaxParserMatchBits(); }
86 static unsigned maxDigestSizeInBytes() {
return Device::get().getMaxDigestSizeInBytes(); }
87 static int numParsersPerPipe() {
return 18; }
88 static int numMaxChannels() {
return Device::get().getNumMaxChannels(); }
90 static int isMemoryCoreSplit() {
return Device::get().getIfMemoryCoreSplit(); }
91 static bool hasCompareInstructions() {
return Device::get().getHasCompareInstructions(); }
92 static int numLogTablesPerStage() {
return Device::get().getNumLogTablesPerStage(); }
93 static bool hasIngressDeparser() {
return Device::get().getHasIngressDeparser(); }
94 static bool hasEgressParser() {
return Device::get().getHasEgressParser(); }
95 static bool hasGhostThread() {
return Device::get().getHasGhostThread(); }
96 static bool threadsSharePipe(gress_t a, gress_t b) {
97 return Device::get().getThreadsSharePipe(a, b);
99 static bool hasMirrorIOSelect() {
return Device::get().getHasMirrorIOSelect(); }
100 static bool hasMetadataPOV() {
return Device::get().getHasMetadataPOV(); }
101 static int sramMinPackEntries() {
return Device::get().getSramMinPackEntries(); }
102 static int sramMaxPackEntries() {
return Device::get().getSramMaxPackEntries(); }
103 static int sramMaxPackEntriesPerRow() {
return Device::get().getSramMaxPackEntriesPerRow(); }
108 static int sramColumnAdjust() {
return Device::get().getSramColumnAdjust(); }
109 static int metaGlobalTimestampStart() {
return Device::get().getMetaGlobalTimestampStart(); }
110 static int metaGlobalTimestampLen() {
return Device::get().getMetaGlobalTimestampLen(); }
111 static int metaGlobalVersionStart() {
return Device::get().getMetaGlobalVersionStart(); }
112 static int metaGlobalVersionLen() {
return Device::get().getMetaGlobalVersionLen(); }
113 static unsigned int egressIntrinsicMetadataMinLen() {
114 return Device::get().getEgressIntrinsicMetadataMinLen();
120 virtual Device_t device_type()
const = 0;
121 virtual cstring get_name()
const = 0;
123 virtual const PhvSpec &getPhvSpec()
const = 0;
124 virtual const PardeSpec &getPardeSpec()
const = 0;
125 virtual const GatewaySpec &getGatewaySpec()
const = 0;
127 virtual const MauPowerSpec &getMauPowerSpec()
const = 0;
128 virtual const MauSpec &getMauSpec()
const = 0;
129 virtual const ArchSpec &getArchSpec()
const = 0;
130 virtual int getNumPipes()
const = 0;
131 virtual int getNumPortsPerPipe()
const = 0;
132 virtual int getNumChannelsPerPort()
const = 0;
133 virtual int getNumStages()
const = 0;
134 virtual int getLongBranchTags()
const = 0;
135 virtual int getAlwaysRunIMemAddr()
const = 0;
136 virtual unsigned getMaxCloneId(gress_t)
const = 0;
137 virtual gress_t getMaxGress()
const = 0;
138 virtual unsigned getMaxResubmitId()
const = 0;
139 virtual unsigned getMaxDigestId()
const = 0;
140 virtual unsigned getMaxDigestSizeInBytes()
const = 0;
141 virtual int getMirrorTypeWidth()
const = 0;
142 virtual int getCloneSessionIdWidth()
const = 0;
143 virtual int getQueueIdWidth()
const = 0;
144 virtual int getPortBitWidth()
const = 0;
145 virtual int getMaxParserMatchBits()
const = 0;
146 virtual int getNumMaxChannels()
const = 0;
147 virtual bool getIfMemoryCoreSplit()
const = 0;
148 virtual bool getHasCompareInstructions()
const = 0;
149 virtual int getNumLogTablesPerStage()
const = 0;
150 virtual bool getHasIngressDeparser()
const = 0;
151 virtual bool getHasEgressParser()
const = 0;
152 virtual bool getHasGhostThread()
const = 0;
153 virtual bool getThreadsSharePipe(gress_t a, gress_t b)
const = 0;
154 virtual bool getHasMirrorIOSelect()
const = 0;
155 virtual bool getHasMetadataPOV()
const = 0;
156 virtual int getSramMinPackEntries()
const = 0;
157 virtual int getSramMaxPackEntries()
const = 0;
158 virtual int getSramMaxPackEntriesPerRow()
const = 0;
159 virtual int getSramColumnAdjust()
const = 0;
160 virtual int getMetaGlobalTimestampStart()
const = 0;
161 virtual int getMetaGlobalTimestampLen()
const = 0;
162 virtual int getMetaGlobalVersionStart()
const = 0;
163 virtual int getMetaGlobalVersionLen()
const = 0;
164 virtual unsigned int getEgressIntrinsicMetadataMinLen()
const = 0;
168 static int numStagesRuntimeOverride_;
181 Device::Device_t device_type()
const override {
return Device::TOFINO; }
182 cstring get_name()
const override {
return "Tofino"_cs; }
183 int getNumPipes()
const override {
return 4; }
184 int getNumPortsPerPipe()
const override {
return 4; }
185 int getNumChannelsPerPort()
const override {
return 18; }
186 int getNumStages()
const override {
return 12; }
187 int getLongBranchTags()
const override {
return 0; }
188 int getAlwaysRunIMemAddr()
const override {
return -1; }
189 unsigned getMaxCloneId(gress_t gress)
const override {
199 gress_t getMaxGress()
const override {
return EGRESS; }
200 unsigned getMaxResubmitId()
const override {
return 8; }
201 unsigned getMaxDigestId()
const override {
return 8; }
202 int getMirrorTypeWidth()
const override {
return 3; }
203 int getCloneSessionIdWidth()
const override {
return 10; }
204 int getQueueIdWidth()
const override {
return 5; }
205 int getPortBitWidth()
const override {
return 9; }
206 int getMaxParserMatchBits()
const override {
return 32; }
207 int getNumMaxChannels()
const override {
208 return getNumPipes() * getNumPortsPerPipe() * getNumChannelsPerPort();
210 unsigned getMaxDigestSizeInBytes()
const override {
return (384 / 8); }
212 const PhvSpec &getPhvSpec()
const override {
return phv_; }
213 const PardeSpec &getPardeSpec()
const override {
return parde_; }
216 const MauPowerSpec &getMauPowerSpec()
const override {
return mau_power_; }
217 const MauSpec &getMauSpec()
const override {
return mau_; }
218 const ArchSpec &getArchSpec()
const override {
return arch_; }
219 bool getIfMemoryCoreSplit()
const override {
return false; }
220 bool getHasCompareInstructions()
const override {
return false; }
221 int getNumLogTablesPerStage()
const override {
return 16; }
222 bool getHasIngressDeparser()
const override {
return true; }
223 bool getHasEgressParser()
const override {
return true; }
224 bool getHasGhostThread()
const override {
return false; };
225 bool getThreadsSharePipe(gress_t, gress_t)
const override {
return true; }
226 bool getHasMirrorIOSelect()
const override {
return false; }
227 bool getHasMetadataPOV()
const override {
return false; }
228 int getSramMinPackEntries()
const override {
return 1; }
229 int getSramMaxPackEntries()
const override {
return 9; }
230 int getSramMaxPackEntriesPerRow()
const override {
return 5; }
231 int getMetaGlobalTimestampStart()
const override {
return 432; }
232 int getMetaGlobalTimestampLen()
const override {
return 48; }
233 int getMetaGlobalVersionStart()
const override {
return 480; }
234 int getMetaGlobalVersionLen()
const override {
return 32; }
235 int getSramColumnAdjust()
const override {
return 2; }
236 unsigned int getEgressIntrinsicMetadataMinLen()
const override {
return 2; }
247#ifdef EMU_OVERRIDE_STAGE_COUNT
248 const int NUM_MAU_STAGES = EMU_OVERRIDE_STAGE_COUNT;
250 const int NUM_MAU_STAGES = 20;
255 Device::Device_t device_type()
const override {
return Device::JBAY; }
256 cstring get_name()
const override {
return "Tofino2"_cs; }
257 int getNumPipes()
const override {
return 4; }
258 int getNumPortsPerPipe()
const override {
return 4; }
259 int getNumChannelsPerPort()
const override {
return 18; }
260 int getNumStages()
const override {
return NUM_MAU_STAGES; }
261 int getLongBranchTags()
const override {
return 8; }
262 int getAlwaysRunIMemAddr()
const override {
return 63; }
263 unsigned getMaxCloneId(gress_t )
const override {
return 16; }
264 gress_t getMaxGress()
const override {
return GHOST; }
265 unsigned getMaxResubmitId()
const override {
return 8; }
266 unsigned getMaxDigestId()
const override {
return 8; }
267 unsigned getMaxDigestSizeInBytes()
const override {
return (384 / 8); }
268 int getMirrorTypeWidth()
const override {
return 4; }
269 int getCloneSessionIdWidth()
const override {
return 8; }
270 int getQueueIdWidth()
const override {
return 7; }
271 int getPortBitWidth()
const override {
return 9; }
272 int getMaxParserMatchBits()
const override {
return 32; }
273 int getNumMaxChannels()
const override {
274 return getNumPipes() * getNumPortsPerPipe() * getNumChannelsPerPort();
277 const PhvSpec &getPhvSpec()
const override {
return phv_; }
278 const PardeSpec &getPardeSpec()
const override {
return parde_; }
279 const GatewaySpec &getGatewaySpec()
const override;
281 const MauSpec &getMauSpec()
const override {
return mau_; }
282 const MauPowerSpec &getMauPowerSpec()
const override {
return mau_power_; }
283 const ArchSpec &getArchSpec()
const override {
return arch_; }
284 bool getIfMemoryCoreSplit()
const override {
return true; }
285 bool getHasCompareInstructions()
const override {
return true; }
286 int getNumLogTablesPerStage()
const override {
return 16; }
287 bool getHasIngressDeparser()
const override {
return true; }
288 bool getHasEgressParser()
const override {
return true; }
289 bool getHasGhostThread()
const override {
return true; };
290 bool getThreadsSharePipe(gress_t, gress_t)
const override {
return true; }
291 bool getHasMirrorIOSelect()
const override {
return true; }
292 bool getHasMetadataPOV()
const override {
return true; }
293 int getSramMinPackEntries()
const override {
return 1; }
294 int getSramMaxPackEntries()
const override {
return 9; }
295 int getSramMaxPackEntriesPerRow()
const override {
return 5; }
296 int getMetaGlobalTimestampStart()
const override {
return 400; }
297 int getMetaGlobalTimestampLen()
const override {
return 48; }
298 int getMetaGlobalVersionStart()
const override {
return 448; }
299 int getMetaGlobalVersionLen()
const override {
return 32; }
300 int getSramColumnAdjust()
const override {
return 2; }
301 unsigned int getEgressIntrinsicMetadataMinLen()
const override {
return 8; }