source: latest/src/sc_time.h @ 1

Last change on this file since 1 was 1, checked in by buchmann, 17 years ago

Initial import from CVS repository

File size: 2.2 KB
Line 
1/*------------------------------------------------------------\
2|                                                             |
3| Tool    :                  systemcass                       |
4|                                                             |
5| File    :                   sc_time.h                       |
6|                                                             |
7| Author  :                 Buchmann Richard                  |
8|                                                             |
9| Date    :                   09_07_2004                      |
10|                                                             |
11\------------------------------------------------------------*/
12#ifndef __SC_TIME_H__
13#define __SC_TIME_H__
14
15#include <iostream>
16#include <string>
17#include "sc_nbdefs.h"
18#include "internal_ext.h"
19
20namespace sc_core {
21
22// ----------------------------------------------------------------------------
23//  ENUM : sc_time_unit
24//
25//  Enumeration of time units.
26// ----------------------------------------------------------------------------
27
28enum sc_time_unit
29{
30    SC_FS = 0,
31    SC_PS,
32    SC_NS,
33    SC_US,
34    SC_MS,
35    SC_SEC
36};
37
38//
39class sc_time;
40extern const sc_time SC_ZERO_TIME;
41extern sc_time SC_CURRENT_TIME;
42
43extern uint64 nb_cycles;
44
45inline double sc_simulation_time()   // in default time units
46{
47  return (double)nb_cycles;
48}
49
50const sc_time& sc_time_stamp ();
51
52//
53class sc_time
54{
55  friend const sc_time &sc_time_stamp ();
56  long long int time;
57public:
58//  sc_time (); LRM 2.1
59  sc_time (double val, sc_time_unit tu);
60  sc_time (const sc_time& = SC_ZERO_TIME);
61 
62  sc_time& operator= (const sc_time &);
63 
64  /*sc_dt::*/uint64 value     () const { return (/*sc_dt::*/uint64) time;}
65  double        to_double () const { return time * 1000;}
66  double        to_seconds() const { return time / (double)1000000000;};
67  operator      double    () const { return to_double ();};
68  const std::string to_string () const;
69};
70
71inline const sc_time& sc_time_stamp ()   // in default time units
72{
73  SC_CURRENT_TIME.time = nb_cycles;
74  return SC_CURRENT_TIME;// = sc_time (nb_cycles, SC_NS);
75}
76
77} // end of namespace sc_core
78
79using sc_core::sc_simulation_time;
80using sc_core::sc_time;
81using sc_core::sc_time_stamp;
82
83#endif /* __SC_TIME_H__ */
Note: See TracBrowser for help on using the repository browser.