source: sources/test_regression/17022006/system.cpp @ 55

Last change on this file since 55 was 55, checked in by meunier, 11 years ago

Tried to clean the test_regression directory:

  • Code formatting
  • Supressed warnings
  • Made comprehensible outputs
  • Factorized Makefiles

There's still a lot to do (many tests don't pass for either good or bad reasons)

File size: 2.5 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    test test1("test1");
72    test1.clk(signal_clk);
73    test1.i1(s01);
74    test1.i2[0](s02_0);
75    test1.i2[1](s02_1);
76    test1.i2[2](s02_2);
77    test1.i2[3](s02_3);
78    test1.o1(s03);
79    test1.o2[0](s04_0);
80    test1.o2[1](s04_1);
81    test1.o2[2](s04_2);
82
83    // Init & run
84    sc_start(sc_time(0, sc_core::SC_NS));
85
86    ASSERT(strcmp(test1.o1.name(), "test1.o1") == 0);
87    ASSERT(strcmp(test1.i1.name(), "test1.i1") == 0);
88    ASSERT(strcmp(test1.reg1.name(), "test1.reg1") == 0);
89    ASSERT(strcmp(test1.reg2.basename(), "reg2") == 0);
90    ASSERT(strcmp(test1.reg3.name(), "test1.reg3") == 0);
91
92#if defined(SYSTEMCASS_SPECIFIC)
93    ASSERT(strcmp(test1.o2[1].name(), "test1.o2_1") == 0);
94    ASSERT(strcmp(test1.i2[2].basename(), "i2_2") == 0);
95    ASSERT(strcmp(test1.reg4[1].name(), "test1.reg4_1") == 0);
96    ASSERT(strcmp(test1.reg4[9].basename(), "reg4_9") == 0);
97#endif
98
99    cout << "OK" << endl;
100
101    return EXIT_SUCCESS;
102}
103
104#undef sc_inout
105
106/*
107# Local Variables:
108# tab-width: 4;
109# c-basic-offset: 4;
110# c-file-offsets:((innamespace . 0)(inline-open . 0));
111# indent-tabs-mode: nil;
112# End:
113#
114# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
115*/
116
Note: See TracBrowser for help on using the repository browser.