19 #include <tlm/scc/scv/tlm_extension_recording_registry.h>
23 std::array<std::string, 3> cmd_str{
"R",
"W",
"I"};
25 std::array<char const*, 103> opc2str = {
45 "CleanSharedPersistSep",
58 "WriteUniqueFullStash",
59 "WriteUniquePtlStash",
62 "ReadOnceCleanInvalid",
63 "ReadOnceMakeInvalid",
106 "WriteNoSnpFullCleanSh",
107 "WriteNoSnpFullCleanInv",
108 "WriteNoSnpFullCleanShPerSep",
110 "WriteUniqueFullCleanSh",
112 "WriteUniqueFullCleanShPerSep",
114 "WriteBackFullCleanSh",
115 "WriteBackFullCleanInv",
116 "WriteBackFullCleanShPerSep",
118 "WriteCleanFullCleanSh",
120 "WriteCleanFullCleanShPerSep",
122 "WriteNoSnpPtlCleanSh",
123 "WriteNoSnpPtlCleanInv",
124 "WriteNoSnpPtlCleanShPerSep",
126 "WriteUniquePtlCleanSh",
128 "WriteUniquePtlCleanShPerSep",
130 template <>
const char* to_char<req_optype_e>(req_optype_e v) {
131 auto idx =
static_cast<unsigned>(v);
132 if(idx<opc2str.size())
134 else return "RESERVED";
137 template <>
const char* to_char<dat_optype_e>(dat_optype_e v) {
139 case dat_optype_e::DataLCrdReturn:
140 return "DataLCrdReturn";
141 case dat_optype_e::SnpRespData:
142 return "SnpRespData";
143 case dat_optype_e::CopyBackWrData:
144 return "CopyBackWrData";
145 case dat_optype_e::NonCopyBackWrData:
146 return "NonCopyBackWrData";
147 case dat_optype_e::CompData:
149 case dat_optype_e::SnpRespDataPtl:
150 return "SnpRespDataPtl";
151 case dat_optype_e::SnpRespDataFwded:
152 return "SnpRespDataFwded";
153 case dat_optype_e::WriteDataCancel:
154 return "WriteDataCancel";
155 case dat_optype_e::DataSepResp:
156 return "DataSepResp";
157 case dat_optype_e::NCBWrDataCompAck:
158 return "NCBWrDataCompAck";
160 return "UNKNOWN_dat_optype_e";
164 template <>
const char* to_char<rsp_optype_e>(rsp_optype_e v) {
166 case rsp_optype_e::RespLCrdReturn:
167 return "RespLCrdReturn";
168 case rsp_optype_e::SnpResp:
170 case rsp_optype_e::CompAck:
172 case rsp_optype_e::RetryAck:
174 case rsp_optype_e::Comp:
176 case rsp_optype_e::CompDBIDResp:
177 return "CompDBIDResp";
178 case rsp_optype_e::DBIDResp:
180 case rsp_optype_e::PCrdGrant:
182 case rsp_optype_e::ReadReceipt:
183 return "ReadReceipt";
184 case rsp_optype_e::SnpRespFwded:
185 return "SnpRespFwded";
186 case rsp_optype_e::TagMatch:
188 case rsp_optype_e::RespSepData:
189 return "RespSepData";
190 case rsp_optype_e::Persist:
192 case rsp_optype_e::CompPersist:
193 return "CompPersist";
194 case rsp_optype_e::DBIDRespOrd:
195 return "DBIDRespOrd";
196 case rsp_optype_e::StashDone:
198 case rsp_optype_e::CompStashDone:
199 return "CompStashDone";
200 case rsp_optype_e::CompCMO:
202 case rsp_optype_e::INVALID:
205 return "UNKNOWN_rsp_optype_e";
209 template <>
const char* to_char<snp_optype_e>(snp_optype_e v) {
211 case snp_optype_e::SnpLCrdReturn:
212 return "SnpLCrdReturn";
213 case snp_optype_e::SnpShared:
215 case snp_optype_e::SnpClean:
217 case snp_optype_e::SnpOnce:
219 case snp_optype_e::SnpNotSharedDirty:
220 return "SnpNotSharedDirty";
221 case snp_optype_e::SnpUniqueStash:
222 return "SnpUniqueStash";
223 case snp_optype_e::SnpMakeInvalidStash:
224 return "SnpMakeInvalidStash";
225 case snp_optype_e::SnpUnique:
227 case snp_optype_e::SnpCleanShared:
228 return "SnpCleanShared";
229 case snp_optype_e::SnpCleanInvalid:
230 return "SnpCleanInvalid";
231 case snp_optype_e::SnpMakeInvalid:
232 return "SnpMakeInvalid";
233 case snp_optype_e::SnpStashUnique:
234 return "SnpStashUnique";
235 case snp_optype_e::SnpStashShared:
236 return "SnpStashShared";
237 case snp_optype_e::SnpDVMOp:
239 case snp_optype_e::SnpSharedFwd:
240 return "SnpSharedFwd";
241 case snp_optype_e::SnpCleanFwd:
242 return "SnpCleanFwd";
243 case snp_optype_e::SnpOnceFwd:
245 case snp_optype_e::SnpNotSharedDirtyFwd:
246 return "SnpNotSharedDirtyFwd";
247 case snp_optype_e::SnpUniqueFwd:
248 return "SnpUniqueFwd";
250 return "UNKNOWN_snp_optype_e";
254 template <>
const char* to_char<dat_resptype_e>(dat_resptype_e v) {
265 case dat_resptype_e::CompData_UD_PD:
266 return "CompData_UD_PD";
267 case dat_resptype_e::CompData_SD_PD:
268 return "CompData_SD_PD";
269 case dat_resptype_e::Comp_I:
271 case dat_resptype_e::Comp_UC:
273 case dat_resptype_e::Comp_SC:
283 return "UNKNOWN_dat_resptype_e";
287 template <>
const char* to_char<rsp_resptype_e>(rsp_resptype_e v) {
289 case rsp_resptype_e::SnpResp_I:
291 case rsp_resptype_e::SnpResp_SC:
293 case rsp_resptype_e::SnpResp_UC:
296 case rsp_resptype_e::SnpResp_SD:
299 return "UNKNOWN_rsp_resptype_e";
303 template <>
const char* to_char<rsp_resperrtype_e>(rsp_resperrtype_e v) {
305 case rsp_resperrtype_e::OK:
307 case rsp_resperrtype_e::EXOK:
309 case rsp_resperrtype_e::DERR:
311 case rsp_resperrtype_e::NDERR:
314 return "rsp_resperrtype_e";
318 template <>
const char* to_char<credit_type_e>(credit_type_e v) {
320 case credit_type_e::LINK:
322 case credit_type_e::REQ:
324 case credit_type_e::RESP:
326 case credit_type_e::DATA:
329 return "credit_type_e";
333 std::ostream& operator<<(std::ostream& os,
const tlm::tlm_generic_payload& t) {
335 t.get_command() == tlm::TLM_READ_COMMAND ?
"AR" : (t.get_command() == tlm::TLM_WRITE_COMMAND ?
"AW" :
"");
336 os <<
"CMD:" << cmd_str[t.get_command()] <<
", " << ch <<
"ADDR:0x" << std::hex << t.get_address() <<
", TXLEN:0x"
337 << t.get_data_length();
339 os <<
", TXNID:"<<ext->get_txn_id();
342 os <<
", TXNID:"<<ext->get_txn_id();
345 os <<
" [ptr:" << &t <<
"]";
348 template <>
const char* is_valid_msg<chi::chi_ctrl_extension>(
chi_ctrl_extension* ext) {
349 auto sz = ext->req.get_size();
351 return "Illegal size setting, maximum is 6";
352 switch(ext->req.get_opcode()) {
353 case req_optype_e::ReadNoSnp:
354 case req_optype_e::ReadNoSnpSep:
355 case req_optype_e::WriteNoSnpPtl:
356 case req_optype_e::WriteUniquePtl:
357 case req_optype_e::WriteUniquePtlStash:
360 if(!is_dataless(ext) && sz<6)
return "Coherent transactions allow only cache line size data transfers";
367 #include <tlm/scc/scv/tlm_recorder.h>
368 #include <tlm/scc/tlm_id.h>
374 void recordBeginTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {
376 handle.record_attribute(
"trans.uid", ext->id);
380 void recordEndTx(SCVNS scv_tr_handle& handle, tlm::tlm_base_protocol_types::tlm_payload_type& trans)
override {
386 void recordBeginTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {
389 handle.record_attribute(
"trans.chi_c.qos", ext->get_qos());
390 handle.record_attribute(
"trans.chi_c.src_id", ext->get_src_id());
391 handle.record_attribute(
"trans.chi_c.txn_id", ext->get_txn_id());
392 handle.record_attribute(
"trans.chi_c.tgt_id", ext->req.get_tgt_id());
393 handle.record_attribute(
"trans.chi_c.lp_id", ext->req.get_lp_id());
394 handle.record_attribute(
"trans.chi_c.return_txn_id", ext->req.get_return_txn_id());
395 handle.record_attribute(
"trans.chi_c.stash_lp_id", ext->req.get_stash_lp_id());
396 handle.record_attribute(
"trans.chi_c.size", ext->req.get_size());
397 handle.record_attribute(
"trans.chi_c.mem_attr", ext->req.get_mem_attr());
398 handle.record_attribute(
"trans.chi_c.req.pcrd_type", ext->req.get_pcrd_type());
399 handle.record_attribute(
"trans.chi_c.order", ext->req.get_order());
400 handle.record_attribute(
"trans.chi_c.endian", ext->req.is_endian());
401 handle.record_attribute(
"trans.chi_c.req.trace_tag", ext->req.is_trace_tag());
402 handle.record_attribute(
"trans.chi_c.return_n_id", ext->req.get_return_n_id());
403 handle.record_attribute(
"trans.chi_c.stash_n_id", ext->req.get_stash_n_id());
404 handle.record_attribute(
"trans.chi_c.opcode", std::string(
to_char(ext->req.get_opcode())));
405 handle.record_attribute(
"trans.chi_c.stash_nnode_id_valid", ext->req.is_stash_n_id_valid());
406 handle.record_attribute(
"trans.chi_c.stash_lp_id_valid", ext->req.is_stash_lp_id_valid());
407 handle.record_attribute(
"trans.chi_c.non_secure", ext->req.is_non_secure());
408 handle.record_attribute(
"trans.chi_c.exp_comp_ack", ext->req.is_exp_comp_ack());
409 handle.record_attribute(
"trans.chi_c.allow_retry", ext->req.is_allow_retry());
410 handle.record_attribute(
"trans.chi_c.snp_attr", ext->req.is_snp_attr());
411 handle.record_attribute(
"trans.chi_c.excl", ext->req.is_excl());
412 handle.record_attribute(
"trans.chi_c.snoop_me", ext->req.is_snoop_me());
413 handle.record_attribute(
"trans.chi_c.likely_shared", ext->req.is_likely_shared());
414 handle.record_attribute(
"trans.chi_c.txn_rsvdc", ext->req.get_rsvdc());
415 handle.record_attribute(
"trans.chi_c.tag_op", ext->req.get_tag_op());
416 handle.record_attribute(
"trans.chi_c.tag_group_id", ext->req.get_tag_group_id());
417 handle.record_attribute(
"trans.chi_c.mpam", ext->req.get_mpam());
418 handle.record_attribute(
"trans.chi_c.rsp.db_id", ext->resp.get_db_id());
419 handle.record_attribute(
"trans.chi_c.rsp.pcrd_type", ext->resp.get_pcrd_type());
420 handle.record_attribute(
"trans.chi_c.rsp.resp_err", std::string(
to_char(ext->resp.get_resp_err())));
421 handle.record_attribute(
"trans.chi_c.rsp.fwd_state", ext->resp.get_fwd_state());
422 handle.record_attribute(
"trans.chi_c.rsp.data_pull", ext->resp.get_data_pull());
423 handle.record_attribute(
"trans.chi_c.rsp.opcode", std::string(
to_char(ext->resp.get_opcode())));
424 handle.record_attribute(
"trans.chi_c.rsp.resp", std::string(
to_char(ext->resp.get_resp())));
425 handle.record_attribute(
"trans.chi_c.rsp.tgt_id", ext->resp.get_tgt_id());
426 handle.record_attribute(
"trans.chi_c.rsp.trace_tag", ext->resp.is_trace_tag());
427 handle.record_attribute(
"trans.chi_c.rsp.tag_op", ext->resp.get_tag_op());
428 handle.record_attribute(
"trans.chi_c.rsp.tag_group_id", ext->resp.get_tag_group_id());
432 void recordEndTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {}
437 void recordBeginTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {
440 handle.record_attribute(
"trans.chi_d.qos", ext->get_qos());
441 handle.record_attribute(
"trans.chi_d.src_id", ext->get_src_id());
442 handle.record_attribute(
"trans.chi_d.txn_id", ext->get_txn_id());
443 handle.record_attribute(
"trans.chi_d.db_id", ext->dat.get_db_id());
444 handle.record_attribute(
"trans.chi_d.resp_err", std::string(
to_char(ext->dat.get_resp_err())));
445 handle.record_attribute(
"trans.chi_d.resp", std::string(
to_char(ext->dat.get_resp())));
446 handle.record_attribute(
"trans.chi_d.fwd_state", ext->dat.get_fwd_state());
447 handle.record_attribute(
"trans.chi_d.data_pull", ext->dat.get_data_pull());
448 handle.record_attribute(
"trans.chi_d.data_source", ext->dat.get_data_source());
449 handle.record_attribute(
"trans.chi_d.cc_id", ext->dat.get_cc_id());
450 handle.record_attribute(
"trans.chi_d.data_id", ext->dat.get_data_id());
451 handle.record_attribute(
"trans.chi_d.poison", ext->dat.get_poison());
452 handle.record_attribute(
"trans.chi_d.tgt_id", ext->dat.get_tgt_id());
453 handle.record_attribute(
"trans.chi_d.home_node_id", ext->dat.get_home_n_id());
454 handle.record_attribute(
"trans.chi_d.opcode", std::string(
to_char(ext->dat.get_opcode())));
455 handle.record_attribute(
"trans.chi_d.rsvdc", ext->dat.get_rsvdc());
456 handle.record_attribute(
"trans.chi_d.data_check", ext->dat.get_data_check());
457 handle.record_attribute(
"trans.chi_d.trace_tag", ext->dat.is_trace_tag());
458 handle.record_attribute(
"trans.chi_d.tag_op", ext->dat.get_tag_op());
459 handle.record_attribute(
"trans.chi_c.tag", ext->dat.get_tag());
460 handle.record_attribute(
"trans.chi_c.tu", ext->dat.get_tu());
464 void recordEndTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {}
469 void recordBeginTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {
472 handle.record_attribute(
"trans.chi_s.qos", ext->get_qos());
473 handle.record_attribute(
"trans.chi_s.src_id", ext->get_src_id());
474 handle.record_attribute(
"trans.chi_s.txn_id", ext->get_txn_id());
475 handle.record_attribute(
"trans.chi_s.fwd_txn_id", ext->req.get_fwd_txn_id());
476 handle.record_attribute(
"trans.chi_s.stash_lp_id", ext->req.get_stash_lp_id());
477 handle.record_attribute(
"trans.chi_s.vm_id_ext", ext->req.get_vm_id_ext());
478 handle.record_attribute(
"trans.chi_s.stash_lp_id_valid", ext->req.is_stash_lp_id_valid());
479 handle.record_attribute(
"trans.chi_s.opcode", std::string(
to_char(ext->req.get_opcode())));
480 handle.record_attribute(
"trans.chi_s.fwd_n_id", ext->req.get_fwd_n_id());
481 handle.record_attribute(
"trans.chi_s.non_secure", ext->req.is_non_secure());
482 handle.record_attribute(
"trans.chi_s.do_not_goto_sd", ext->req.is_do_not_goto_sd());
483 handle.record_attribute(
"trans.chi_s.do_not_data_pull", ext->req.is_do_not_data_pull());
484 handle.record_attribute(
"trans.chi_s.ret_to_src", ext->req.is_ret_to_src());
485 handle.record_attribute(
"trans.chi_s.trace_tag", ext->req.is_trace_tag());
486 handle.record_attribute(
"trans.chi_s.rsp.db_id", ext->resp.get_db_id());
487 handle.record_attribute(
"trans.chi_s.rsp.pcrd_type", ext->resp.get_pcrd_type());
488 handle.record_attribute(
"trans.chi_s.rsp.resp_err", std::string(
to_char(ext->resp.get_resp_err())));
489 handle.record_attribute(
"trans.chi_s.rsp.fwd_state", ext->resp.get_fwd_state());
490 handle.record_attribute(
"trans.chi_s.rsp.data_pull", ext->resp.get_data_pull());
491 handle.record_attribute(
"trans.chi_s.rsp.opcode", std::string(
to_char(ext->resp.get_opcode())));
492 handle.record_attribute(
"trans.chi_s.rsp.resp", std::string(
to_char(ext->resp.get_resp())));
493 handle.record_attribute(
"trans.chi_s.rsp.tgt_id", ext->resp.get_tgt_id());
494 handle.record_attribute(
"trans.chi_s.rsp.trace_tag", ext->resp.is_trace_tag());
498 void recordEndTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {}
503 void recordBeginTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {
506 handle.record_attribute(
"trans.chi_credit.type", std::string(
to_char(ext->type)));
507 handle.record_attribute(
"trans.chi_credit.count", ext->count);
511 void recordEndTx(SCVNS scv_tr_handle& handle, chi_protocol_types::tlm_payload_type& trans)
override {
514 handle.record_attribute(
"trans.chi_credit.type", std::string(
to_char(ext->type)));
515 handle.record_attribute(
"trans.chi_credit.count", ext->count);
521 #if defined(__GNUG__)
522 __attribute__((constructor))
524 bool register_extensions() {
546 bool registered = register_extensions();
The TLM transaction extensions recorder registry.
The TLM transaction extensions recorder interface.
TLM2.0 components modeling CHI.
const char * to_char(E t)
SCC SCV4TLM classes and functions.