scc  2024.06
SystemC components library
axi_ace_scv.cpp
1 /*
2  * Copyright 2020 Arteris IP
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <axi/axi_tlm.h>
18 #include <tlm/scc/scv/tlm_extension_recording_registry.h>
19 #include <tlm/scc/scv/tlm_recorder.h>
20 #include <tlm/scc/tlm_id.h>
21 
22 namespace axi {
23 namespace scv {
24 
26 
27  void recordBeginTx(SCVNS scv_tr_handle& handle, axi_protocol_types::tlm_payload_type& trans) override {
28  if(auto ext = trans.get_extension<tlm::scc::tlm_id_extension>()) {
29  handle.record_attribute("trans.uid", ext->id);
30  }
31  }
32 
33  void recordEndTx(SCVNS scv_tr_handle& handle, tlm::tlm_base_protocol_types::tlm_payload_type& trans) override {
34  }
35 };
36 
38 
39  void recordBeginTx(SCVNS scv_tr_handle& handle, axi_protocol_types::tlm_payload_type& trans) override {
40  if(auto ext3 = trans.get_extension<axi3_extension>()) { // CTRL, DATA, RESP
41  handle.record_attribute("trans.axi3.id", ext3->get_id());
42  handle.record_attribute("trans.axi3.user[CTRL]", ext3->get_user(common::id_type::CTRL));
43  handle.record_attribute("trans.axi3.user[DATA]", ext3->get_user(common::id_type::DATA));
44  handle.record_attribute("trans.axi3.user[RESP]", ext3->get_user(common::id_type::RESP));
45  handle.record_attribute("trans.axi3.length", ext3->get_length());
46  handle.record_attribute("trans.axi3.size", ext3->get_size());
47  handle.record_attribute("trans.axi3.burst", std::string(to_char(ext3->get_burst())));
48  handle.record_attribute("trans.axi3.prot", ext3->get_prot());
49  handle.record_attribute("trans.axi3.exclusive", std::string(ext3->is_exclusive() ? "true" : "false"));
50  handle.record_attribute("trans.axi3.cache", ext3->get_cache());
51  handle.record_attribute("trans.axi4.cache_bufferable", ext3->is_bufferable());
52  handle.record_attribute("trans.axi4.cache_cacheable", ext3->is_cacheable());
53  handle.record_attribute("trans.axi4.cache_read_alloc", ext3->is_read_allocate());
54  handle.record_attribute("trans.axi4.cache_write_alloc", ext3->is_write_allocate());
55  handle.record_attribute("trans.axi3.qos", ext3->get_qos());
56  handle.record_attribute("trans.axi3.region", ext3->get_region());
57  }
58  }
59 
60  void recordEndTx(SCVNS scv_tr_handle& handle, axi_protocol_types::tlm_payload_type& trans) override {
61  if(auto ext3 = trans.get_extension<axi3_extension>()) {
62  handle.record_attribute("trans.axi3.resp", std::string(to_char(ext3->get_resp())));
63  }
64  }
65 };
67 
68  void recordBeginTx(SCVNS scv_tr_handle& handle, axi_protocol_types::tlm_payload_type& trans) override {
69  if(auto ext4 = trans.get_extension<axi4_extension>()) {
70  handle.record_attribute("trans.axi4.id", ext4->get_id());
71  handle.record_attribute("trans.axi4.user[CTRL]", ext4->get_user(common::id_type::CTRL));
72  handle.record_attribute("trans.axi4.user[DATA]", ext4->get_user(common::id_type::DATA));
73  handle.record_attribute("trans.axi4.user[RESP]", ext4->get_user(common::id_type::RESP));
74  handle.record_attribute("trans.axi4.length", ext4->get_length());
75  handle.record_attribute("trans.axi4.size", ext4->get_size());
76  handle.record_attribute("trans.axi4.burst", std::string(to_char(ext4->get_burst())));
77  handle.record_attribute("trans.axi4.prot", ext4->get_prot());
78  handle.record_attribute("trans.axi4.exclusive", std::string(ext4->is_exclusive() ? "true" : "false"));
79  handle.record_attribute("trans.axi4.cache", ext4->get_cache());
80  handle.record_attribute("trans.axi4.cache_bufferable", ext4->is_bufferable());
81  handle.record_attribute("trans.axi4.cache_modifiable", ext4->is_modifiable());
82  handle.record_attribute("trans.axi4.cache_allocate", ext4->is_allocate());
83  handle.record_attribute("trans.axi4.cache_other_alloc", ext4->is_other_allocate());
84  handle.record_attribute("trans.axi4.qos", ext4->get_qos());
85  handle.record_attribute("trans.axi4.region", ext4->get_region());
86  }
87  }
88 
89  void recordEndTx(SCVNS scv_tr_handle& handle, axi_protocol_types::tlm_payload_type& trans) override {
90  if(auto ext4 = trans.get_extension<axi4_extension>()) {
91  handle.record_attribute("trans.axi4.resp", std::string(to_char(ext4->get_resp())));
92  }
93  }
94 };
96 
97  void recordBeginTx(SCVNS scv_tr_handle& handle, axi_protocol_types::tlm_payload_type& trans) override {
98  if(auto ext4 = trans.get_extension<ace_extension>()) {
99  handle.record_attribute("trans.ace.id", ext4->get_id());
100  handle.record_attribute("trans.ace.user[CTRL]", ext4->get_user(common::id_type::CTRL));
101  handle.record_attribute("trans.ace.user[DATA]", ext4->get_user(common::id_type::DATA));
102  handle.record_attribute("trans.ace.length", ext4->get_length());
103  handle.record_attribute("trans.ace.size", ext4->get_size());
104  handle.record_attribute("trans.ace.burst", std::string(to_char(ext4->get_burst())));
105  handle.record_attribute("trans.ace.prot", ext4->get_prot());
106  handle.record_attribute("trans.ace.exclusive", std::string(ext4->is_exclusive() ? "true" : "false"));
107  handle.record_attribute("trans.ace.cache", ext4->get_cache());
108  handle.record_attribute("trans.ace.cache_bufferable", ext4->is_bufferable());
109  handle.record_attribute("trans.ace.cache_modifiable", ext4->is_modifiable());
110  handle.record_attribute("trans.ace.cache_allocate", ext4->is_allocate());
111  handle.record_attribute("trans.ace.cache_other_alloc", ext4->is_other_allocate());
112  handle.record_attribute("trans.ace.qos", ext4->get_qos());
113  handle.record_attribute("trans.ace.region", ext4->get_region());
114  handle.record_attribute("trans.ace.domain", std::string(to_char(ext4->get_domain())));
115  handle.record_attribute("trans.ace.snoop", std::string(to_char(ext4->get_snoop())));
116  handle.record_attribute("trans.ace.barrier", std::string(to_char(ext4->get_barrier())));
117  handle.record_attribute("trans.ace.unique", ext4->get_unique());
118  }
119  }
120 
121  void recordEndTx(SCVNS scv_tr_handle& handle, axi_protocol_types::tlm_payload_type& trans) override {
122  if(auto ext4 = trans.get_extension<ace_extension>()) {
123  handle.record_attribute("trans.ace.resp", std::string(to_char(ext4->get_resp())));
124  handle.record_attribute("trans.ace.cresp", static_cast<unsigned>(ext4->get_cresp()));
125  handle.record_attribute("trans.ace.cresp_PassDirty", ext4->is_pass_dirty());
126  handle.record_attribute("trans.ace.cresp_IsShared", ext4->is_shared());
127  handle.record_attribute("trans.ace.cresp_SnoopDataTransfer", ext4->is_snoop_data_transfer());
128  handle.record_attribute("trans.ace.cresp_SnoopError", ext4->is_snoop_error());
129  handle.record_attribute("trans.ace.cresp_SnoopWasUnique", ext4->is_snoop_was_unique());
130  }
131  }
132 };
133 
134 #if defined(__GNUG__)
135 __attribute__((constructor))
136 #endif
137 bool register_extensions() {
138  tlm::scc::tlm_id_extension ext(nullptr); // NOLINT
140  ext.ID, new tlm_id_ext_recording()); // NOLINT
141  axi::axi3_extension ext3; // NOLINT
143  ext3.ID, new axi::scv::axi3_ext_recording()); // NOLINT
144  axi::axi4_extension ext4; // NOLINT
146  ext4.ID, new axi::scv::axi4_ext_recording()); // NOLINT
147  axi::ace_extension extace; // NOLINT
149  extace.ID, new axi::scv::ace_ext_recording()); // NOLINT
150  return true; // NOLINT
151 }
152 bool registered = register_extensions();
153 } // namespace scv
154 } // namespace axi
The TLM transaction extensions recorder registry.
The TLM transaction extensions recorder interface.
TLM2.0 components modeling AHB.
Definition: axi_initiator.h:30
const char * to_char(E t)