Deleted Added
sdiff udiff text old ( 12952:94fca7e8120b ) new ( 12953:ddfd5e4643a9 )
full compact
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

--- 19 unchanged lines hidden (view full) ---

28 */
29
30#ifndef __SYSTEMC_CORE_PROCESS_HH__
31#define __SYSTEMC_CORE_PROCESS_HH__
32
33#include <functional>
34
35#include "base/fiber.hh"
36#include "systemc/core/object.hh"
37#include "systemc/ext/core/sc_event.hh"
38#include "systemc/ext/core/sc_module.hh"
39#include "systemc/ext/core/sc_process_handle.hh"
40
41namespace sc_gem5
42{
43
44class Process : public ::sc_core::sc_object
45{
46 public:
47 virtual ::sc_core::sc_curr_proc_kind procKind() const = 0;
48 bool dynamic() const { return _dynamic; }
49 bool isUnwinding() const { return _isUnwinding; }
50 bool terminated() const { return _terminated; }
51
52 void forEachKid(const std::function<void(Process *)> &work);
53
54 bool suspended() const { return _suspended; }
55 bool disabled() const { return _disabled; }

--- 14 unchanged lines hidden (view full) ---

70 void syncResetOff(bool inc_kids);
71
72 void incref() { refCount++; }
73 void decref() { refCount--; }
74
75 const ::sc_core::sc_event &resetEvent() { return _resetEvent; }
76 const ::sc_core::sc_event &terminatedEvent() { return _terminatedEvent; }
77
78 protected:
79 Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
80 ::sc_core::sc_object(name), func(func), _dynamic(_dynamic),
81 _isUnwinding(false), _terminated(false), _suspended(false),
82 _disabled(false), _syncReset(false), refCount(0)
83 {}
84
85 virtual ~Process() { delete func; }
86
87 ::sc_core::sc_event _resetEvent;
88 ::sc_core::sc_event _terminatedEvent;
89
90 ProcessFuncWrapper *func;
91 sc_core::sc_curr_proc_kind _procKind;
92 bool _dynamic;
93 bool _isUnwinding;
94 bool _terminated;
95
96 bool _suspended;
97 bool _disabled;
98
99 bool _syncReset;
100
101 int refCount;
102};
103
104class Method : public Process
105{
106 public:
107 Method(const char *name, ProcessFuncWrapper *func, bool _dynamic=false) :
108 Process(name, func, _dynamic)
109 {}
110
111 const char *kind() const override { return "sc_method_process"; }
112
113 sc_core::sc_curr_proc_kind
114 procKind() const override
115 {
116 return sc_core::SC_METHOD_PROC_;
117 }
118};
119
120class Thread : public Process
121{
122 public:
123 Thread(const char *name, ProcessFuncWrapper *func, bool _dynamic=false) :
124 Process(name, func, _dynamic)
125 {}
126
127 const char *kind() const override { return "sc_thread_process"; }
128
129 void throw_it(ExceptionWrapperBase &exc, bool inc_kids) override;
130
131 sc_core::sc_curr_proc_kind
132 procKind() const override
133 {
134 return sc_core::SC_THREAD_PROC_;
135 }
136};
137
138class CThread : public Thread
139{
140 public:
141 CThread(const char *name, ProcessFuncWrapper *func, bool _dynamic=false) :
142 Thread(name, func, _dynamic)
143 {}
144
145 const char *kind() const override { return "sc_cthread_process"; }
146
147 sc_core::sc_curr_proc_kind
148 procKind() const override
149 {
150 return sc_core::SC_CTHREAD_PROC_;
151 }
152};
153
154} // namespace sc_gem5
155
156#endif //__SYSTEMC_CORE_PROCESS_HH__