From 1fc84b480c30a7ba43f24854c62fbc6ddadc5fcd Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 20 Jul 2018 19:27:27 -0700 Subject: systemc: Implement much of sc_spawn. This doesn't implement reset signals, although those aren't implemented for static processes either yet. Change-Id: I748a7f75b9b91774c91d969bc1ff5b07e1711aa3 Reviewed-on: https://gem5-review.googlesource.com/12044 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/ext/core/sc_spawn.hh | 64 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) (limited to 'src/systemc/ext/core') diff --git a/src/systemc/ext/core/sc_spawn.hh b/src/systemc/ext/core/sc_spawn.hh index 0463dc133..82851542d 100644 --- a/src/systemc/ext/core/sc_spawn.hh +++ b/src/systemc/ext/core/sc_spawn.hh @@ -30,11 +30,51 @@ #ifndef __SYSTEMC_EXT_CORE_SC_SPAWN_HH__ #define __SYSTEMC_EXT_CORE_SC_SPAWN_HH__ +#include + #include "sc_process_handle.hh" namespace sc_core { +class sc_spawn_options; + +} // namespace sc_core + +namespace sc_gem5 +{ + +class Process; + +template +struct ProcessObjFuncWrapper : public ProcessFuncWrapper +{ + T t; + + ProcessObjFuncWrapper(T t) : t(t) {} + + void call() override { t(); } +}; + +template +struct ProcessObjRetFuncWrapper : public ProcessFuncWrapper +{ + T t; + R *r; + + ProcessObjRetFuncWrapper(T t, R *r) : t(t), r(r) {} + + void call() override { *r = t(); } +}; + +Process *spawnWork(ProcessFuncWrapper *func, const char *name, + const ::sc_core::sc_spawn_options *); + +} // namespace sc_gem5 + +namespace sc_core +{ + template class sc_in; template @@ -53,6 +93,10 @@ class sc_port_base; class sc_spawn_options { public: + friend ::sc_gem5::Process *::sc_gem5::spawnWork( + ::sc_gem5::ProcessFuncWrapper *, const char *, + const sc_spawn_options *); + sc_spawn_options(); void spawn_method(); @@ -76,6 +120,15 @@ class sc_spawn_options void async_reset_signal_is(const sc_signal_in_if &, bool); private: + bool _spawnMethod; + bool _dontInitialize; + int _stackSize; + std::vector _events; + std::vector _ports; + std::vector _exports; + std::vector _interfaces; + std::vector _finders; + // Disabled sc_spawn_options(const sc_spawn_options &) {} sc_spawn_options &operator = (const sc_spawn_options &) { return *this; } @@ -88,8 +141,9 @@ sc_process_handle sc_spawn(T object, const char *name_p=nullptr, const sc_spawn_options *opt_p=nullptr) { - sc_spawn_warn_unimpl(__PRETTY_FUNCTION__); - return sc_process_handle(); + auto func = new ::sc_gem5::ProcessObjFuncWrapper(object); + ::sc_gem5::Process *p = spawnWork(func, name_p, opt_p); + return sc_process_handle() = p; } template @@ -97,8 +151,10 @@ sc_process_handle sc_spawn(typename T::result_type *r_p, T object, const char *name_p=nullptr, const sc_spawn_options *opt_p=nullptr) { - sc_spawn_warn_unimpl(__PRETTY_FUNCTION__); - return sc_process_handle(); + auto func = new ::sc_gem5::ProcessObjRetFuncWrapper< + T, typename T::result_type>(object, r_p); + ::sc_gem5::Process *p = spawnWork(func, name_p, opt_p); + return sc_process_handle() = p; } #define sc_bind boost::bind -- cgit v1.2.3