00001
00002
00003
00004
00005
00006
00013 #include <systemc>
00014 #include "during.h"
00015 #include "utils/io-lock.h"
00016
00017 using namespace std;
00018 using namespace sc_core;
00019
00020 SC_MODULE(A), sc_during
00021 {
00022 void compute() {
00023 L_COUT << "A 1: " << sc_time_stamp() << endl;
00024 wait(10, SC_NS);
00025 L_COUT << "A 2: " << sc_time_stamp() << endl;
00026 during(5, SC_NS, boost::bind(&A::f, this));
00027 L_COUT << "// TEST-EXPECT: A 3: 20 ns" << endl;
00028 L_COUT << "A 3: " << sc_time_stamp() << endl;
00029 }
00030
00031 SC_CTOR(A) {
00032 SC_THREAD(compute);
00033 }
00034
00035 void f(void) {
00036 L_COUT << "A.f()" << endl;
00037 extra_time(5, SC_NS);
00038 L_COUT << "A.f() (after extra_time)" << endl;
00039 };
00040 };
00041
00042 SC_MODULE(B), sc_during
00043 {
00044 void compute() {
00045 wait(1, SC_NS);
00046 L_COUT << "B 1: " << sc_time_stamp() << endl;
00047 during(4, SC_NS, boost::bind(&B::f, this));
00048 L_COUT << "// TEST-EXPECT: B 2: 9 ns" << endl;
00049 L_COUT << "B 2: " << sc_time_stamp() << endl;
00050 wait(14, SC_NS);
00051 L_COUT << "B 3: " << sc_time_stamp() << endl;
00052 }
00053
00054 SC_CTOR(B) {
00055 SC_THREAD(compute);
00056 }
00057
00058 void f(void) {
00059 L_COUT << "B.f()" << endl;
00060 for (int i = 0; i < 4; i++) {
00061 extra_time(1, SC_NS);
00062 }
00063 };
00064 };
00065
00066 int sc_main(int argc, char *argv[])
00067 {
00068 (void)argc; (void)argv;
00069 A a("a");
00070 B b("b");
00071 {
00072 measure_time t;
00073 sc_start();
00074 }
00075
00076 return 0;
00077 }