scc 2025.09
SystemC components library
tlm_signal_conv.h
1/*******************************************************************************
2 * Copyright 2018 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_TLM_SIGNAL_CONV_H_
18#define _TLM_TLM_SIGNAL_CONV_H_
19
20#include "tlm_signal_gp.h"
21#include "tlm_signal_sockets.h"
22#include <deque>
23#include <scc/peq.h>
24
26namespace tlm {
28namespace scc {
29
30template <typename TYPE>
31struct tlm_signal2sc_signal : public sc_core::sc_module, public tlm_signal_fw_transport_if<TYPE, tlm_signal_baseprotocol_types<TYPE>> {
32
33 using protocol_types = tlm_signal_baseprotocol_types<TYPE>;
34 using payload_type = typename protocol_types::tlm_payload_type;
35 using phase_type = typename protocol_types::tlm_phase_type;
36
37 SC_HAS_PROCESS(tlm_signal2sc_signal); // NOLINT
38
40
41 sc_core::sc_out<TYPE> s_o{"s_o"};
42
43 tlm_signal2sc_signal(sc_core::sc_module_name nm)
44 : sc_core::sc_module(nm) {
45 t_i.bind(*this);
46 SC_METHOD(que_cb);
47 sensitive << que.event();
48 }
49
50private:
51 tlm_sync_enum nb_transport_fw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) {
52 que.notify(gp.get_value(), delay);
53 return TLM_COMPLETED;
54 }
55
56 void que_cb() {
57 while(auto oi = que.get_next())
58 s_o.write(oi.get());
59 }
61};
62
63template <typename TYPE>
64struct sc_signal2tlm_signal : public sc_core::sc_module, public tlm_signal_bw_transport_if<TYPE, tlm_signal_baseprotocol_types<TYPE>> {
65
66 using protocol_types = tlm_signal_baseprotocol_types<TYPE>;
67 using payload_type = typename protocol_types::tlm_payload_type;
68 using phase_type = typename protocol_types::tlm_phase_type;
69
70 SC_HAS_PROCESS(sc_signal2tlm_signal); // NOLINT
71
72 sc_core::sc_in<TYPE> s_i{"s_i"};
73
75
76 sc_signal2tlm_signal(sc_core::sc_module_name nm)
77 : sc_core::sc_module(nm) {
78 t_o.bind(*this);
79 SC_METHOD(sig_cb);
80 sensitive << s_i;
81 }
82
83private:
84 tlm_sync_enum nb_transport_bw(payload_type& gp, phase_type& phase, sc_core::sc_time& delay) { return TLM_COMPLETED; }
85
86 void sig_cb() {
87 tlm::tlm_phase phase(tlm::BEGIN_REQ);
88 sc_core::sc_time delay;
89 auto* gp = payload_type::create();
90 gp->acquire();
91 gp->set_value(s_i.read());
92 t_o->nb_transport_fw(*gp, phase, delay);
93 gp->release();
94 }
95};
96} // namespace scc
97} // namespace tlm
98#endif /* _TLM_TLM_SIGNAL_CONV_H_ */
SCC TLM utilities.
Definition axis_tlm.h:56
SystemC TLM.
Definition dmi_mgr.h:19
priority event queue
Definition peq.h:41