Go to the documentation of this file.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 for(int i = 0; i <= 10; i++) {
00025 L_COUT << "A " << i << " (before)" << endl;
00026
00027 boost::function<void ()> fn = boost::bind(&A::f, this, i);
00028 L_COUT << "A " << i << " (bound)" << endl;
00029 L_COUT << "// TEST-EXPECT: A.f(" << i << ")" << endl;
00030 during(10, SC_NS, fn);
00031 L_COUT << "A " << i << " (after)" << endl;
00032 L_COUT << "// TEST-EXPECT: A.g()" << endl;
00033
00034 during(10, SC_NS, bind_this(&A::g));
00035 int z = 0;
00036
00037
00038 during(10, SC_NS, boost::bind(&A::ref, this, boost::ref(z)));
00039 L_COUT << "// TEST-EXPECT: A z = 1" << endl;
00040 L_COUT << "A z = " << z << endl;
00041 }
00042 }
00043
00044 SC_CTOR(A) {
00045 SC_THREAD(compute);
00046 }
00047
00048 void f(int i) {
00049 L_COUT << "A.f(" << i << ")" << endl;
00050 };
00051
00052 void ref(int &i) {
00053 L_COUT << "A.f(" << ++i << ")" << endl;
00054 };
00055
00056 void g() {
00057 L_COUT << name() << ".g()" << endl;
00058 };
00059 };
00060
00061 int sc_main(int argc, char *argv[])
00062 {
00063 (void)argc; (void)argv;
00064 A a("A");
00065 L_COUT << "elaboration done, start simulation" << endl;
00066 {
00067 measure_time t;
00068 sc_start();
00069 }
00070 L_COUT << "Simulation terminated. Terminating threads" << endl;
00071 return 0;
00072 }