scc  2022.4.0
SystemC components library
initiator.h
1 /*******************************************************************************
2  * Copyright 2019-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_AHB_PIN_INITIATOR_H_
18 #define _BUS_AHB_PIN_INITIATOR_H_
19 
20 #include <tlm/scc/target_mixin.h>
21 #include <tlm>
22 #include <tlm_utils/peq_with_get.h>
23 #include <type_traits>
24 
25 namespace ahb {
26 namespace pin {
27 
28 template <unsigned WIDTH> class initiator : sc_core::sc_module {
29  static constexpr bool is_larger(unsigned x) { return x > 64U; }
30  using data_t = typename std::conditional<is_larger(WIDTH), sc_dt::sc_biguint<WIDTH>, sc_dt::sc_uint<WIDTH>>::type;
31 
32 public:
33  sc_core::sc_in<bool> HCLK_i{"HCLK_i"};
34  sc_core::sc_in<bool> HRESETn_i{"HRESETn_i"};
35  sc_core::sc_out<sc_dt::sc_uint<32>> HADDR_o{"HADDR_o"};
36  sc_core::sc_out<sc_dt::sc_uint<3>> HBURST_o{"HBURST_o"};
37  sc_core::sc_out<bool> HMASTLOCK_o{"HMASTLOCK_o"};
38  sc_core::sc_out<sc_dt::sc_uint<4>> HPROT_o{"HPROT_o"};
39  sc_core::sc_out<sc_dt::sc_uint<3>> HSIZE_o{"HSIZE_o"};
40  sc_core::sc_out<sc_dt::sc_uint<2>> HTRANS_o{"HTRANS_o"};
41  sc_core::sc_out<data_t> HWDATA_o{"HWDATA_o"};
42  sc_core::sc_out<bool> HWRITE_o{"HWRITE_o"};
43  sc_core::sc_in<data_t> HRDATA_i{"HRDATA_i"};
44  sc_core::sc_in<bool> HREADY_i{"HREADY_i"};
45  sc_core::sc_in<bool> HRESP_i{"HRESP_i"};
46 
48 
49  initiator(const sc_core::sc_module_name& nm);
50  virtual ~initiator() = default;
51 
52 private:
53  struct data_phase_desc {
54  tlm::tlm_generic_payload* gp;
55  unsigned size;
56  unsigned length;
57  };
58  void bus_addr_task();
59  void bus_data_task();
60 
61  tlm_utils::peq_with_get<tlm::tlm_generic_payload> inqueue{"inqueue"};
62  tlm_utils::peq_with_get<tlm::tlm_generic_payload> tx_in_flight{"tx_in_flight"};
63 };
64 
65 } // namespace pin
66 } /* namespace ahb */
67 
68 #endif /* _BUS_AHB_PIN_INITIATOR_H_ */
TLM2.0 components modeling AHB.
Definition: ahb_tlm.cpp:19