SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
sc_signal_access_base.h
Go to the documentation of this file.
1/*
2 © 2017 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14#ifndef SIMICS_SYSTEMC_SC_SIGNAL_ACCESS_BASE_H
15#define SIMICS_SYSTEMC_SC_SIGNAL_ACCESS_BASE_H
16
19
20namespace simics {
21namespace systemc {
22
23#define __SIMICS_SYSTEMC_SIGNAL_DECLARE_TRANSFORM(type) \
24bool attrToValue(const attr_value_t *attr, type *value) const; \
25attr_value_t valueToAttr(type value) const;
26
27#define __SIMICS_SYSTEMC_SIGNAL_COMMA ,
28
29#define __SIMICS_SYSTEMC_SIGNAL_WRITE_BASE(signal, type, obj, \
30 value, set_func) \
31do { \
32 signal *s = dynamic_cast<signal *>(obj); \
33 if (s) { \
34 type v; \
35 if (set_func(value, &v)) { \
36 *s = v; \
37 return true; \
38 } \
39 } \
40} while (0)
41
42#define SIMICS_SYSTEMC_SIGNAL_WRITE(type, obj, value, set_func) \
43__SIMICS_SYSTEMC_SIGNAL_WRITE_BASE(sc_core::sc_signal<type>, \
44 type, obj, value, set_func); \
45__SIMICS_SYSTEMC_SIGNAL_WRITE_BASE(sc_core::sc_signal<type \
46 __SIMICS_SYSTEMC_SIGNAL_COMMA \
47 sc_core::SC_MANY_WRITERS>, \
48 type, obj, value, set_func); \
49__SIMICS_SYSTEMC_SIGNAL_WRITE_BASE(sc_core::sc_out<type>, \
50 type, obj, value, set_func); \
51__SIMICS_SYSTEMC_SIGNAL_WRITE_BASE(sc_core::sc_inout<type>, \
52 type, obj, value, set_func);
53
54#define __SIMICS_SYSTEMC_SIGNAL_READ_BASE(signal, type, obj, \
55 value, get_func) \
56do { \
57 const signal *s = dynamic_cast<const signal *>(obj); \
58 if (s) { \
59 *value = get_func(s->read()); \
60 return true; \
61 } \
62} while (0)
63
64#define SIMICS_SYSTEMC_SIGNAL_READ(type, obj, value, get_func) \
65__SIMICS_SYSTEMC_SIGNAL_READ_BASE(sc_core::sc_signal<type>, \
66 type, obj, value, get_func); \
67__SIMICS_SYSTEMC_SIGNAL_READ_BASE(sc_core::sc_signal<type \
68 __SIMICS_SYSTEMC_SIGNAL_COMMA \
69 sc_core::SC_MANY_WRITERS>, \
70 type, obj, value, get_func); \
71__SIMICS_SYSTEMC_SIGNAL_READ_BASE(sc_core::sc_in<type>, \
72 type, obj, value, get_func); \
73__SIMICS_SYSTEMC_SIGNAL_READ_BASE(sc_core::sc_inout<type>, \
74 type, obj, value, get_func);
75
76class ScSignalAccessBase : public Registrant<ScSignalAccessInterface> {
77 public:
83#ifndef _WIN32
84 __SIMICS_SYSTEMC_SIGNAL_DECLARE_TRANSFORM(long long unsigned int) // NOLINT
85#endif
92};
93
94} // namespace systemc
95} // namespace simics
96
97#endif
Definition: registry.h:86
Definition: sc_signal_access_base.h:76
Definition: adapter.h:79
#define __SIMICS_SYSTEMC_SIGNAL_DECLARE_TRANSFORM(type)
Definition: sc_signal_access_base.h:23