Last change
on this file since 98 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
|
Line | |
---|
1 | #ifndef Morpheo_Time_h |
---|
2 | #define Morpheo_Time_h |
---|
3 | |
---|
4 | #ifdef SYSTEMC |
---|
5 | #include "systemc.h" |
---|
6 | #endif |
---|
7 | |
---|
8 | #include <string> |
---|
9 | #include <iostream> |
---|
10 | #include <sys/time.h> |
---|
11 | |
---|
12 | namespace morpheo { |
---|
13 | |
---|
14 | class Time |
---|
15 | { |
---|
16 | #ifdef SYSTEMC |
---|
17 | private : const bool systemc; |
---|
18 | private : double nb_cycles_begin; |
---|
19 | #endif |
---|
20 | private : timeval time_begin; |
---|
21 | // private : timeval time_end; |
---|
22 | |
---|
23 | public : Time (bool systemc=true) |
---|
24 | #ifdef SYSTEMC |
---|
25 | : |
---|
26 | systemc (systemc) |
---|
27 | #endif |
---|
28 | { |
---|
29 | #ifdef SYSTEMC |
---|
30 | nb_cycles_begin = sc_simulation_time(); |
---|
31 | #endif |
---|
32 | gettimeofday(&time_begin,NULL); |
---|
33 | }; |
---|
34 | |
---|
35 | public : ~Time () |
---|
36 | { |
---|
37 | std::cout << *this; |
---|
38 | }; |
---|
39 | |
---|
40 | public : friend std::ostream& operator<< (std::ostream& output, |
---|
41 | const Time & x) |
---|
42 | { |
---|
43 | timeval time_end; |
---|
44 | |
---|
45 | gettimeofday(&time_end,NULL); |
---|
46 | |
---|
47 | #ifdef SYSTEMC |
---|
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 |
---|
56 | #endif |
---|
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 | |
---|
63 | return output; |
---|
64 | } |
---|
65 | }; |
---|
66 | |
---|
67 | }; // end namespace morpheo |
---|
68 | |
---|
69 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.