scc 2025.09
SystemC components library
parallel_pe.cpp
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 SC_INCLUDE_DYNAMIC_PROCESSES
18#define SC_INCLUDE_DYNAMIC_PROCESSES
19#endif
20#include "parallel_pe.h"
21
22namespace tlm {
23namespace scc {
24namespace pe {
25using namespace sc_core;
26
27parallel_pe::parallel_pe(sc_core::sc_module_name const& nm)
28: sc_module(nm) {
29 fw_i.bind(*this);
30}
31
33
34void parallel_pe::transport(tlm::tlm_generic_payload& payload, bool lt_transport) {
35 if(!waiting_ids.size()) {
36 auto id = threads.size();
37 threads.resize(threads.size() + 1);
38 thread_unit& tu = threads.back();
39 tu.hndl = sc_core::sc_spawn(
40 [this, id]() -> void {
41 auto& tu = threads[id];
42 while(true) {
43 fw_o->transport(*tu.gp, tu.lt_transport);
44 if(bw_o.get_interface())
45 bw_o->transport(*tu.gp);
46 if(tu.gp->has_mm())
47 tu.gp->release();
48 tu.gp = nullptr;
49 waiting_ids.push_back(id);
50 wait(tu.evt);
51 assert(tu.gp);
52 }
53 },
54 sc_core::sc_gen_unique_name("execute"));
55 tu.gp = &payload;
56 } else {
57 auto& tu = threads[waiting_ids.front()];
58 waiting_ids.pop_front();
59 tu.gp = &payload;
60 tu.lt_transport = lt_transport;
61 tu.evt.notify();
62 }
63 if(payload.has_mm())
64 payload.acquire();
65}
66
67} /* namespace pe */
68} // namespace scc
69} /* namespace tlm */
parallel_pe(sc_core::sc_module_name const &nm)
sc_core::sc_port< intor_fw_b > fw_o
Definition parallel_pe.h:70
sc_port_opt< intor_bw_nb > bw_o
Definition parallel_pe.h:64
sc_core::sc_export< intor_fw_nb > fw_i
Definition parallel_pe.h:58
SCC protocol engines.
Definition intor_if.h:27
SCC TLM utilities.
Definition axis_tlm.h:56
SystemC TLM.
Definition dmi_mgr.h:19