source: sources/test_regression/17022006/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.6 KB
Line 
1
2#include <cstring>
3
4#include "systemc.h"
5#include "test.h"
6
7
8using namespace std;
9
10
11struct test : sc_module {
12    sc_in_clk clk;
13    sc_in<int> i1;
14    sc_in<bool> i2[4];
15    sc_out<int> o1;
16    sc_out<char> o2[3];
17
18    sc_signal<bool> reg1;
19    sc_signal<int> reg2;
20    sc_signal<int> reg3;
21    sc_signal<int> reg4[10];
22
23    void trans() {}
24
25    void gen() {}
26
27    SC_HAS_PROCESS(test);
28
29    test(sc_module_name n) : sc_module(n),
30    clk("clk"),
31    i1("i1"), 
32    o1("o1"),
33    reg1("reg1"),
34    reg2("reg2"),
35    reg3("reg3") {
36        SC_METHOD(trans);
37        sensitive << clk.pos();
38        dont_initialize();
39
40        SC_METHOD(gen);
41        sensitive << clk.neg();
42        dont_initialize();
43
44#ifdef NONAME_RENAME
45        char str[100];
46        for (int i = 0; i < 3; i++) {
47            sprintf(str, "o2_%d", i);
48            o2[i].rename(str);
49        }
50        for (int i = 0; i < 4; i++) {
51            sprintf(str, "i2_%d", i);
52            i2[i].rename(str);
53        }
54        for (int i = 0; i < 10; i++) {
55            sprintf(str, "reg4_%d", i);
56            reg4[i].rename(str);
57        }
58#endif
59    }
60
61};
62
63
64int sc_main (int argc, char * argv[]) {
65    sc_clock signal_clk("my_clock");
66    sc_signal<int> s01("s01");
67    sc_signal<bool> s02_0("s02_0"), s02_1("s02_1"), s02_2("s02_2"), s02_3("s02_3");
68    sc_signal<int> s03("s03");
69    sc_signal<char> s04_0("s04_0"), s04_1("s04_1"), s04_2("s04_2");
70
71    // Setup number of threads open-mp to 1 with the macro threads_omp()
72    threads_omp();
73
74    test test1("test1");
75    test1.clk(signal_clk);
76    test1.i1(s01);
77    test1.i2[0](s02_0);
78    test1.i2[1](s02_1);
79    test1.i2[2](s02_2);
80    test1.i2[3](s02_3);
81    test1.o1(s03);
82    test1.o2[0](s04_0);
83    test1.o2[1](s04_1);
84    test1.o2[2](s04_2);
85
86    // Init & run
87    sc_start(sc_time(0, sc_core::SC_NS));
88
89    ASSERT(strcmp(test1.o1.name(), "test1.o1") == 0);
90    ASSERT(strcmp(test1.i1.name(), "test1.i1") == 0);
91    ASSERT(strcmp(test1.reg1.name(), "test1.reg1") == 0);
92    ASSERT(strcmp(test1.reg2.basename(), "reg2") == 0);
93    ASSERT(strcmp(test1.reg3.name(), "test1.reg3") == 0);
94
95#if defined(SYSTEMCASS_SPECIFIC)
96    ASSERT(strcmp(test1.o2[1].name(), "test1.o2_1") == 0);
97    ASSERT(strcmp(test1.i2[2].basename(), "i2_2") == 0);
98    ASSERT(strcmp(test1.reg4[1].name(), "test1.reg4_1") == 0);
99    ASSERT(strcmp(test1.reg4[9].basename(), "reg4_9") == 0);
100#endif
101
102    cout << "OK" << endl;
103
104    return EXIT_SUCCESS;
105}
106
107#undef sc_inout
108
109/*
110# Local Variables:
111# tab-width: 4;
112# c-basic-offset: 4;
113# c-file-offsets:((innamespace . 0)(inline-open . 0));
114# indent-tabs-mode: nil;
115# End:
116#
117# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
118*/
119
Note: See TracBrowser for help on using the repository browser.