49using namespace ARM::CHI;
50using namespace ruby::CHI;
53reqOpcodeToName(ReqOpcode req_opcode)
56 case REQ_OPCODE_REQ_LCRD_RETURN:
return "ReqLCrdReturn";
57 case REQ_OPCODE_READ_SHARED:
return "ReadShared";
58 case REQ_OPCODE_READ_CLEAN:
return "ReadClean";
59 case REQ_OPCODE_READ_ONCE:
return "ReadOnce";
60 case REQ_OPCODE_READ_NO_SNP:
return "ReadNoSnp";
61 case REQ_OPCODE_PCRD_RETURN:
return "PCrdReturn";
62 case REQ_OPCODE_READ_UNIQUE:
return "ReadUnique";
63 case REQ_OPCODE_CLEAN_SHARED:
return "CleanShared";
64 case REQ_OPCODE_CLEAN_INVALID:
return "CleanInvalid";
65 case REQ_OPCODE_MAKE_INVALID:
return "MakeInvalid";
66 case REQ_OPCODE_CLEAN_UNIQUE:
return "CleanUnique";
67 case REQ_OPCODE_MAKE_UNIQUE:
return "MakeUnique";
68 case REQ_OPCODE_EVICT:
return "Evict";
69 case REQ_OPCODE_EO_BARRIER:
return "EoBarrier";
70 case REQ_OPCODE_EC_BARRIER:
return "EcBarrier";
71 case REQ_OPCODE_READ_NO_SNP_SEP:
return "ReadNoSnpSep";
72 case REQ_OPCODE_CLEAN_SHARED_PERSIST_SEP:
return "CleanSharedPersistSep";
73 case REQ_OPCODE_DVM_OP:
return "DvmOp";
74 case REQ_OPCODE_WRITE_EVICT_FULL:
return "WriteEvictFull";
75 case REQ_OPCODE_WRITE_CLEAN_PTL:
return "WriteCleanPtl";
76 case REQ_OPCODE_WRITE_CLEAN_FULL:
return "WriteCleanFull";
77 case REQ_OPCODE_WRITE_UNIQUE_PTL:
return "WriteUniquePtl";
78 case REQ_OPCODE_WRITE_UNIQUE_FULL:
return "WriteUniqueFull";
79 case REQ_OPCODE_WRITE_BACK_PTL:
return "WriteBackPtl";
80 case REQ_OPCODE_WRITE_BACK_FULL:
return "WriteBackFull";
81 case REQ_OPCODE_WRITE_NO_SNP_PTL:
return "WriteNoSnpPtl";
82 case REQ_OPCODE_WRITE_NO_SNP_FULL:
return "WriteNoSnpFull";
83 case REQ_OPCODE_WRITE_UNIQUE_FULL_STASH:
return "WriteUniqueFullStash";
84 case REQ_OPCODE_WRITE_UNIQUE_PTL_STASH:
return "WriteUniquePtlStash";
85 case REQ_OPCODE_STASH_ONCE_SHARED:
return "StashOnceShared";
86 case REQ_OPCODE_STASH_ONCE_UNIQUE:
return "StashOnceUnique";
87 case REQ_OPCODE_READ_ONCE_CLEAN_INVALID:
return "ReadOnceCleanInvalid";
88 case REQ_OPCODE_READ_ONCE_MAKE_INVALID:
return "ReadOnceMakeInvalid";
89 case REQ_OPCODE_READ_NOT_SHARED_DIRTY:
return "ReadNotSharedDirty";
90 case REQ_OPCODE_CLEAN_SHARED_PERSIST:
return "CleanSharedPersist";
91 case REQ_OPCODE_ATOMIC_STORE_ADD:
return "AtomicStoreAdd";
92 case REQ_OPCODE_ATOMIC_STORE_CLR:
return "AtomicStoreClr";
93 case REQ_OPCODE_ATOMIC_STORE_EOR:
return "AtomicStoreEor";
94 case REQ_OPCODE_ATOMIC_STORE_SET:
return "AtomicStoreSet";
95 case REQ_OPCODE_ATOMIC_STORE_SMAX:
return "AtomicStoreSmax";
96 case REQ_OPCODE_ATOMIC_STORE_SMIN:
return "AtomicStoreSmin";
97 case REQ_OPCODE_ATOMIC_STORE_UMAX:
return "AtomicStoreUmax";
98 case REQ_OPCODE_ATOMIC_STORE_UMIN:
return "AtomicStoreUmin";
99 case REQ_OPCODE_ATOMIC_LOAD_ADD:
return "AtomicLoadAdd";
100 case REQ_OPCODE_ATOMIC_LOAD_CLR:
return "AtomicLoadClr";
101 case REQ_OPCODE_ATOMIC_LOAD_EOR:
return "AtomicLoadEor";
102 case REQ_OPCODE_ATOMIC_LOAD_SET:
return "AtomicLoadSet";
103 case REQ_OPCODE_ATOMIC_LOAD_SMAX:
return "AtomicLoadSmax";
104 case REQ_OPCODE_ATOMIC_LOAD_SMIN:
return "AtomicLoadSmin";
105 case REQ_OPCODE_ATOMIC_LOAD_UMAX:
return "AtomicLoadUmax";
106 case REQ_OPCODE_ATOMIC_LOAD_UMIN:
return "AtomicLoadUmin";
107 case REQ_OPCODE_ATOMIC_SWAP:
return "AtomicSwap";
108 case REQ_OPCODE_ATOMIC_COMPARE:
return "AtomicCompare";
109 case REQ_OPCODE_PREFETCH_TGT:
return "PrefetchTgt";
110 case REQ_OPCODE_MAKE_READ_UNIQUE:
return "MakeReadUnique";
111 case REQ_OPCODE_WRITE_EVICT_OR_EVICT:
return "WriteEvictOrEvict";
112 case REQ_OPCODE_WRITE_UNIQUE_ZERO:
return "WriteUniqueZero";
113 case REQ_OPCODE_WRITE_NO_SNP_ZERO:
return "WriteNoSnpZero";
114 case REQ_OPCODE_STASH_ONCE_SEP_SHARED:
return "StashOnceSepShared";
115 case REQ_OPCODE_STASH_ONCE_SEP_UNIQUE:
return "StashOnceSepUnique";
116 case REQ_OPCODE_READ_PREFER_UNIQUE:
return "ReadPreferUnique";
117 case REQ_OPCODE_WRITE_NO_SNP_FULL_CLEAN_SH:
return "WriteNoSnpFullCleanSh";
118 default:
return std::string{};
123snpOpcodeToName(SnpOpcode snp_opcode)
125 switch (snp_opcode) {
126 case SNP_OPCODE_SNP_LCRD_RETURN:
return "SnpLcrdReturn";
127 case SNP_OPCODE_SNP_SHARED:
return "SnpShared";
128 case SNP_OPCODE_SNP_CLEAN:
return "SnpClean";
129 case SNP_OPCODE_SNP_ONCE:
return "SnpOnce";
130 case SNP_OPCODE_SNP_NOT_SHARED_DIRTY:
return "SnpNotSharedDirty";
131 case SNP_OPCODE_SNP_UNIQUE_STASH:
return "SnpUniqueStash";
132 case SNP_OPCODE_SNP_MAKE_INVALID_STASH:
return "SnpMakeInvalidStash";
133 case SNP_OPCODE_SNP_UNIQUE:
return "SnpUnique";
134 case SNP_OPCODE_SNP_CLEAN_SHARED:
return "SnpCleanShared";
135 case SNP_OPCODE_SNP_CLEAN_INVALID:
return "SnpCleanInvalid";
136 case SNP_OPCODE_SNP_MAKE_INVALID:
return "SnpMakeInvalid";
137 case SNP_OPCODE_SNP_STASH_UNIQUE:
return "SnpStashUnique";
138 case SNP_OPCODE_SNP_STASH_SHARED:
return "SnpStashShared";
139 case SNP_OPCODE_SNP_DVM_OP:
return "SnpDvmOp";
140 case SNP_OPCODE_SNP_QUERY:
return "SnpQuery";
141 case SNP_OPCODE_SNP_SHARED_FWD:
return "SnpSharedFwd";
142 case SNP_OPCODE_SNP_CLEAN_FWD:
return "SnpCleanFwd";
143 case SNP_OPCODE_SNP_ONCE_FWD:
return "SnpOnceFwd";
144 case SNP_OPCODE_SNP_NOT_SHARED_DIRTY_FWD:
return "SnpNotSharedDirtyFwd";
145 case SNP_OPCODE_SNP_PREFER_UNIQUE:
return "SnpPreferUnique";
146 case SNP_OPCODE_SNP_PREFER_UNIQUE_FWD:
return "SnpPreferUniqueFwd";
147 case SNP_OPCODE_SNP_UNIQUE_FWD:
return "SnpUniqueFwd";
148 default:
return std::string{};
153datOpcodeToName(DatOpcode dat_opcode)
155 switch (dat_opcode) {
156 case DAT_OPCODE_DAT_LCRD_RETURN:
return "DatLcrdReturn";
157 case DAT_OPCODE_SNP_RESP_DATA:
return "SnpRespData";
158 case DAT_OPCODE_COPY_BACK_WR_DATA:
return "CopyBackWrData";
159 case DAT_OPCODE_NON_COPY_BACK_WR_DATA:
return "NonCopyBackWrData";
160 case DAT_OPCODE_COMP_DATA:
return "CompData";
161 case DAT_OPCODE_SNP_RESP_DATA_PTL:
return "SnpRespDataPtl";
162 case DAT_OPCODE_SNP_RESP_DATA_FWDED:
return "SnpRespDataFwded";
163 case DAT_OPCODE_WRITE_DATA_CANCEL:
return "WriteDataCancel";
164 case DAT_OPCODE_DATA_SEP_RESP:
return "DataSepResp";
165 case DAT_OPCODE_NCB_WR_DATA_COMP_ACK:
return "NcbWrDataCompAck";
166 default:
return std::string{};
171rspOpcodeToName(RspOpcode rsp_opcode)
173 switch (rsp_opcode) {
174 case RSP_OPCODE_RSP_LCRD_RETURN:
return "RspLcrdReturn";
175 case RSP_OPCODE_SNP_RESP:
return "SnpResp";
176 case RSP_OPCODE_COMP_ACK:
return "CompAck";
177 case RSP_OPCODE_RETRY_ACK:
return "RetryAck";
178 case RSP_OPCODE_COMP:
return "OpcodeComp";
179 case RSP_OPCODE_COMP_DBID_RESP:
return "CompDbidResp";
180 case RSP_OPCODE_DBID_RESP:
return "DbidResp";
181 case RSP_OPCODE_PCRD_GRANT:
return "PcrdGrant";
182 case RSP_OPCODE_READ_RECEIPT:
return "ReadReceipt";
183 case RSP_OPCODE_SNP_RESP_FWDED:
return "SnpRespFwded";
184 case RSP_OPCODE_TAG_MATCH:
return "TagMatch";
185 case RSP_OPCODE_RESP_SEP_DATA:
return "RespSepData";
186 case RSP_OPCODE_PERSIST:
return "Persist";
187 case RSP_OPCODE_COMP_PERSIST:
return "CompPersist";
188 case RSP_OPCODE_DBID_RESP_ORD:
return "DbidRespOrd";
189 case RSP_OPCODE_STASH_DONE:
return "StashDone";
190 case RSP_OPCODE_COMP_STASH_DONE:
return "CompStashDone";
191 case RSP_OPCODE_COMP_CMO:
return "CompCMO";
192 default:
return std::string{};
197phaseToOpcodeName(
const Phase &phase)
199 switch (phase.channel) {
201 return reqOpcodeToName(phase.req_opcode);
203 return snpOpcodeToName(phase.snp_opcode);
205 return datOpcodeToName(phase.dat_opcode);
207 return rspOpcodeToName(phase.rsp_opcode);
211 return std::string{};
215phaseToChannelName(
const Phase &phase)
217 switch (phase.channel) {
227 return std::string{};
237 return csprintf(
"%s %s addr=0x%08lx ns=%d size=%d attrs=0x%x",
238 phaseToChannelName(phase),
239 phaseToOpcodeName(phase).c_str(),
240 payload.address, payload.ns,
241 (
int)payload.size, (
int)payload.mem_attr);
244namespace tlm_to_ruby {
249 static std::unordered_map<uint8_t, CHIRequestType> translation_map = {
250 { REQ_OPCODE_READ_SHARED, CHIRequestType_ReadShared },
251 { REQ_OPCODE_READ_CLEAN, CHIRequestType_ReadOnce },
252 { REQ_OPCODE_READ_ONCE, CHIRequestType_ReadOnce },
253 { REQ_OPCODE_READ_NO_SNP, CHIRequestType_ReadNoSnp },
254 { REQ_OPCODE_READ_UNIQUE, CHIRequestType_ReadUnique },
255 { REQ_OPCODE_READ_NOT_SHARED_DIRTY, CHIRequestType_ReadNotSharedDirty },
256 { REQ_OPCODE_READ_PREFER_UNIQUE, CHIRequestType_ReadUnique },
257 { REQ_OPCODE_MAKE_READ_UNIQUE, CHIRequestType_MakeReadUnique },
259 { REQ_OPCODE_CLEAN_UNIQUE, CHIRequestType_CleanUnique },
260 { REQ_OPCODE_MAKE_UNIQUE, CHIRequestType_CleanUnique },
261 { REQ_OPCODE_EVICT, CHIRequestType_Evict },
262 { REQ_OPCODE_STASH_ONCE_SEP_SHARED, CHIRequestType_StashOnceShared },
263 { REQ_OPCODE_STASH_ONCE_SEP_UNIQUE, CHIRequestType_StashOnceUnique },
264 { REQ_OPCODE_WRITE_NO_SNP_PTL, CHIRequestType_WriteUniquePtl },
265 { REQ_OPCODE_WRITE_NO_SNP_FULL, CHIRequestType_WriteUniqueFull },
266 { REQ_OPCODE_WRITE_UNIQUE_FULL, CHIRequestType_WriteUniqueFull },
267 { REQ_OPCODE_WRITE_UNIQUE_ZERO, CHIRequestType_WriteUniqueZero },
268 { REQ_OPCODE_WRITE_BACK_FULL, CHIRequestType_WriteBackFull },
269 { REQ_OPCODE_WRITE_EVICT_OR_EVICT, CHIRequestType_WriteEvictFull },
272 auto it = translation_map.find(req);
273 if (it != translation_map.end()) {
276 panic(
"Unsupported Translation: %s\n", reqOpcodeToName(req));
280#define RESP_CASE(opc) \
282 case RESP_I: return opc ## _ ## I; \
283 case RESP_SC: return opc ## _ ## SC; \
284 case RESP_UC: return opc ## _ ## UC; \
285 case RESP_SD: return opc ## _ ## SD; \
286 case RESP_I_PD: return opc ## _ ## I_PD; \
287 case RESP_SC_PD: return opc ## _ ## SC_PD; \
288 case RESP_UC_PD: return opc ## _ ## UC; \
289 case RESP_SD_PD: return opc ## _ ## SD; \
290 default: panic(""); \
280#define RESP_CASE(opc) \ …
297 case DAT_OPCODE_NON_COPY_BACK_WR_DATA:
298 return CHIDataType_NCBWrData;
299 case DAT_OPCODE_COPY_BACK_WR_DATA:
301 case RESP_I:
return CHIDataType_CBWrData_I;
302 case RESP_UC:
return CHIDataType_CBWrData_UC;
303 case RESP_SC:
return CHIDataType_CBWrData_SC;
304 case RESP_UD_PD:
return CHIDataType_CBWrData_UD_PD;
307 case DAT_OPCODE_SNP_RESP_DATA:
310 panic(
"Unsupported Translation: %s\n", datOpcodeToName(dat));
318 case RSP_OPCODE_COMP_ACK:
return CHIResponseType_CompAck;
319 case RSP_OPCODE_SNP_RESP:
321 case RESP_I:
return CHIResponseType_SnpResp_I;
322 default:
panic(
"Invalid resp %d for %d\n", resp, opc);
325 panic(
"Unsupported Translation: %s\n", rspOpcodeToName(opc));
244namespace tlm_to_ruby {
…}
331namespace ruby_to_tlm {
337 case CHIDataType_CompData_I:
338 case CHIDataType_CompData_UC:
339 case CHIDataType_CompData_SC:
340 case CHIDataType_CompData_UD_PD:
341 case CHIDataType_CompData_SD_PD:
343 case CHIDataType_DataSepResp_UC:
345 case CHIDataType_CBWrData_UC:
346 case CHIDataType_CBWrData_SC:
347 case CHIDataType_CBWrData_UD_PD:
348 case CHIDataType_CBWrData_SD_PD:
349 case CHIDataType_CBWrData_I:
351 case CHIDataType_NCBWrData:
353 case CHIDataType_SnpRespData_I:
354 case CHIDataType_SnpRespData_I_PD:
355 case CHIDataType_SnpRespData_SC:
356 case CHIDataType_SnpRespData_SC_PD:
357 case CHIDataType_SnpRespData_SD:
358 case CHIDataType_SnpRespData_UC:
359 case CHIDataType_SnpRespData_UD:
361 case CHIDataType_SnpRespData_SC_Fwded_SC:
362 case CHIDataType_SnpRespData_SC_Fwded_SD_PD:
363 case CHIDataType_SnpRespData_SC_PD_Fwded_SC:
364 case CHIDataType_SnpRespData_SD_Fwded_SC:
365 case CHIDataType_SnpRespData_I_Fwded_SD_PD:
366 case CHIDataType_SnpRespData_I_PD_Fwded_SC:
367 case CHIDataType_SnpRespData_I_Fwded_SC:
370 panic(
"Unrecognised data opcode: %d\n", dat);
378 case CHIResponseType_Comp_UD_PD:
379 case CHIResponseType_Comp_UC:
380 case CHIResponseType_Comp_I:
381 return RSP_OPCODE_COMP;
382 case CHIResponseType_CompDBIDResp:
383 return RSP_OPCODE_COMP_DBID_RESP;
384 case CHIResponseType_RetryAck:
385 return RSP_OPCODE_RETRY_ACK;
387 panic(
"Unrecognised rsp opcode: %d\n", rsp);
395 case CHIRequestType_SnpOnceFwd:
396 return SNP_OPCODE_SNP_ONCE_FWD;
397 case CHIRequestType_SnpOnce:
398 return SNP_OPCODE_SNP_ONCE;
399 case CHIRequestType_SnpShared:
400 return SNP_OPCODE_SNP_SHARED;
401 case CHIRequestType_SnpCleanInvalid:
402 return SNP_OPCODE_SNP_CLEAN_INVALID;
403 case CHIRequestType_SnpUnique:
404 return SNP_OPCODE_SNP_UNIQUE;
406 panic(
"Unrecognised snp opcode: %d\n", snp);
414 case CHIDataType_SnpRespData_I:
415 case CHIDataType_CompData_I:
416 case CHIDataType_CBWrData_I:
418 case CHIDataType_SnpRespData_SC:
419 case CHIDataType_CompData_SC:
420 case CHIDataType_CBWrData_SC:
422 case CHIDataType_SnpRespData_UC:
423 case CHIDataType_CompData_UC:
424 case CHIDataType_CBWrData_UC:
425 case CHIDataType_DataSepResp_UC:
427 case CHIDataType_SnpRespData_UD:
429 case CHIDataType_SnpRespData_SD:
431 case CHIDataType_SnpRespData_I_PD:
433 case CHIDataType_SnpRespData_SC_PD:
435 case CHIDataType_CompData_UD_PD:
436 case CHIDataType_CBWrData_UD_PD:
438 case CHIDataType_CompData_SD_PD:
439 case CHIDataType_CBWrData_SD_PD:
442 case CHIDataType_SnpRespData_SC_Fwded_SC:
443 case CHIDataType_SnpRespData_SC_Fwded_SD_PD:
444 case CHIDataType_SnpRespData_SC_PD_Fwded_SC:
445 case CHIDataType_SnpRespData_SD_Fwded_SC:
446 case CHIDataType_SnpRespData_I_Fwded_SD_PD:
447 case CHIDataType_SnpRespData_I_PD_Fwded_SC:
448 case CHIDataType_SnpRespData_I_Fwded_SC:
450 panic(
"Unrecognised data opcode: %d\n", dat);
458 case CHIResponseType_Comp_I:
460 case CHIResponseType_Comp_UC:
462 case CHIResponseType_Comp_UD_PD:
464 case CHIResponseType_CompDBIDResp:
466 case CHIResponseType_RetryAck:
470 panic(
"Unrecognised rsp opcode: %d\n", rsp);
331namespace ruby_to_tlm {
…}
485 uint64_t bus_width = 256;
488 return bits(address, 5, 4);
490 return bits(address, 5, 4) & 0b10;
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define panic(...)
This implements a cprintf based panic() function.
uint8_t snpOpcode(CHIRequestType snp)
uint8_t rspOpcode(CHIResponseType rsp)
Resp rspResp(CHIResponseType rsp)
Resp datResp(CHIDataType dat)
uint8_t datOpcode(CHIDataType dat)
CHIDataType datOpcode(DatOpcode dat, Resp resp)
CHIResponseType rspOpcode(RspOpcode opc, Resp resp)
CHIRequestType reqOpcode(ReqOpcode req)
Addr transactionSize(Size sz)
std::string transactionToString(const Payload &payload, const Phase &phase)
uint8_t dataId(Addr address)
Copyright (c) 2024 Arm Limited All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::string csprintf(const char *format, const Args &...args)