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
RevLine 
[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>
[113]11#include "Common/include/Systemc.h"
[71]12
[88]13namespace morpheo {
14
[71]15class Time
16{
[88]17#ifdef SYSTEMC
[97]18private : const bool systemc;
19private : double     nb_cycles_begin;
[88]20#endif
[97]21private : timeval    time_begin;
[71]22// private : timeval time_end;
23 
[97]24public  : Time (bool systemc=true)
25#ifdef SYSTEMC
26  :
27  systemc (systemc)
28#endif
[88]29  { 
30#ifdef SYSTEMC
[113]31    nb_cycles_begin = simulation_cycle();
[88]32#endif
33    gettimeofday(&time_begin,NULL);
[71]34  };
[88]35 
[71]36public  : ~Time ()
37  {
38    std::cout << *this;
39  };
40
[88]41public  : friend std::ostream& operator<< (std::ostream& output,
[71]42                                           const Time & x)
43  {
44    timeval time_end;
45   
[88]46    gettimeofday(&time_end,NULL);
[71]47   
[88]48#ifdef SYSTEMC
[97]49    if (x.systemc)
50      {
[113]51        double nb_cycles_end = simulation_cycle();
[97]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
[88]57#endif
[97]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
[88]64    return output;
[71]65  }
66};
67
[88]68}; // end namespace morpheo
69
[71]70#endif
Note: See TracBrowser for help on using the repository browser.