source: sources/test_regression/15092005b/system.cpp @ 60

Last change on this file since 60 was 60, checked in by meunier, 7 years ago
  • Intégration des modifications de Clément, qui a intégré la version parallélisée de systemcass faite par Manuel.
File size: 2.1 KB
Line 
1
2
3#include <iostream>
4
5#include "systemc.h"
6#include "test.h"
7
8using namespace std;
9
10
11struct observer : sc_module {
12    sc_in_clk clk;
13
14    sc_in<int> i;
15
16    void f() {}
17
18    SC_HAS_PROCESS(observer);
19    observer(sc_module_name) : clk("clk"), i("i") {
20        SC_METHOD(f);
21        sensitive << clk.pos();
22        dont_initialize();
23    }
24
25};
26
27
28struct generator : sc_module {
29    sc_in_clk clk;
30
31    sc_out<int> o;
32    sc_in<int>  i;
33
34    void f() {
35        int t = (int) (sc_time_stamp ().to_double());
36        o.write(t);
37    }
38
39    SC_HAS_PROCESS(generator);
40    generator(sc_module_name) : clk ("clk"), o("o") {
41        SC_METHOD(f);
42        sensitive << clk.neg();
43        dont_initialize();
44#ifdef SYSTEMCASS_SPECIFIC
45        o(i);
46#endif
47    }
48
49};
50
51
52
53struct top_level : sc_module {
54    sc_in_clk clk;
55
56    sc_out<int> o;
57    sc_in <int> i;
58
59    generator g;
60    observer obs1, obs2;
61
62    SC_HAS_PROCESS(top_level);
63    top_level(sc_module_name) :
64    clk ("clk"),
65    o("o"),
66    i("i"),
67    g("generator"),
68    obs1("observer1"),
69    obs2("observer2") {
70        g.clk(clk);
71        obs1.clk(clk);
72        obs2.clk(clk);
73
74        g.i(i);
75        g.o(o);
76        obs1.i(o);
77        obs2.i(o);
78
79#ifdef SYSTEMCASS_SPECIFIC
80        o  (i);
81        g.o(obs1.i); // <----- wrong declaration that needs detection
82#endif
83    }
84};
85
86
87int sc_main (int argc, char ** argv) {
88    sc_clock       clk("top_clk");
89    sc_signal<int> out("top_out");
90    sc_signal<int> in ("top_in");
91
92    top_level t("top_level");
93
94    // Setup number of threads open-mp to 1 with the macro threads_omp()
95    threads_omp();
96
97    t.clk(clk);
98    t.o(out);
99    t.i(in);
100
101    sc_start(sc_time(0, sc_core::SC_NS));
102
103    /* simulation */
104    int i = 0;
105    while (i++ < 5) {
106        sc_start(sc_time(1, sc_core::SC_NS));
107        ASSERT(out.read() == t.obs1.i.read());
108        ASSERT(out.read() == t.obs2.i.read());
109    }
110
111    cout << "OK" << endl;
112    return 0;
113}
114
115
116/*
117# Local Variables:
118# tab-width: 4;
119# c-basic-offset: 4;
120# c-file-offsets:((innamespace . 0)(inline-open . 0));
121# indent-tabs-mode: nil;
122# End:
123#
124# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
125*/
126
Note: See TracBrowser for help on using the repository browser.