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
|
Rev | Line | |
---|
[55] | 1 | |
---|
[1] | 2 | #include "systemc.h" |
---|
| 3 | |
---|
[55] | 4 | #include "test.h" |
---|
[1] | 5 | |
---|
| 6 | using namespace std; |
---|
| 7 | |
---|
[55] | 8 | struct hard : sc_module { |
---|
| 9 | sc_in_clk clk; |
---|
| 10 | sc_in <int> i1, i2; |
---|
| 11 | sc_out<int> o1, o2; |
---|
[1] | 12 | |
---|
[55] | 13 | void f() { |
---|
| 14 | o1 = i1; |
---|
| 15 | o2 = i2; |
---|
| 16 | } |
---|
[1] | 17 | |
---|
[55] | 18 | SC_HAS_PROCESS(hard); |
---|
| 19 | |
---|
| 20 | hard(sc_module_name) { |
---|
| 21 | SC_METHOD(f); |
---|
| 22 | sensitive << i1 << i2; |
---|
| 23 | dont_initialize(); |
---|
| 24 | |
---|
[1] | 25 | #ifdef SYSTEMCASS_SPECIFIC |
---|
[55] | 26 | o1 (i1); |
---|
| 27 | o2 (i2); |
---|
[1] | 28 | #endif |
---|
[55] | 29 | } |
---|
| 30 | |
---|
[1] | 31 | }; |
---|
| 32 | |
---|
| 33 | |
---|
[55] | 34 | int 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"); |
---|
[1] | 41 | |
---|
[55] | 42 | a.clk(clk1); |
---|
| 43 | b.clk(clk2); |
---|
| 44 | c.clk(clk2); |
---|
[1] | 45 | |
---|
[55] | 46 | a.i1(s[0]); |
---|
[1] | 47 | |
---|
[55] | 48 | a.o1(s[1]); |
---|
| 49 | b.i1(s[1]); |
---|
[1] | 50 | |
---|
[55] | 51 | b.o1(s[2]); |
---|
[1] | 52 | |
---|
[55] | 53 | b.i2(s[3]); |
---|
[1] | 54 | |
---|
[55] | 55 | b.o2(s[4]); |
---|
| 56 | a.i2(s[4]); |
---|
[1] | 57 | |
---|
[55] | 58 | a.o2(s[5]); |
---|
[1] | 59 | |
---|
[55] | 60 | c.i1(s[6]); |
---|
| 61 | c.o1(s[7]); |
---|
| 62 | c.i2(s[8]); |
---|
| 63 | c.o2(s[9]); |
---|
[1] | 64 | |
---|
[55] | 65 | /* Open trace file */ |
---|
| 66 | sc_trace_file *system_trace_file; |
---|
| 67 | system_trace_file = sc_create_vcd_trace_file("trace_file"); |
---|
[1] | 68 | |
---|
[55] | 69 | /* clks waveforms are always useful */ |
---|
| 70 | sc_trace(system_trace_file, clk1, "clk1"); |
---|
| 71 | sc_trace(system_trace_file, clk2, "clk2"); |
---|
[1] | 72 | |
---|
[55] | 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 | } |
---|
[1] | 77 | |
---|
[55] | 78 | /* initilization */ |
---|
| 79 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
[1] | 80 | |
---|
[55] | 81 | s[0] = 1; |
---|
| 82 | s[3] = 1; |
---|
[1] | 83 | |
---|
[55] | 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; |
---|
[1] | 92 | } |
---|
| 93 | |
---|
[55] | 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.