Changeset 55 for sources/test_regression/17022006/system.cpp
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/17022006/system.cpp
r1 r55 1 #include <systemc.h>2 1 3 #define ASSERT(x) \ 4 { errnum++; \ 5 if (!(x)) \ 6 { \ 7 cerr << "ASSERT : " #x "\n"; \ 8 exit (errnum); \ 9 } \ 10 } 2 #include <cstring> 3 4 #include "systemc.h" 5 #include "test.h" 6 11 7 12 8 using namespace std; 13 9 10 14 11 struct test : sc_module { 15 sc_in_clkclk;16 sc_in<int>i1;17 sc_in<bool>i2[4];18 sc_out<int>o1;19 sc_out<char>o2[3];12 sc_in_clk clk; 13 sc_in<int> i1; 14 sc_in<bool> i2[4]; 15 sc_out<int> o1; 16 sc_out<char> o2[3]; 20 17 21 sc_signal<bool>reg1;22 sc_signal<int>reg2;23 sc_signal<int>reg3;24 sc_signal<int>reg4[10];18 sc_signal<bool> reg1; 19 sc_signal<int> reg2; 20 sc_signal<int> reg3; 21 sc_signal<int> reg4[10]; 25 22 26 void trans () 27 { 28 } 23 void trans() {} 29 24 30 void gen () 31 { 32 } 25 void gen() {} 33 26 34 SC_HAS_PROCESS(test); 35 test (sc_module_name n) : sc_module (n), 27 SC_HAS_PROCESS(test); 28 29 test(sc_module_name n) : sc_module(n), 36 30 clk("clk"), 37 31 i1("i1"), … … 39 33 reg1("reg1"), 40 34 reg2("reg2"), 41 reg3("reg3") 42 { 43 SC_METHOD(trans); 44 sensitive << clk.pos(); 45 dont_initialize(); 46 SC_METHOD(gen); 47 sensitive << clk.neg(); 48 dont_initialize(); 35 reg3("reg3") { 36 SC_METHOD(trans); 37 sensitive << clk.pos(); 38 dont_initialize(); 39 40 SC_METHOD(gen); 41 sensitive << clk.neg(); 42 dont_initialize(); 43 49 44 #ifdef NONAME_RENAME 50 char str[100]; 51 for (int i=0; i<3; i++ ) { 52 sprintf(str,"o2_%d", i); 53 o2[i].rename(str); 45 char str[100]; 46 for (int i = 0; i < 3; i++) { 47 sprintf(str, "o2_%d", i); 48 o2[i].rename(str); 49 } 50 for (int i = 0; i < 4; i++) { 51 sprintf(str, "i2_%d", i); 52 i2[i].rename(str); 53 } 54 for (int i = 0; i < 10; i++) { 55 sprintf(str, "reg4_%d", i); 56 reg4[i].rename(str); 57 } 58 #endif 54 59 } 55 for (int i=0; i<4; i++ ) { 56 sprintf(str,"i2_%d", i); 57 i2[i].rename(str); 58 } 59 for (int i=0; i<10; i++ ) { 60 sprintf(str,"reg4_%d", i); 61 reg4[i].rename(str); 62 } 63 #endif 64 }; 60 65 61 }; 66 62 67 int sc_main (int argc, char *argv[])68 {69 int errnum = 0;70 sc_clock signal_clk("my_clock",1, 0.5);71 sc_signal<int> s01("s01");72 sc_signal<bool> s02_0("s02_0"), s02_1("s02_1"), s02_2("s02_2"), s02_3("s02_3");73 sc_signal<int> s03("s03");74 sc_signal<char> s04_0("s04_0"),s04_1("s04_1"),s04_2("s04_2");75 63 76 test test1("test1"); 77 test1.clk (signal_clk); 78 test1.i1 (s01); 79 test1.i2[0] (s02_0); 80 test1.i2[1] (s02_1); 81 test1.i2[2] (s02_2); 82 test1.i2[3] (s02_3); 83 test1.o1 (s03); 84 test1.o2[0] (s04_0); 85 test1.o2[1] (s04_1); 86 test1.o2[2] (s04_2); 64 int sc_main (int argc, char * argv[]) { 65 sc_clock signal_clk("my_clock"); 66 sc_signal<int> s01("s01"); 67 sc_signal<bool> s02_0("s02_0"), s02_1("s02_1"), s02_2("s02_2"), s02_3("s02_3"); 68 sc_signal<int> s03("s03"); 69 sc_signal<char> s04_0("s04_0"), s04_1("s04_1"), s04_2("s04_2"); 87 70 88 // Init & run 89 sc_start (0); 71 test test1("test1"); 72 test1.clk(signal_clk); 73 test1.i1(s01); 74 test1.i2[0](s02_0); 75 test1.i2[1](s02_1); 76 test1.i2[2](s02_2); 77 test1.i2[3](s02_3); 78 test1.o1(s03); 79 test1.o2[0](s04_0); 80 test1.o2[1](s04_1); 81 test1.o2[2](s04_2); 90 82 91 ASSERT(strcmp (test1.o1.name (), "test1.o1") == 0); 92 ASSERT(strcmp (test1.i1.name (), "test1.i1") == 0); 93 ASSERT(strcmp (test1.reg1.name (), "test1.reg1") == 0); 94 ASSERT(strcmp (test1.reg2.basename (), "reg2") == 0); 95 ASSERT(strcmp (test1.reg3.name (), "test1.reg3") == 0); 96 #if defined(NONAME_RENAME) 97 ASSERT(strcmp (test1.o2[1].name (), "test1.o2_1") == 0); 98 ASSERT(strcmp (test1.i2[2].basename (), "i2_2") == 0); 99 ASSERT(strcmp (test1.reg4[1].name (), "test1.reg4_1") == 0); 100 ASSERT(strcmp (test1.reg4[9].basename (), "reg4_9") == 0); 83 // Init & run 84 sc_start(sc_time(0, sc_core::SC_NS)); 85 86 ASSERT(strcmp(test1.o1.name(), "test1.o1") == 0); 87 ASSERT(strcmp(test1.i1.name(), "test1.i1") == 0); 88 ASSERT(strcmp(test1.reg1.name(), "test1.reg1") == 0); 89 ASSERT(strcmp(test1.reg2.basename(), "reg2") == 0); 90 ASSERT(strcmp(test1.reg3.name(), "test1.reg3") == 0); 91 92 #if defined(SYSTEMCASS_SPECIFIC) 93 ASSERT(strcmp(test1.o2[1].name(), "test1.o2_1") == 0); 94 ASSERT(strcmp(test1.i2[2].basename(), "i2_2") == 0); 95 ASSERT(strcmp(test1.reg4[1].name(), "test1.reg4_1") == 0); 96 ASSERT(strcmp(test1.reg4[9].basename(), "reg4_9") == 0); 101 97 #endif 102 return EXIT_SUCCESS; 98 99 cout << "OK" << endl; 100 101 return EXIT_SUCCESS; 103 102 } 104 103 105 104 #undef sc_inout 105 106 /* 107 # Local Variables: 108 # tab-width: 4; 109 # c-basic-offset: 4; 110 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 111 # indent-tabs-mode: nil; 112 # End: 113 # 114 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 115 */ 116
Note: See TracChangeset
for help on using the changeset viewer.