Changeset 4 for sources/src/sc_time.h
- Timestamp:
- Mar 10, 2008, 12:37:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/sc_time.h
r1 r4 13 13 #define __SC_TIME_H__ 14 14 15 #include <iostream>16 15 #include <string> 17 #include "sc_nbdefs.h" 18 #include "internal_ext.h" 16 #include <stdint.h> 19 17 20 18 namespace sc_core { … … 41 39 extern sc_time SC_CURRENT_TIME; 42 40 43 extern uint64 nb_cycles;41 extern uint64_t nb_cycles; 44 42 45 43 inline double sc_simulation_time() // in default time units … … 54 52 { 55 53 friend const sc_time &sc_time_stamp (); 56 long long int time; 54 uint64_t time; 55 enum sc_time_unit unit; 57 56 public: 58 // sc_time (); LRM 2.159 57 sc_time (double val, sc_time_unit tu); 60 58 sc_time (const sc_time& = SC_ZERO_TIME); … … 62 60 sc_time& operator= (const sc_time &); 63 61 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 ();};62 uint64_t value () const { return time;} 63 inline double to_double () const; 64 inline double to_seconds() const; 65 inline operator double () const { return to_double ();} 68 66 const std::string to_string () const; 69 67 }; … … 75 73 } 76 74 75 double 76 sc_time::to_double () const 77 { 78 double fact = 1; 79 switch(unit) { 80 case SC_FS: fact = 1e-6; break; 81 case SC_PS: fact = 1e-3; break; 82 case SC_NS: fact = 1; break; 83 case SC_US: fact = 1e3; break; 84 case SC_MS: fact = 1e6; break; 85 case SC_SEC: fact = 1e9; break; 86 } 87 return (double)time * fact; 88 } 89 90 double 91 sc_time::to_seconds() const 92 { 93 double fact = 1; 94 switch(unit) { 95 case SC_FS: fact = 1e-15; break; 96 case SC_PS: fact = 1e-12; break; 97 case SC_NS: fact = 1e-9; break; 98 case SC_US: fact = 1e-6; break; 99 case SC_MS: fact = 1e-3; break; 100 case SC_SEC: fact = 1; break; 101 } 102 return (double)time * fact; 103 } 104 77 105 } // end of namespace sc_core 78 106 79 using sc_core::sc_simulation_time;80 using sc_core::sc_time;81 using sc_core::sc_time_stamp;82 83 107 #endif /* __SC_TIME_H__ */
Note: See TracChangeset
for help on using the changeset viewer.