scc  2022.4.0
SystemC components library
target.h
1 /*******************************************************************************
2  * Copyright 2019-2023 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_TARGET_H_
18 #define _BUS_AHB_PIN_TARGET_H_
19 
20 #include <scc/peq.h>
21 #include <tlm/scc/initiator_mixin.h>
22 #include <tlm>
23 #include <tlm_utils/peq_with_get.h>
24 
26 namespace ahb {
28 namespace pin {
29 
30 template <unsigned DWIDTH, unsigned AWIDTH> class target : sc_core::sc_module {
31  static constexpr bool is_larger(unsigned x) { return x > 64U; }
32  using addr_t = typename std::conditional<is_larger(AWIDTH), sc_dt::sc_biguint<AWIDTH>, sc_dt::sc_uint<AWIDTH>>::type;
33  using data_t = typename std::conditional<is_larger(DWIDTH), sc_dt::sc_biguint<DWIDTH>, sc_dt::sc_uint<DWIDTH>>::type;
34 
35 public:
36  sc_core::sc_in<bool> HCLK_i{"HCLK_i"};
37  sc_core::sc_in<bool> HRESETn_i{"HRESETn_i"};
38  sc_core::sc_in<addr_t> HADDR_i{"HADDR_i"};
39  sc_core::sc_in<sc_dt::sc_uint<3>> HBURST_i{"HBURST_i"};
40  sc_core::sc_in<bool> HMASTLOCK_i{"HMASTLOCK_i"};
41  sc_core::sc_in<sc_dt::sc_uint<4>> HPROT_i{"HPROT_i"};
42  sc_core::sc_in<sc_dt::sc_uint<3>> HSIZE_i{"HSIZE_i"};
43  sc_core::sc_in<sc_dt::sc_uint<2>> HTRANS_i{"HTRANS_i"};
44  sc_core::sc_in<data_t> HWDATA_i{"HWDATA_i"};
45  sc_core::sc_in<bool> HWRITE_i{"HWRITE_i"};
46  sc_core::sc_in<bool> HSEL_i{"HSEL_i"};
47  sc_core::sc_out<data_t> HRDATA_o{"HRDATA_o"};
48  sc_core::sc_out<bool> HREADY_o{"HREADY_o"};
49  sc_core::sc_out<bool> HRESP_o{"HRESP_o"};
50 
52 
53  target(const sc_core::sc_module_name& nm);
54  virtual ~target();
55 
56 private:
57  void bus_addr_task();
58  void bus_data_task();
59  static tlm::tlm_generic_payload* wait4tx(tlm_utils::peq_with_get<tlm::tlm_generic_payload>& que) {
60  tlm::tlm_generic_payload* ret = que.get_next_transaction();
61  while(!ret) {
62  ::sc_core::wait(que.get_event());
63  ret = que.get_next_transaction();
64  }
65  return ret;
66  }
67  sc_core::sc_event end_req_evt;
68  tlm_utils::peq_with_get<tlm::tlm_generic_payload> resp_que{"resp_que"};
69  tlm_utils::peq_with_get<tlm::tlm_generic_payload> tx_in_flight{"tx_in_flight"};
70  bool waiting4end_req{false};
71 };
72 
73 } // namespace pin
74 } /* namespace ahb */
75 
76 #endif /* _BUS_AHB_PIN_TARGET_H_ */
initiator socket mixin
TLM2.0 components modeling AHB.
Definition: ahb_tlm.cpp:19