sc_spawn.hh revision 12879:3d1110d82f87
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#ifndef __SYSTEMC_EXT_CORE_SC_SPAWN_HH__
31#define __SYSTEMC_EXT_CORE_SC_SPAWN_HH__
32
33#include "sc_process_handle.hh"
34
35namespace sc_core
36{
37
38template <class T>
39class sc_in;
40template <class T>
41class sc_inout;
42template <class T>
43class sc_out;
44template <class T>
45class sc_signal_in_if;
46
47class sc_event;
48class sc_event_finder;
49class sc_export_base;
50class sc_interface;
51class sc_port_base;
52
53class sc_spawn_options
54{
55  public:
56    sc_spawn_options();
57
58    void spawn_method();
59    void dont_initialize();
60    void set_stack_size(int);
61
62    void set_sensitivity(const sc_event *);
63    void set_sensitivity(sc_port_base *);
64    void set_sensitivity(sc_export_base *);
65    void set_sensitivity(sc_interface *);
66    void set_sensitivity(sc_event_finder *);
67
68    void reset_signal_is(const sc_in<bool> &, bool);
69    void reset_signal_is(const sc_inout<bool> &, bool);
70    void reset_signal_is(const sc_out<bool> &, bool);
71    void reset_signal_is(const sc_signal_in_if<bool> &, bool);
72
73    void async_reset_signal_is(const sc_in<bool> &, bool);
74    void async_reset_signal_is(const sc_inout<bool> &, bool);
75    void async_reset_signal_is(const sc_out<bool> &, bool);
76    void async_reset_signal_is(const sc_signal_in_if<bool> &, bool);
77
78  private:
79    // Disabled
80    sc_spawn_options(const sc_spawn_options &) {}
81    sc_spawn_options &operator = (const sc_spawn_options &) { return *this; }
82};
83
84void sc_spawn_warn_unimpl(const char *func);
85
86template <typename T>
87sc_process_handle
88sc_spawn(T object, const char *name_p=nullptr,
89         const sc_spawn_options *opt_p=nullptr)
90{
91    sc_spawn_warn_unimpl(__PRETTY_FUNCTION__);
92    return sc_process_handle();
93}
94
95template <typename T>
96sc_process_handle
97sc_spawn(typename T::result_type *r_p, T object, const char *name_p=nullptr,
98         const sc_spawn_options *opt_p=nullptr)
99{
100    sc_spawn_warn_unimpl(__PRETTY_FUNCTION__);
101    return sc_process_handle();
102}
103
104#define sc_bind boost::bind
105#define sc_ref(r) boost::ref(r)
106#define sc_cref(r) boost::cref(r)
107
108#define SC_FORK \
109{ \
110    ::sc_core::sc_process_handle forkees[] = {
111
112#define SC_JOIN \
113    }; /* TODO wait for the forkees. */ \
114}
115
116// Non-standard
117#define SC_CJOIN SC_JOIN
118
119} // namespace sc_core
120
121namespace sc_unnamed
122{
123
124typedef int ImplementationDefined;
125extern ImplementationDefined _1;
126extern ImplementationDefined _2;
127extern ImplementationDefined _3;
128extern ImplementationDefined _4;
129extern ImplementationDefined _5;
130extern ImplementationDefined _6;
131extern ImplementationDefined _7;
132extern ImplementationDefined _8;
133extern ImplementationDefined _9;
134
135} // namespace sc_unnamed
136
137#endif  //__SYSTEMC_EXT_CORE_SC_SPAWN_HH__
138