gem5  v20.1.0.0
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 
35 #include "../dt/int/sc_nbdefs.hh"
36 
37 namespace sc_core
38 {
39 
41  SC_FS = 0,
47 };
48 
49 class sc_time
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);
61  sc_time(sc_dt::uint64, 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 
77  sc_time &operator += (const sc_time &);
78  sc_time &operator -= (const sc_time &);
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 
93 const sc_time operator + (const sc_time &, const sc_time &);
94 const sc_time operator - (const sc_time &, const sc_time &);
95 
96 const sc_time operator * (const sc_time &, double);
97 const sc_time operator * (double, const sc_time &);
98 const sc_time operator / (const sc_time &, double);
99 double operator / (const sc_time &, const sc_time &);
100 
101 std::ostream &operator << (std::ostream &, const sc_time &);
102 
103 extern const sc_time SC_ZERO_TIME;
104 
107 const 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_core::sc_time::from_value
static sc_time from_value(sc_dt::uint64)
Definition: sc_time.cc:210
sc_core::sc_time_tuple::_set
bool _set
Definition: sc_time.hh:135
sc_core::sc_time::operator>
bool operator>(const sc_time &) const
Definition: sc_time.cc:164
sc_core::SC_MS
@ SC_MS
Definition: sc_time.hh:45
sc_core::sc_time::from_string
static sc_time from_string(const char *str)
Definition: sc_time.cc:228
sc_core::SC_FS
@ SC_FS
Definition: sc_time.hh:41
sc_core::sc_time::operator=
sc_time & operator=(const sc_time &)
Definition: sc_time.cc:108
sc_core::sc_time_tuple::to_string
std::string to_string() const
Definition: sc_time.cc:447
sc_core
Definition: messages.cc:31
sc_core::sc_time_unit
sc_time_unit
Definition: sc_time.hh:40
sc_core::sc_set_default_time_unit
void sc_set_default_time_unit(double d, sc_time_unit tu)
Definition: sc_time.cc:352
sc_core::SC_US
@ SC_US
Definition: sc_time.hh:44
sc_core::SC_ZERO_TIME
const sc_time SC_ZERO_TIME
Definition: sc_time.cc:290
sc_core::sc_time_tuple::unit
sc_time_unit unit() const
Definition: sc_time.hh:123
sc_core::sc_time::to_double
double to_double() const
Definition: sc_time.cc:121
sc_core::sc_time_tuple::unit_symbol
const char * unit_symbol() const
Definition: sc_time.cc:439
sc_core::sc_time::operator==
bool operator==(const sc_time &) const
Definition: sc_time.cc:140
sc_core::sc_time::operator+=
sc_time & operator+=(const sc_time &)
Definition: sc_time.cc:176
sc_core::sc_max_time
const sc_time & sc_max_time()
Definition: sc_time.cc:345
sc_core::SC_NS
@ SC_NS
Definition: sc_time.hh:43
sc_core::sc_time_tuple::sc_time_tuple
sc_time_tuple()
Definition: sc_time.hh:117
sc_core::sc_time_tuple::to_double
double to_double() const
Definition: sc_time.cc:444
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
sc_core::sc_time_tuple::value
sc_dt::uint64 value() const
Definition: sc_time.cc:436
sc_core::sc_time::operator<
bool operator<(const sc_time &) const
Definition: sc_time.cc:152
sc_core::sc_time::to_seconds
double to_seconds() const
Definition: sc_time.cc:126
sc_core::sc_time
Definition: sc_time.hh:49
sc_core::sc_time::value
sc_dt::uint64 value() const
Definition: sc_time.cc:115
sc_core::operator<<
std::ostream & operator<<(std::ostream &os, sc_status s)
Definition: sc_main.cc:179
sc_core::sc_time::val
uint64_t val
Definition: sc_time.hh:90
sc_core::sc_time_tuple::_value
sc_dt::uint64 _value
Definition: sc_time.hh:133
sc_core::sc_get_default_time_unit
sc_time sc_get_default_time_unit()
Definition: sc_time.cc:390
sc_core::operator-
const sc_time operator-(const sc_time &a, const sc_time &b)
Definition: sc_time.cc:251
sc_core::sc_time::sc_time
sc_time()
Definition: sc_time.cc:64
sc_core::sc_time_tuple::has_value
bool has_value() const
Definition: sc_time.cc:431
sc_core::SC_SEC
@ SC_SEC
Definition: sc_time.hh:46
sc_core::sc_time::operator*=
sc_time & operator*=(double)
Definition: sc_time.cc:190
sc_core::operator/
const sc_time operator/(const sc_time &t, double d)
Definition: sc_time.cc:271
sc_core::SC_PS
@ SC_PS
Definition: sc_time.hh:42
sc_core::sc_get_time_resolution
sc_time sc_get_time_resolution()
Definition: sc_time.cc:339
sc_core::sc_set_time_resolution
void sc_set_time_resolution(double d, sc_time_unit tu)
Definition: sc_time.cc:293
sc_core::sc_time::operator/=
sc_time & operator/=(double)
Definition: sc_time.cc:197
sc_core::sc_time::print
void print(std::ostream &=std::cout) const
Definition: sc_time.cc:204
sc_core::operator*
const sc_time operator*(const sc_time &t, double d)
Definition: sc_time.cc:257
sc_core::operator+
const sc_time operator+(const sc_time &a, const sc_time &b)
Definition: sc_time.cc:245
sc_core::sc_time_tuple
Definition: sc_time.hh:114
sc_core::sc_time::operator>=
bool operator>=(const sc_time &) const
Definition: sc_time.cc:170
sc_core::sc_time::operator!=
bool operator!=(const sc_time &) const
Definition: sc_time.cc:146
sc_core::sc_time::operator-=
sc_time & operator-=(const sc_time &)
Definition: sc_time.cc:183
sc_core::sc_time_tuple::_unit
sc_time_unit _unit
Definition: sc_time.hh:134
sc_core::sc_time::to_string
const std::string to_string() const
Definition: sc_time.cc:132
sc_core::sc_time::operator<=
bool operator<=(const sc_time &) const
Definition: sc_time.cc:158
sc_core::sc_time::from_seconds
static sc_time from_seconds(double)
Definition: sc_time.cc:220

Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17