scc 2025.09
SystemC components library
axi_initiator.h
1/*******************************************************************************
2 * Copyright 2021 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#pragma once
18
19#ifndef SC_INCLUDE_DYNAMIC_PROCESSES
20#define SC_INCLUDE_DYNAMIC_PROCESSES
21#endif
22
23#include <axi/axi_tlm.h>
24#include <axi/pe/simple_initiator.h>
25
26#include <systemc>
27#include <tlm>
28#include <tlm_utils/simple_target_socket.h>
29
30namespace axi {
35class axi_initiator_base : public sc_core::sc_module {
36public:
37 sc_core::sc_in<bool> clk_i{"clk_i"};
38#ifdef CWR_SYSTEMC
39 tlm_utils::simple_target_socket<axi_initiator_base, 32> tsck{"tsck"};
40#else
41 tlm_utils::simple_target_socket<axi_initiator_base, scc::LT> tsck{"tsck"};
42#endif
48 tlm::tlm_generic_payload* create_axi_trans(tlm::tlm_generic_payload& p);
49
50 void b_transport(tlm::tlm_generic_payload& trans, sc_core::sc_time& delay);
51
52 axi_initiator_base(const sc_core::sc_module_name& nm, axi::pe::simple_initiator_b& pe, uint32_t width);
53
54 virtual ~axi_initiator_base() {}
55
56 void setTxSetupCb(const std::function<void(tlm::tlm_generic_payload& p)>& setupCb) { setup_cb = setupCb; }
57
58private:
60 uint32_t buswidth{0};
61 unsigned id{0};
62 std::function<void(tlm::tlm_generic_payload& p)> setup_cb;
63};
64
65template <unsigned int BUSWIDTH = 32> class axi_initiator : public axi_initiator_base {
66public:
68
69 axi_initiator(sc_core::sc_module_name nm)
70 : axi_initiator_base(nm, pe, BUSWIDTH) {
71 pe.clk_i(clk_i);
72 };
73
74 virtual ~axi_initiator(){};
75
77};
78
79} // namespace axi
tlm::tlm_generic_payload * create_axi_trans(tlm::tlm_generic_payload &p)
TLM2.0 components modeling AHB.