scc  2024.06
SystemC components library
ace_rec_sockets.h
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.axi_util.cpp
15  */
16 
17 #pragma once
18 
19 #include "ace_recorder.h"
20 #include <axi/axi_tlm.h>
21 
22 namespace axi {
23 namespace scv {
24 
25 template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
26  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
27 class ace_rec_initiator_socket : public axi::ace_initiator_socket<BUSWIDTH, TYPES, N, POL> {
28  static std::string gen_name(const char* first, const char* second) {
29  std::stringstream ss;
30  ss << first << "_" << second;
31  return ss.str();
32  }
33 
34 public:
35  using fw_interface_type = axi::ace_fw_transport_if<TYPES>;
37  using port_type = sc_core::sc_port<fw_interface_type, N, POL>;
38  using export_type = sc_core::sc_export<bw_interface_type>;
39  using base_target_socket_type = tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type>;
40  using base_type = tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type>;
41 
44  , recorder(gen_name(this->name(), "tx").c_str()) {
45  this->add_attribute(recorder.enableTracing);
46  this->add_attribute(recorder.enableTimed);
47  }
48 
49  explicit ace_rec_initiator_socket(const char* name)
51  , recorder(gen_name(this->name(), "tx").c_str()) {}
52 
53  virtual ~ace_rec_initiator_socket() {}
54 
55  virtual const char* kind() const { return "axi_rec_initiator_socket"; }
56  //
57  // Bind initiator socket to target socket
58  // - Binds the port of the initiator socket to the export of the target
59  // socket
60  // - Binds the port of the target socket to the export of the initiator
61  // socket
62  //
63  virtual void bind(base_target_socket_type& s) {
64  // initiator.port -> target.export
65  (this->get_base_port())(recorder);
66  recorder.fw_port(s.get_base_interface());
67  // target.port -> initiator.export
68  (s.get_base_port())(recorder);
69  recorder.bw_port(this->get_base_interface());
70  }
71  //
72  // Bind initiator socket to initiator socket (hierarchical bind)
73  // - Binds both the export and the port
74  //
75  virtual void bind(base_type& s) {
76  // port
77  (this->get_base_port())(recorder);
78  recorder.fw_port(s.get_base_port());
79  // export
80  (s.get_base_export())(recorder);
81  recorder.bw_port(this->get_base_export());
82  }
83 
84  //
85  // Bind interface to socket
86  // - Binds the interface to the export of this socket
87  //
88  virtual void bind(bw_interface_type& ifs) { (this->get_base_export())(ifs); }
89 
90  void setExtensionRecording(tlm::scc::scv::tlm_extensions_recording_if<TYPES>* extensionRecording) {
91  recorder.setExtensionRecording(extensionRecording);
92  }
93 
94 protected:
96 };
97 } // namespace scv
98 } // namespace axi
The TLM2 transaction recorder.
Definition: ace_recorder.h:80
The TLM transaction extensions recorder interface.
TLM2.0 components modeling AHB.
Definition: axi_initiator.h:30
tlm::tlm_fw_transport_if< TYPES > ace_fw_transport_if
alias declaration for the ACE forward interface
Definition: axi_tlm.h:958
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...
Definition: axi_tlm.h:920