00001
00002
00003
00004
00005
00006
00013 #include <systemc>
00014 #include "during.h"
00015 #include <boost/bind.hpp>
00016 #include "utils/io-lock.h"
00017
00018 using namespace std;
00019 using namespace sc_core;
00020
00021 SC_MODULE(A), sc_during
00022 {
00023 void compute() {
00024 L_COUT << name() << ": before task" << endl;
00025 during(5, SC_MS, bind_this(&A::f));
00026 L_COUT << name() << ": after task" << endl;
00027 }
00028
00029 SC_CTOR(A) {
00030 SC_THREAD(compute);
00031 }
00032
00033 void do_wait() {
00034
00035 L_COUT << "waiting 1 s" << endl;
00036 wait(1, SC_SEC);
00037 L_COUT << "Done waiting (should never happen)" << endl;
00038 }
00039
00040 void f() {
00041 sc_call(boost::bind(&A::do_wait, this));
00042 };
00043 };
00044
00045 int sc_main(int argc, char *argv[])
00046 {
00047 (void)argc; (void)argv;
00048 A a("a");
00049 L_COUT << "elaboration done, start simulation" << endl;
00050 {
00051 measure_time t;
00052 sc_start(30, SC_MS);
00053 }
00054 L_COUT << "Simulation terminated. Terminating threads" << endl;
00055 return 0;
00056 }