Changeset 55 for sources/test_regression/14092005/system.cpp
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/14092005/system.cpp
r1 r55 1 // Le test échoue 2 // Par ailleurs, la référence est la trace de systemcass ; je pense qu'il faudrait changer ça 3 1 4 #include "systemc.h" 2 5 3 #define ASSERT(x) \ 4 { errnum++; \ 5 if (!(x)) \ 6 { \ 7 cerr << "ASSERT : " #x "\n"; \ 8 exit (errnum); \ 9 } \ 10 } 6 #include "test.h" 7 11 8 12 9 using namespace std; 13 10 14 struct hard : sc_module 15 { 16 sc_in_clk clk; 17 sc_in<bool> resetn; 18 sc_in <int> i1; 19 sc_out<int> o1; 20 sc_signal <int> r1; 11 struct hard : sc_module { 12 sc_in_clk clk; 13 sc_in<bool> resetn; 14 sc_in <int> i1; 15 sc_out<int> o1; 16 sc_signal <int> r1; 21 17 22 void fg () 23 { 24 o1 = r1; 25 } 18 void fg() { 19 o1 = r1; 20 } 26 21 27 void ft () 28 { 29 if (resetn.read()) 30 r1 = i1; 31 else 32 r1 = 0x0; 33 } 22 void ft() { 23 if (resetn.read()) { 24 r1 = i1; 25 } 26 else { 27 r1 = 0x0; 28 } 29 } 34 30 35 SC_HAS_PROCESS(hard); 36 hard(sc_module_name) 37 { 38 SC_METHOD(ft); 39 dont_initialize(); 40 sensitive << clk.pos(); 41 SC_METHOD(fg); 42 dont_initialize(); 43 sensitive << clk.neg(); 44 #ifdef SYSTEMCASS_SPECIFIC 45 #endif 46 } 31 SC_HAS_PROCESS(hard); 32 33 hard(sc_module_name) { 34 SC_METHOD(ft); 35 sensitive << clk.pos(); 36 dont_initialize(); 37 38 SC_METHOD(fg); 39 sensitive << clk.neg(); 40 dont_initialize(); 41 } 47 42 }; 48 43 49 int50 sc_main (int argc, char ** argv)51 {52 int errnum = 0;53 sc_clock clk1("clk1", 1, 0.5,0,true);54 sc_signal<bool> resetn;55 sc_signal<int> s[10];56 hard a("a");57 44 58 a.clk (clk1); 59 a.resetn (resetn); 45 int sc_main (int argc, char ** argv) { 46 sc_clock clk1("clk1", 1, 0.5, 0, true); 47 sc_signal<bool> resetn; 48 sc_signal<int> s[10]; 49 hard a("a"); 60 50 61 a.i1 (s[0]);62 a.o1 (s[1]);51 a.clk (clk1); 52 a.resetn(resetn); 63 53 64 /* Open trace file */ 65 sc_trace_file *system_trace_file; 66 system_trace_file = sc_create_vcd_trace_file ("trace_file"); 67 68 /* clks waveforms are always useful */ 69 sc_trace(system_trace_file, resetn, "resetn"); 70 sc_trace(system_trace_file, s[0], "i1"); 71 sc_trace(system_trace_file, s[1], "o1"); 72 sc_trace(system_trace_file, clk1, "clk1"); 54 a.i1(s[0]); 55 a.o1(s[1]); 73 56 74 /* initilization */ 75 sc_initialize (); 57 /* Open trace file */ 58 sc_trace_file *system_trace_file; 59 system_trace_file = sc_create_vcd_trace_file ("trace_file"); 76 60 77 s[0] = 0; 78 resetn = 0; 61 /* clks waveforms are always useful */ 62 sc_trace(system_trace_file, resetn, "resetn"); 63 sc_trace(system_trace_file, s[0], "i1"); 64 sc_trace(system_trace_file, s[1], "o1"); 65 sc_trace(system_trace_file, clk1, "clk1"); 79 66 80 sc_start (5); 67 /* initilization */ 68 sc_start(sc_time(0, sc_core::SC_NS)); 81 69 82 s[0] = 0x7B;83 resetn = 1;70 s[0] = 0; 71 resetn = 0; 84 72 85 sc_start (1);73 sc_start(sc_time(5, sc_core::SC_NS)); 86 74 87 for (int i = 0; i < 10; i++) 88 { 89 s[0] = i; 90 sc_start (1); 91 // cout << i << " " << s[1].read() << " " << a.o1.read() << endl; 92 //ASSERT(((i > 0) && (s[1].read() == i - 1)) || ((i == 0) && (s[1].read() == 0x7B))); 93 ASSERT(s[1].read() == i); 94 } 75 s[0] = 0x7B; 76 resetn = 1; 95 77 96 cout << "Test OK\n"; 97 return 0; 78 sc_start(sc_time(1, sc_core::SC_NS)); 79 80 for (int i = 0; i < 10; i++) { 81 s[0] = i; 82 sc_start(sc_time(1, sc_core::SC_NS)); 83 ASSERT(s[1].read() == i); 84 } 85 86 return 0; 98 87 } 99 88 89 90 /* 91 # Local Variables: 92 # tab-width: 4; 93 # c-basic-offset: 4; 94 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 95 # indent-tabs-mode: nil; 96 # End: 97 # 98 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 99 */ 100
Note: See TracChangeset
for help on using the changeset viewer.