source: sources/test_regression/09092005b/system.cpp @ 59

Last change on this file since 59 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: 1.7 KB
Line 
1
2#include "systemc.h"
3
4#include "test.h"
5
6using namespace std;
7
8struct hard : sc_module {
9    sc_in_clk clk;
10    sc_in <int> i1, i2;
11    sc_out<int> o1, o2;
12
13    void f() {
14        o1 = i1;
15        o2 = i2;
16    }
17
18    SC_HAS_PROCESS(hard);
19
20    hard(sc_module_name) {
21        SC_METHOD(f);
22        sensitive << i1 << i2;
23        dont_initialize();
24
25#ifdef SYSTEMCASS_SPECIFIC
26        o1 (i1);
27        o2 (i2);
28#endif
29    }
30
31};
32
33
34int sc_main (int argc, char ** argv) {
35    sc_clock clk1("clk1");
36    sc_clock clk2("clk2", 1, 0.5, 0, false);
37    sc_signal<int> s[10];
38    hard a("a");
39    hard b("b");
40    hard c("c");
41
42    a.clk(clk1);
43    b.clk(clk2);
44    c.clk(clk2);
45
46    a.i1(s[0]);
47
48    a.o1(s[1]);
49    b.i1(s[1]);
50
51    b.o1(s[2]);
52
53    b.i2(s[3]);
54
55    b.o2(s[4]);
56    a.i2(s[4]);
57
58    a.o2(s[5]);
59
60    c.i1(s[6]);
61    c.o1(s[7]);
62    c.i2(s[8]);
63    c.o2(s[9]);
64
65    /* Open trace file */
66    sc_trace_file *system_trace_file;
67    system_trace_file = sc_create_vcd_trace_file("trace_file");
68
69    /* clks waveforms are always useful */
70    sc_trace(system_trace_file, clk1, "clk1");
71    sc_trace(system_trace_file, clk2, "clk2");
72
73    /* others signals */ 
74    for (int i = 0; i < 10; ++i) {
75        sc_trace(system_trace_file, s[i], sc_gen_unique_name ("s"));
76    }
77
78    /* initilization */
79    sc_start(sc_time(0, sc_core::SC_NS));
80
81    s[0] = 1;
82    s[3] = 1;
83
84    sc_start(sc_time(1, sc_core::SC_NS));
85
86    s[0] = 123;
87    s[3] = 321;
88
89    sc_start(sc_time(1, sc_core::SC_NS));
90
91    return 0;
92}
93
94
95/*
96# Local Variables:
97# tab-width: 4;
98# c-basic-offset: 4;
99# c-file-offsets:((innamespace . 0)(inline-open . 0));
100# indent-tabs-mode: nil;
101# End:
102#
103# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
104*/
105
Note: See TracBrowser for help on using the repository browser.