Changeset 35 for sources/test_regression/25032005
- Timestamp:
- Jun 29, 2009, 6:03:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/25032005/system.cpp
r1 r35 4 4 5 5 using namespace std; 6 6 7 7 struct A : sc_module { 8 9 8 sc_in_clk clk; 9 sc_out<bool> o1; 10 10 11 11 void eval () { 12 12 o1 = (rand()%2) == 0; 13 13 } 14 14 15 16 17 15 SC_CTOR (A) : clk ("clk"), o1("o1") { 16 SC_METHOD(eval); 17 sensitive << clk.neg(); 18 18 #ifdef SYSTEMCASS_SPECIFIC 19 // 19 // s1(); 20 20 #endif 21 21 }; 22 22 }; 23 23 24 24 struct B : sc_module { 25 26 27 28 29 25 sc_in_clk clk; 26 sc_in<bool> i1; 27 sc_in<bool> i2; 28 sc_out<bool> o1; 29 sc_out<bool> o2; 30 30 31 31 void eval1 () { 32 32 o1 = ~i1; 33 34 33 } 34 void eval2 () { 35 35 o2 = ~i2; 36 36 } 37 37 38 39 40 41 38 SC_CTOR (B) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2"), o2 ("o2") { 39 SC_METHOD(eval1); 40 sensitive << clk.neg(); 41 sensitive << i1; 42 42 #ifdef SYSTEMCASS_SPECIFIC 43 43 o1(i1); 44 44 #endif 45 46 47 45 SC_METHOD(eval2); 46 sensitive << clk.neg(); 47 sensitive << i2; 48 48 #ifdef SYSTEMCASS_SPECIFIC 49 49 o2(i2); 50 50 #endif 51 51 }; 52 52 }; 53 53 54 54 struct C : sc_module { 55 56 57 58 55 sc_in_clk clk; 56 sc_in<bool> i1; 57 sc_in<bool> i2; 58 sc_out<bool> o1; 59 59 60 60 void eval1 () { 61 61 o1 = i1 ^ i2; 62 62 } 63 63 64 65 66 67 64 SC_CTOR (C) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2") { 65 SC_METHOD(eval1); 66 sensitive << clk.neg(); 67 sensitive << i1 << i2; 68 68 #ifdef SYSTEMCASS_SPECIFIC 69 70 69 o1(i1); 70 o1(i2); 71 71 #endif 72 72 }; 73 73 }; 74 74 75 75 struct D : sc_module { 76 77 76 sc_in_clk clk; 77 sc_out<bool> o1; 78 78 79 79 void eval () { 80 80 o1 = (rand()%2) == 0; 81 81 } 82 82 83 84 85 83 SC_CTOR (D) : clk ("clk"), o1("o1") { 84 SC_METHOD(eval); 85 sensitive << clk.neg(); 86 86 #ifdef SYSTEMCASS_SPECIFIC 87 // 87 // s1(); 88 88 #endif 89 89 }; 90 90 }; 91 91 92 92 int sc_main (int argc, char *argv[]) 93 93 { 94 95 94 sc_clock signal_clk("my_clock",1, 0.5); 95 sc_signal<bool> s1("s1"),s2("s2"),s3("s3"),s4("s4"),s5("s5"); 96 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 97 A a("a"); 98 B b("b"); 99 C c("c"); 100 D d("d"); 101 102 a.clk (signal_clk); 103 b.clk (signal_clk); 104 c.clk (signal_clk); 105 d.clk (signal_clk); 106 107 a.o1 (s1); 108 b.i1 (s1); 109 110 d.o1 (s2); 111 c.i2 (s2); 112 112 113 114 115 116 117 118 119 120 121 122 113 b.o1 (s3); 114 c.i1 (s3); 115 116 c.o1 (s4); 117 b.i2 (s4); 118 119 b.o2 (s5); 120 121 // Init & run 122 sc_initialize (); 123 123 124 124 if (argc == 1) … … 128 128 } 129 129 130 131 130 chrono_t chrono; 131 chrono.start (); 132 132 133 133 sc_start (atoi(argv[1])); 134 134 135 136 137 138 139 140 141 142 143 135 chrono.stop (); 136 unsigned int t = chrono; 137 cout << "Time elapsed (sec) : " << t << endl; 138 cout << "Cycles done : " << sc_simulation_time () << endl; 139 cout << "Performance : " << sc_simulation_time () / t << endl; 140 printf("\nPress <RETURN> to exit simulation."); 141 char buf_ret[2]; 142 cin.getline(buf_ret,1); 143 return EXIT_SUCCESS; 144 144 }
Note: See TracChangeset
for help on using the changeset viewer.