gem5 v24.0.0.0
Loading...
Searching...
No Matches
sc_time.hh
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef __SYSTEMC_EXT_CORE_SC_TIME_HH__
29#define __SYSTEMC_EXT_CORE_SC_TIME_HH__
30
31#include <stdint.h>
32
33#include <iostream>
34
36
37namespace sc_core
38{
39
41 SC_FS = 0,
46 SC_SEC
47};
48
50{
51 public:
52 sc_time();
53 sc_time(double, sc_time_unit);
54 sc_time(const sc_time &);
55
56 // Nonstandard
57 sc_time(double, const char *);
58
59 // Deprecated
60 sc_time(double, bool);
62
63 sc_time &operator = (const sc_time &);
64
65 sc_dt::uint64 value() const;
66 double to_double() const;
67 double to_seconds() const;
68 const std::string to_string() const;
69
70 bool operator == (const sc_time &) const;
71 bool operator != (const sc_time &) const;
72 bool operator < (const sc_time &) const;
73 bool operator <= (const sc_time &) const;
74 bool operator > (const sc_time &) const;
75 bool operator >= (const sc_time &) const;
76
79 sc_time &operator *= (double);
80 sc_time &operator /= (double);
81
82 void print(std::ostream & =std::cout) const;
83
84 // Deprecated
86 static sc_time from_seconds(double);
87 static sc_time from_string(const char *str);
88
89 private:
90 uint64_t val;
91};
92
93const sc_time operator + (const sc_time &, const sc_time &);
94const sc_time operator - (const sc_time &, const sc_time &);
95
96const sc_time operator * (const sc_time &, double);
97const sc_time operator * (double, const sc_time &);
98const sc_time operator / (const sc_time &, double);
99double operator / (const sc_time &, const sc_time &);
100
101std::ostream &operator << (std::ostream &, const sc_time &);
102
103extern const sc_time SC_ZERO_TIME;
104
107const sc_time &sc_max_time();
108
109// Deprecated
112
113// Nonstandard
115{
116 public:
117 sc_time_tuple() : _value(), _unit(SC_SEC), _set(false) {}
118 sc_time_tuple(const sc_time &);
119
120 bool has_value() const;
121 sc_dt::uint64 value() const;
122 // Normalized unit.
123 sc_time_unit unit() const { return _unit; }
124 // Normalized unit symbol.
125 const char *unit_symbol() const;
126
127 operator sc_time() const { return sc_time(to_double(), _unit); }
128
129 double to_double() const; // Relative to the normalized unit.
130 std::string to_string() const;
131
132 private:
135 bool _set;
136};
137
138} // namespace sc_core
139
140#endif //__SYSTEMC_EXT_CORE_SC_TIME_HH__
sc_dt::uint64 value() const
Definition sc_time.cc:436
const char * unit_symbol() const
Definition sc_time.cc:439
sc_time_unit _unit
Definition sc_time.hh:134
std::string to_string() const
Definition sc_time.cc:447
bool has_value() const
Definition sc_time.cc:431
sc_dt::uint64 _value
Definition sc_time.hh:133
sc_time_unit unit() const
Definition sc_time.hh:123
double to_double() const
Definition sc_time.cc:444
bool operator!=(const sc_time &) const
Definition sc_time.cc:146
static sc_time from_seconds(double)
Definition sc_time.cc:220
sc_time & operator-=(const sc_time &)
Definition sc_time.cc:183
bool operator>=(const sc_time &) const
Definition sc_time.cc:170
bool operator==(const sc_time &) const
Definition sc_time.cc:140
void print(std::ostream &=std::cout) const
Definition sc_time.cc:204
bool operator>(const sc_time &) const
Definition sc_time.cc:164
static sc_time from_value(sc_dt::uint64)
Definition sc_time.cc:210
static sc_time from_string(const char *str)
Definition sc_time.cc:228
double to_double() const
Definition sc_time.cc:121
sc_time & operator+=(const sc_time &)
Definition sc_time.cc:176
double to_seconds() const
Definition sc_time.cc:126
const std::string to_string() const
Definition sc_time.cc:132
sc_time & operator=(const sc_time &)
Definition sc_time.cc:108
uint64_t val
Definition sc_time.hh:90
sc_time & operator/=(double)
Definition sc_time.cc:197
bool operator<(const sc_time &) const
Definition sc_time.cc:152
bool operator<=(const sc_time &) const
Definition sc_time.cc:158
sc_time & operator*=(double)
Definition sc_time.cc:190
sc_dt::uint64 value() const
Definition sc_time.cc:115
const sc_time operator/(const sc_time &t, double d)
Definition sc_time.cc:271
void sc_set_time_resolution(double d, sc_time_unit tu)
Definition sc_time.cc:293
const sc_time SC_ZERO_TIME
Definition sc_time.cc:290
const sc_time operator+(const sc_time &a, const sc_time &b)
Definition sc_time.cc:245
void sc_set_default_time_unit(double d, sc_time_unit tu)
Definition sc_time.cc:352
const sc_time operator*(const sc_time &t, double d)
Definition sc_time.cc:257
sc_time_unit
Definition sc_time.hh:40
@ SC_MS
Definition sc_time.hh:45
@ SC_PS
Definition sc_time.hh:42
@ SC_US
Definition sc_time.hh:44
@ SC_NS
Definition sc_time.hh:43
std::ostream & operator<<(std::ostream &os, sc_status s)
Definition sc_main.cc:178
sc_time sc_get_default_time_unit()
Definition sc_time.cc:390
sc_time sc_get_time_resolution()
Definition sc_time.cc:339
const sc_time operator-(const sc_time &a, const sc_time &b)
Definition sc_time.cc:251
const sc_time & sc_max_time()
Definition sc_time.cc:345
uint64_t uint64
Definition sc_nbdefs.hh:172

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0