From eb3b52b56c7caa20e7814ceab0005d63eeac3f6f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 16 Jul 2018 16:25:32 -0700 Subject: [PATCH] systemc: Implement next_trigger and wait. These set up dynamic sensitivity. Change-Id: I6cf2c2e4f93fe001eb7df8377753d51846b57d32 Reviewed-on: https://gem5-review.googlesource.com/11714 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/sc_module.cc | 93 +++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc index 90139a166..20cc4d288 100644 --- a/src/systemc/core/sc_module.cc +++ b/src/systemc/core/sc_module.cc @@ -421,31 +421,36 @@ sc_module::at_negedge(const sc_signal_in_if &s) void next_trigger() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(nullptr); } void -next_trigger(const sc_event &) +next_trigger(const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e)); } void -next_trigger(const sc_event_or_list &) +next_trigger(const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol)); } void -next_trigger(const sc_event_and_list &) +next_trigger(const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal)); } void -next_trigger(const sc_time &) +next_trigger(const sc_time &t) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t)); } void @@ -455,9 +460,10 @@ next_trigger(double d, sc_time_unit u) } void -next_trigger(const sc_time &, const sc_event &) +next_trigger(const sc_time &t, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e)); } void @@ -467,9 +473,11 @@ next_trigger(double d, sc_time_unit u, const sc_event &e) } void -next_trigger(const sc_time &, const sc_event_or_list &) +next_trigger(const sc_time &t, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic( + new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol)); } void @@ -479,9 +487,11 @@ next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) } void -next_trigger(const sc_time &, const sc_event_and_list &) +next_trigger(const sc_time &t, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic( + new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal)); } void @@ -501,37 +511,48 @@ timed_out() void wait() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(nullptr); + sc_gem5::scheduler.yield(); } void -wait(int) +wait(int n) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + for (int i = 0; i < n; i++) + wait(); } void -wait(const sc_event &) +wait(const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e)); + sc_gem5::scheduler.yield(); } void -wait(const sc_event_or_list &) +wait(const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol)); + sc_gem5::scheduler.yield(); } void -wait(const sc_event_and_list &) +wait(const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal)); + sc_gem5::scheduler.yield(); } void -wait(const sc_time &) +wait(const sc_time &t) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t)); + sc_gem5::scheduler.yield(); } void @@ -541,9 +562,11 @@ wait(double d, sc_time_unit u) } void -wait(const sc_time &, const sc_event &) +wait(const sc_time &t, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e)); + sc_gem5::scheduler.yield(); } void @@ -553,9 +576,12 @@ wait(double d, sc_time_unit u, const sc_event &e) } void -wait(const sc_time &, const sc_event_or_list &) +wait(const sc_time &t, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic( + new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol)); + sc_gem5::scheduler.yield(); } void @@ -565,9 +591,12 @@ wait(double d, sc_time_unit u, const sc_event_or_list &eol) } void -wait(const sc_time &, const sc_event_and_list &) +wait(const sc_time &t, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_gem5::Process *p = sc_gem5::scheduler.current(); + p->setDynamic( + new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal)); + sc_gem5::scheduler.yield(); } void -- 2.30.2