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

Last change on this file since 113 was 113, checked in by rosiere, 15 years ago

1) Add modelsim simulation systemC
2) Modelsim cosimulation systemC / VHDL is not finish !!!! (cf execute_queue and write_unit)
3) Add multi architecture
5) Add template for comparator, multiplier and divider
6) Change Message
Warning) Various test macro have change, many selftest can't compile

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