source: trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h

Last change on this file was 138, checked in by rosiere, 14 years ago

1) add counters_t type for interface
2) fix in check load in load_store_unit
3) add parameters (but not yet implemented)
4) change environment and add script (distcc_env.sh ...)
5) add warning if an unser change rename flag with l.mtspr instruction
6) ...

  • Property svn:keywords set to Id
File size: 1.4 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#include "Common/include/Systemc.h"
12#include "Common/include/Message.h"
13
14namespace morpheo {
15
16class Time
17{
18#ifdef SYSTEMC
19private : const bool systemc;
20private : double     nb_cycles_begin;
21#endif
22private : timeval    time_begin;
23// private : timeval time_end;
24 
25public  : Time (bool systemc=true)
26#ifdef SYSTEMC
27  :
28  systemc (systemc)
29#endif
30  { 
31#ifdef SYSTEMC
32    nb_cycles_begin = simulation_cycle();
33#endif
34    gettimeofday(&time_begin,NULL);
35  };
36 
37public  : ~Time ()
38  {
39    std::cout << *this;
40  };
41
42public  : friend std::ostream& operator<< (std::ostream& output,
43                                           const Time & x)
44  {
45    timeval time_end;
46   
47    gettimeofday(&time_end,NULL);
48   
49#ifdef SYSTEMC
50    if (x.systemc)
51      {
52        double nb_cycles_end = simulation_cycle();
53        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);
54       
55        output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl;
56      }
57    else
58#endif
59      {
60        double average       = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
61       
62        output << "Timing : " << average << " s" << std::endl;
63      }
64
65    return output;
66  }
67};
68
69}; // end namespace morpheo
70
71#endif
Note: See TracBrowser for help on using the repository browser.