Ignore:
Timestamp:
Dec 10, 2008, 7:31:39 PM (16 years ago)
Author:
rosiere
Message:

Almost complete design
with Test and test platform

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h

    r81 r88  
    1 #ifndef TIME_H
    2 #define TIME_H
     1#ifndef Morpheo_Time_h
     2#define Morpheo_Time_h
    33
    44#ifdef SYSTEMC
     
    1010#include <sys/time.h>
    1111
     12namespace morpheo {
     13
    1214class Time
    1315{
    14 private : timeval time_begin;
     16#ifdef SYSTEMC
     17private : double   nb_cycles_begin;
     18#endif
     19private : timeval  time_begin;
    1520// private : timeval time_end;
    1621 
    1722public  : Time ()
    18   {
    19     gettimeofday(&time_begin     ,NULL);
     23  {
     24#ifdef SYSTEMC
     25    nb_cycles_begin = sc_simulation_time();
     26#endif
     27    gettimeofday(&time_begin,NULL);
    2028  };
    21 
     29 
    2230public  : ~Time ()
    2331  {
     
    2533  };
    2634
    27 public  : friend std::ostream& operator<< (std::ostream& output_stream,
     35public  : friend std::ostream& operator<< (std::ostream& output,
    2836                                           const Time & x)
    2937  {
    3038    timeval time_end;
    3139   
    32     gettimeofday(&time_end       ,NULL);
     40    gettimeofday(&time_end,NULL);
    3341   
    34     uint32_t nb_cycles = static_cast<uint32_t>(sc_simulation_time());
    35 
    36     double average = static_cast<double>(nb_cycles) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
     42#ifdef SYSTEMC
     43    double nb_cycles_end = sc_simulation_time();
     44    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);
    3745   
    38     output_stream << "Timing : " << nb_cycles << " cycles \t(" << average << " cycles/s)" << std::endl;
    39 
    40     return output_stream;
     46    output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl;
     47#else
     48    double average       = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
     49   
     50    output << "Timing : " average << " s" << std::endl;
     51#endif
     52   
     53    return output;
    4154  }
    4255};
    4356
     57}; // end namespace morpheo
     58
    4459#endif
Note: See TracChangeset for help on using the changeset viewer.