scc  2022.4.0
SystemC components library
parallel_pe.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 _TLM_SCC_PE_PARALLEL_PE_H_
18 #define _TLM_SCC_PE_PARALLEL_PE_H_
19 
20 #include "intor_if.h"
21 #include <deque>
22 #include <tlm>
24 namespace tlm {
26 namespace scc {
28 namespace pe {
29 
30 class parallel_pe : public sc_core::sc_module, public intor_fw_nb {
31  template <class IF> using sc_port_opt = sc_core::sc_port<IF, 1, sc_core::SC_ZERO_OR_MORE_BOUND>;
32 
33  struct thread_unit {
34  sc_core::sc_event evt;
35  tlm::tlm_generic_payload* gp{nullptr};
36  bool lt_transport{false};
37  sc_core::sc_process_handle hndl{};
38  thread_unit(const thread_unit& o)
39  : gp(o.gp)
40  , lt_transport(o.lt_transport)
41  , hndl(o.hndl) {}
42  thread_unit() = default;
43  };
44 
45 public:
46  sc_core::sc_export<intor_fw_nb> fw_i{"fw_i"};
47 
48  sc_port_opt<intor_bw_nb> bw_o{"bw_o"};
49 
50  sc_core::sc_port<intor_fw_b> fw_o{"fw_o"};
51 
52  parallel_pe(sc_core::sc_module_name const& nm);
53 
54  virtual ~parallel_pe();
55 
56 private:
57  void transport(tlm::tlm_generic_payload& payload, bool lt_transport = false) override;
58 
59  void snoop_resp(tlm::tlm_generic_payload& payload, bool sync) override { fw_o->snoop_resp(payload, sync); }
60 
61  std::deque<unsigned> waiting_ids;
62  std::vector<thread_unit> threads;
63 };
64 
65 } /* namespace pe */
66 } // namespace scc
67 } /* namespace tlm */
68 
69 #endif /* _TLM_SCC_PE_PARALLEL_PE_H_ */
SCC SystemC utilities.
SystemC TLM.