Last change
on this file since 104 was
97,
checked in by rosiere, 16 years ago
|
1) Update Prediction Table : statistics
2) Size instruction address on 30 bits
3) Change Log File
4) Add debug_level in simulation configuration file
|
-
Property svn:keywords set to
Id
|
File size:
1.3 KB
|
Rev | Line | |
---|
[88] | 1 | #ifndef Morpheo_Time_h |
---|
| 2 | #define Morpheo_Time_h |
---|
[71] | 3 | |
---|
| 4 | #ifdef SYSTEMC |
---|
| 5 | #include "systemc.h" |
---|
| 6 | #endif |
---|
| 7 | |
---|
| 8 | #include <string> |
---|
| 9 | #include <iostream> |
---|
| 10 | #include <sys/time.h> |
---|
| 11 | |
---|
[88] | 12 | namespace morpheo { |
---|
| 13 | |
---|
[71] | 14 | class Time |
---|
| 15 | { |
---|
[88] | 16 | #ifdef SYSTEMC |
---|
[97] | 17 | private : const bool systemc; |
---|
| 18 | private : double nb_cycles_begin; |
---|
[88] | 19 | #endif |
---|
[97] | 20 | private : timeval time_begin; |
---|
[71] | 21 | // private : timeval time_end; |
---|
| 22 | |
---|
[97] | 23 | public : Time (bool systemc=true) |
---|
| 24 | #ifdef SYSTEMC |
---|
| 25 | : |
---|
| 26 | systemc (systemc) |
---|
| 27 | #endif |
---|
[88] | 28 | { |
---|
| 29 | #ifdef SYSTEMC |
---|
| 30 | nb_cycles_begin = sc_simulation_time(); |
---|
| 31 | #endif |
---|
| 32 | gettimeofday(&time_begin,NULL); |
---|
[71] | 33 | }; |
---|
[88] | 34 | |
---|
[71] | 35 | public : ~Time () |
---|
| 36 | { |
---|
| 37 | std::cout << *this; |
---|
| 38 | }; |
---|
| 39 | |
---|
[88] | 40 | public : friend std::ostream& operator<< (std::ostream& output, |
---|
[71] | 41 | const Time & x) |
---|
| 42 | { |
---|
| 43 | timeval time_end; |
---|
| 44 | |
---|
[88] | 45 | gettimeofday(&time_end,NULL); |
---|
[71] | 46 | |
---|
[88] | 47 | #ifdef SYSTEMC |
---|
[97] | 48 | if (x.systemc) |
---|
| 49 | { |
---|
| 50 | double nb_cycles_end = sc_simulation_time(); |
---|
| 51 | double average = static_cast<double>(nb_cycles_end-x.nb_cycles_begin+1) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1); |
---|
| 52 | |
---|
| 53 | output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl; |
---|
| 54 | } |
---|
| 55 | else |
---|
[88] | 56 | #endif |
---|
[97] | 57 | { |
---|
| 58 | double average = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1); |
---|
| 59 | |
---|
| 60 | output << "Timing : " << average << " s" << std::endl; |
---|
| 61 | } |
---|
| 62 | |
---|
[88] | 63 | return output; |
---|
[71] | 64 | } |
---|
| 65 | }; |
---|
| 66 | |
---|
[88] | 67 | }; // end namespace morpheo |
---|
| 68 | |
---|
[71] | 69 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.