scc 2025.09
SystemC components library
apb_initiator.h
1/*******************************************************************************
2 * Copyright 2020-2022 MINRES Technologies GmbH
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#ifndef _BUS_APB_PE_APB_INITIATOR_H_
18#define _BUS_APB_PE_APB_INITIATOR_H_
19
20#include <scc/ordered_semaphore.h>
21#include <scc/peq.h>
22#include <tlm>
23
25namespace apb {
27namespace pe {
28
29class apb_initiator_b : public sc_core::sc_module, public tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types> {
30public:
31#if SYSTEMC_VERSION < 20250221
32 SC_HAS_PROCESS(apb_initiator_b);
33#endif
34 using payload_type = tlm::tlm_generic_payload;
35 using phase_type = tlm::tlm_phase;
36
37 sc_core::sc_in<bool> clk_i{"clk_i"};
38
39 tlm::tlm_sync_enum nb_transport_bw(payload_type& trans, phase_type& phase, sc_core::sc_time& t) override;
40
41 void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range) override;
42
43 size_t get_transferwith_in_bytes() const { return transfer_width_in_bytes; }
53 void transport(payload_type& trans, bool blocking);
54
55 apb_initiator_b(sc_core::sc_module_name nm, sc_core::sc_port_b<tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types>>& port,
56 size_t transfer_width, bool coherent);
57
58 virtual ~apb_initiator_b();
59
60 apb_initiator_b() = delete;
61
62 apb_initiator_b(apb_initiator_b const&) = delete;
63
64 apb_initiator_b(apb_initiator_b&&) = delete;
65
66 apb_initiator_b& operator=(apb_initiator_b const&) = delete;
67
68 apb_initiator_b& operator=(apb_initiator_b&&) = delete;
69
70protected:
71 const size_t transfer_width_in_bytes;
72
73 sc_core::sc_port_b<tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types>>& socket_fw;
74
76
78
79 sc_core::sc_event any_tx_finished;
80
81 sc_core::sc_time clk_period{10, sc_core::SC_NS};
82
83private:
84 sc_core::sc_clock* clk_if{nullptr};
85 void end_of_elaboration() override { clk_if = dynamic_cast<sc_core::sc_clock*>(clk_i.get_interface()); }
86
87 unsigned m_clock_counter{0};
88 unsigned m_prev_clk_cnt{0};
89};
90
94template <unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1,
95 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
96class apb_initiator : public apb_initiator_b {
97public:
98 using base = apb_initiator_b;
99
100 using payload_type = base::payload_type;
101 using phase_type = base::phase_type;
108 apb_initiator(const sc_core::sc_module_name& nm, tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL>& socket)
109 : apb_initiator_b(nm, socket.get_base_port(), BUSWIDTH, false)
110 , socket(socket) {
111 socket(*this);
112 }
113
114 apb_initiator() = delete;
115
116 apb_initiator(apb_initiator const&) = delete;
117
118 apb_initiator(apb_initiator&&) = delete;
119
120 apb_initiator& operator=(apb_initiator const&) = delete;
121
122 apb_initiator& operator=(apb_initiator&&) = delete;
123
124private:
125 tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL>& socket;
126};
127
128} /* namespace pe */
129} /* namespace apb */
130
131#endif /* _BUS_APB_PE_APB_INITIATOR_H_ */
void transport(payload_type &trans, bool blocking)
The forward transport function. It behaves blocking and is re-entrant.
apb_initiator(const sc_core::sc_module_name &nm, tlm::tlm_initiator_socket< BUSWIDTH, TYPES, N, POL > &socket)
the constructor
protocol engine implementations
TLM2.0 components modeling APB.
Definition apb_tlm.cpp:21
priority event queue
Definition peq.h:41