Changeset 50 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic
- Timestamp:
- Aug 17, 2007, 6:00:56 PM (17 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/SelfTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/SelfTest/include/test.h
r15 r50 12 12 #include <string> 13 13 #include <iostream> 14 #include <sys/time.h> 14 15 15 16 #include "Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/include/RegisterFile_Monolithic.h" … … 24 25 void test (string name, 25 26 morpheo::behavioural::generic::registerfile::registerfile_monolithic::Parameters param); 27 28 class Time 29 { 30 private : timeval time_begin; 31 // private : timeval time_end; 32 33 public : Time () 34 { 35 gettimeofday(&time_begin ,NULL); 36 }; 37 38 public : ~Time () 39 { 40 cout << *this; 41 }; 42 43 public : friend ostream& operator<< (ostream& output_stream, 44 const Time & x) 45 { 46 timeval time_end; 47 48 gettimeofday(&time_end ,NULL); 49 50 uint32_t nb_cycles = static_cast<uint32_t>(sc_simulation_time()); 51 52 double average = static_cast<double>(nb_cycles) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec); 53 54 output_stream << nb_cycles << "\t(" << average << " cycles / seconds )" << endl; 55 56 return output_stream; 57 } 58 }; -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/SelfTest/src/test.cpp
r44 r50 7 7 */ 8 8 9 #define NB_ITERATION 32 10 9 11 #include "Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/SelfTest/include/test.h" 10 12 #include "Common/include/Test.h" … … 31 33 } 32 34 33 RegisterFile_Monolithic * registerfile = new RegisterFile_Monolithic (name.c_str() ,35 RegisterFile_Monolithic * registerfile = new RegisterFile_Monolithic (name.c_str() 34 36 #ifdef STATISTICS 35 morpheo::behavioural::Parameters_Statistics(5,50),37 ,morpheo::behavioural::Parameters_Statistics(5,1000) 36 38 #endif 37 param);39 ,param); 38 40 39 41 #ifdef SYSTEMC … … 79 81 } 80 82 83 cout << "<" << name << "> Start Simulation ............" << endl; 84 Time * _time = new Time(); 85 81 86 /******************************************************** 82 87 * Simulation - Begin 83 88 ********************************************************/ 84 89 85 cout << "<" << name << "> Start Simulation ............" << endl;86 90 // Initialisation 87 91 … … 100 104 NRESET.write(1); 101 105 102 cout << "<" << name << "> Write the RegisterFile (no read)" << endl; 103 104 uint32_t grain = 0; 105 //uint32_t grain = static_cast<uint32_t>(time(NULL)); 106 107 srand(grain); 108 109 Tdata_t data, data_wait; 110 Taddress_t address = 0; 111 112 while (address < param._nb_word) 113 { 114 uint32_t num_port = 0; 115 116 cout << "cycle : " << static_cast<uint32_t> (sc_simulation_time()) << endl; 117 118 while (num_port<param._nb_port_write) 106 107 for (uint32_t nb_iteration=0; nb_iteration < NB_ITERATION; nb_iteration ++) 108 { 109 cout << "<" << name << "> 1) Write the RegisterFile (no read)" << endl; 110 111 // random init 112 uint32_t grain = 0; 113 //uint32_t grain = static_cast<uint32_t>(time(NULL)); 114 115 srand(grain); 116 117 Tdata_t tab [param._nb_word]; 118 119 for (uint32_t i=0; i<param._nb_word; i++) 120 tab[i]= rand()%(1<<(param._size_word-1)); 121 122 Taddress_t address_next = 0; 123 Taddress_t nb_ack = 0; 124 125 while (nb_ack < param._nb_word) 119 126 { 120 data = rand()%(1<<(param._size_word-1)); 121 122 cout << "(" << num_port << ") [" << address << "] <= " << data << endl; 123 WRITE_VAL [num_port] .write(1); 124 WRITE_DATA [num_port] .write(data); 125 WRITE_ADDRESS [num_port] .write(address); 126 127 address ++; 128 num_port ++; 129 // Address can be not a multiple of nb_port_write 130 if (address >= param._nb_word) 131 break; 127 cout << "cycle : " << static_cast<uint32_t> (sc_simulation_time()) << endl; 128 129 for (uint32_t num_port=0; num_port < param._nb_port_write; num_port ++) 130 { 131 if ((address_next < param._nb_word) and 132 (WRITE_VAL [num_port].read() == 0)) 133 { 134 cout << "(" << num_port << ") [" << address_next << "] <= " << tab[address_next] << endl; 135 136 WRITE_VAL [num_port] .write(1); 137 WRITE_DATA [num_port] .write(tab[address_next]); 138 WRITE_ADDRESS [num_port] .write(address_next++); 139 140 // Address can be not a multiple of nb_port_write 141 if (address_next >= param._nb_word) 142 break; 143 } 144 } 145 146 sc_start(1); 147 148 // reset write_val port 149 for (uint32_t num_port=0; num_port < param._nb_port_write; num_port ++) 150 { 151 if ((WRITE_ACK [num_port].read() == 1) and 152 (WRITE_VAL [num_port].read() == 1)) 153 { 154 WRITE_VAL [num_port] .write(0); 155 nb_ack ++; 156 } 157 } 158 159 sc_start(0); 132 160 } 133 134 while (num_port<param._nb_port_write) 161 162 address_next = 0; 163 nb_ack = 0; 164 165 cout << "<" << name << "> 2) Read the RegisterFile (no write)" << endl; 166 167 Tdata_t read_address [param._nb_port_read]; 168 169 while (nb_ack < param._nb_word) 135 170 { 136 WRITE_VAL [num_port] .write(0); 137 num_port ++; 171 cout << "cycle : " << static_cast<uint32_t> (sc_simulation_time()) << endl; 172 173 for (uint32_t num_port=0; num_port < param._nb_port_read; num_port ++) 174 { 175 if ((address_next < param._nb_word) and 176 (READ_VAL [num_port].read() == 0)) 177 { 178 read_address [num_port] = address_next++; 179 180 READ_VAL [num_port].write(1); 181 READ_ADDRESS [num_port].write(read_address [num_port]); 182 183 if (address_next >= param._nb_word) 184 break; 185 } 186 } 187 188 sc_start(1); 189 190 // reset write_val port 191 for (uint32_t num_port=0; num_port < param._nb_port_read; num_port ++) 192 { 193 if ((READ_ACK [num_port].read() == 1) and 194 (READ_VAL [num_port].read() == 1)) 195 { 196 READ_VAL [num_port] .write(0); 197 198 cout << "(" << num_port << ") [" << read_address [num_port] << "] => " << READ_DATA [num_port].read() << endl; 199 200 TEST(Tdata_t,READ_DATA [num_port].read(), tab[read_address [num_port]]); 201 nb_ack ++; 202 } 203 } 204 205 sc_start(0); 138 206 } 139 140 sc_start(1); 141 } 142 cout << "<" << name << "> Read the RegisterFile (no write)" << endl; 143 144 srand(grain); 145 146 for (uint32_t i=0; i<param._nb_port_write; i++) 147 WRITE_VAL [i] .write (0); 148 149 sc_start(1); 150 151 address = 0; 152 while (address < param._nb_word) 153 { 154 uint32_t num_port = 0; 155 156 cout << "cycle : " << static_cast<uint32_t> (sc_simulation_time()) << endl; 157 158 while (num_port<param._nb_port_read) 159 { 160 READ_VAL [num_port] .write(1); 161 READ_ADDRESS [num_port] .write(address); 162 163 sc_start(0); // evaluation 164 165 data_wait = rand()%(1<<(param._size_word-1)); 166 data = READ_DATA [num_port] .read(); 167 168 cout << "(" << num_port << ") [" << address << "] => " << data << endl; 169 170 TEST(Tdata_t,data,data_wait); 171 172 address ++; 173 num_port ++; 174 if (address >= param._nb_word) 175 break; 176 } 177 178 while (num_port<param._nb_port_read) 179 { 180 READ_VAL [num_port] .write(0); 181 num_port ++; 182 } 183 184 sc_start(1); 185 } 186 187 for (uint32_t i=0; i<param._nb_port_read; i++) 188 READ_VAL [i] .write (0); 189 190 sc_start(1); 207 } 191 208 192 209 /******************************************************** … … 194 211 ********************************************************/ 195 212 213 TEST_STR(bool,true,true, "End of Simulation"); 214 delete _time; 196 215 cout << "<" << name << "> ............ Stop Simulation" << endl; 197 216
Note: See TracChangeset
for help on using the changeset viewer.