Changeset 55 for sources/test_regression/11062007/system.cpp
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/11062007/system.cpp
r1 r55 1 #include <systemc.h> 1 2 2 #include <signal.h> 3 3 4 #include "systemc.h" 5 6 #include "test.h" 7 4 8 using namespace std; 5 9 10 6 11 struct A : sc_module { 7 sc_in_clkclk;8 sc_out<bool>o1;12 sc_in_clk clk; 13 sc_out<bool> o1; 9 14 10 void eval() {11 o1 = (rand()%2) == 0;12 15 void eval() { 16 o1 = (rand() % 2) == 0; 17 } 13 18 14 SC_CTOR (A) : clk ("clk"), o1("o1") { 15 SC_METHOD(eval); 16 sensitive << clk.neg(); 17 #ifdef SYSTEMCASS_SPECIFIC 18 // s1(); 19 #endif 20 }; 19 SC_CTOR(A) : clk ("clk"), o1("o1") { 20 SC_METHOD(eval); 21 sensitive << clk.neg(); 22 dont_initialize(); 23 } 21 24 }; 22 25 26 23 27 struct B : sc_module { 24 sc_in_clkclk;25 sc_in<bool>i1;26 sc_in<bool>i2;27 sc_out<bool>o1;28 sc_out<bool>o2;28 sc_in_clk clk; 29 sc_in<bool> i1; 30 sc_in<bool> i2; 31 sc_out<bool> o1; 32 sc_out<bool> o2; 29 33 30 void eval1 () { 31 o1 = ~i1; 32 } 33 void eval2 () { 34 o2 = ~i2; 35 } 34 void eval1() { 35 o1 = ~i1; 36 } 36 37 37 SC_CTOR (B) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2"), o2 ("o2") { 38 SC_METHOD(eval1); 39 sensitive << clk.neg(); 40 sensitive << i1; 38 void eval2() { 39 o2 = ~i2; 40 } 41 42 SC_CTOR(B) : clk("clk"), i1("i1"), i2("i2"), o1("o1"), o2("o2") { 43 SC_METHOD(eval1); 44 sensitive << clk.neg(); 45 sensitive << i1; 46 dont_initialize(); 41 47 #ifdef SYSTEMCASS_SPECIFIC 42 48 o1(i1); 43 49 #endif 44 SC_METHOD(eval2); 45 sensitive << clk.neg(); 46 sensitive << i2; 50 SC_METHOD(eval2); 51 sensitive << clk.neg(); 52 sensitive << i2; 53 dont_initialize(); 47 54 #ifdef SYSTEMCASS_SPECIFIC 48 55 o2(i2); 49 56 #endif 50 }; 57 } 51 58 }; 52 59 60 53 61 struct C : sc_module { 54 sc_in_clkclk;55 sc_in<bool>i1;56 sc_in<bool>i2;57 sc_out<bool>o1;62 sc_in_clk clk; 63 sc_in<bool> i1; 64 sc_in<bool> i2; 65 sc_out<bool> o1; 58 66 59 void eval1() {60 o1 = i1 ^ i2;61 67 void eval1() { 68 o1 = i1 ^ i2; 69 } 62 70 63 SC_CTOR (C) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2") { 64 SC_METHOD(eval1); 65 sensitive << clk.neg(); 66 sensitive << i1 << i2; 71 SC_CTOR(C) : clk ("clk"), i1 ("i1"), i2("i2"), o1("o1") { 72 SC_METHOD(eval1); 73 sensitive << clk.neg(); 74 sensitive << i1 << i2; 75 dont_initialize(); 67 76 #ifdef SYSTEMCASS_SPECIFIC 68 69 77 o1(i1); 78 o1(i2); 70 79 #endif 71 }; 80 } 81 72 82 }; 73 83 84 74 85 struct D : sc_module { 75 sc_in_clkclk;76 sc_out<bool>o1;86 sc_in_clk clk; 87 sc_out<bool> o1; 77 88 78 79 o1 = (rand()%2) == 0;80 89 void eval () { 90 o1 = (rand() % 2) == 0; 91 } 81 92 82 SC_CTOR (D) : clk ("clk"), o1("o1") { 83 SC_METHOD(eval); 84 sensitive << clk.neg(); 85 #ifdef SYSTEMCASS_SPECIFIC 86 // s1(); 87 #endif 88 }; 93 SC_CTOR(D) : clk ("clk"), o1("o1") { 94 SC_METHOD(eval); 95 sensitive << clk.neg(); 96 dont_initialize(); 97 } 98 89 99 }; 90 100 91 int sc_main (int argc, char *argv[])92 {93 sc_clock signal_clk("my_clock",1, 0.5);94 sc_signal<bool> s1("s1"),s2("s2"),s3("s3"),s4("s4"),s5("s5");95 101 96 A a("a"); 97 B b("b"); 98 C c("c"); 99 D d("d"); 100 101 a.clk (signal_clk); 102 b.clk (signal_clk); 103 c.clk (signal_clk); 104 d.clk (signal_clk); 105 106 a.o1 (s1); 107 b.i1 (s1); 108 109 d.o1 (s2); 110 c.i2 (s2); 102 int sc_main (int argc, char * argv[]) { 103 sc_clock signal_clk("my_clock",1, 0.5); 104 sc_signal<bool> s1("s1"),s2("s2"),s3("s3"),s4("s4"),s5("s5"); 111 105 112 b.o1 (s3); 113 c.i1 (s3); 114 115 c.o1 (s4); 116 b.i2 (s4); 117 118 b.o2 (s5); 119 120 // Init & run 121 sc_initialize (); 106 A a("a"); 107 B b("b"); 108 C c("c"); 109 D d("d"); 122 110 123 if (argc == 1) 124 { 125 cout << "Usage :\n" << argv[0] << " [#cycles]\n"; 111 a.clk(signal_clk); 112 b.clk(signal_clk); 113 c.clk(signal_clk); 114 d.clk(signal_clk); 115 116 a.o1(s1); 117 b.i1(s1); 118 119 d.o1(s2); 120 c.i2(s2); 121 122 b.o1(s3); 123 c.i1(s3); 124 125 c.o1(s4); 126 b.i2(s4); 127 128 b.o2(s5); 129 130 // Init & run 131 sc_start(sc_time(0, sc_core::SC_NS)); 132 133 if (argc == 1) { 134 cout << "Usage :\n" << argv[0] << " [#cycles]\n"; 135 return EXIT_SUCCESS; 136 } 137 138 sc_start(sc_time(atoi(argv[1]), sc_core::SC_NS)); 139 140 cout << s1.read() << endl; 141 cout << s2.read() << endl; 142 cout << s3.read() << endl; 143 cout << s4.read() << endl; 144 cout << s5.read() << endl; 145 126 146 return EXIT_SUCCESS; 127 147 } 128 148 129 sc_start (atoi(argv[1])); 149 /* 150 # Local Variables: 151 # tab-width: 4; 152 # c-basic-offset: 4; 153 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 154 # indent-tabs-mode: nil; 155 # End: 156 # 157 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 158 */ 130 159 131 cout << s1.read() << endl;132 cout << s2.read() << endl;133 cout << s3.read() << endl;134 cout << s4.read() << endl;135 cout << s5.read() << endl;136 137 return EXIT_SUCCESS;138 }
Note: See TracChangeset
for help on using the changeset viewer.