Changeset 4 for sources/src/sc_time.cc
- Timestamp:
- Mar 10, 2008, 12:37:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/sc_time.cc
r1 r4 39 39 #include <sys/time.h> 40 40 #include <string> 41 42 using namespace std; 41 #include <sstream> 43 42 44 43 namespace sc_core { 45 44 46 uint64 nb_cycles = 0; 45 static const char *const unit_repr_string[6] = 46 { 47 "FS", "PS", "NS", "US", "MS", "SEC" 48 }; 49 50 uint64_t nb_cycles = 0; 47 51 48 52 const sc_time SC_ZERO_TIME(0,SC_NS); … … 51 55 sc_time::sc_time (const sc_time &t) 52 56 { 53 time = t.time;57 *this = t; 54 58 } 55 59 56 60 sc_time::sc_time (double val, sc_time_unit tu) 57 61 { 58 time = (long long int) val; 62 time = (uint64_t) val; 63 unit = tu; 59 64 } 60 65 … … 64 69 { 65 70 time = t.time; 71 unit = t.unit; 72 return *this; 66 73 } 67 74 68 75 69 const st ring76 const std::string 70 77 sc_time::to_string () const 71 78 { 72 char res[32]; 73 const char* unit; 74 if (time == 0) 75 { 76 unit = "s"; 77 } else 78 unit = "ns"; 79 sprintf (res, "%lld %s", time, unit); 80 return (string)res; 79 std::ostringstream o; 80 o << time << ' ' << unit_repr_string[unit]; 81 return o.str(); 81 82 } 82 83
Note: See TracChangeset
for help on using the changeset viewer.