gem5  v21.2.0.0
sc_clock.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_CHANNEL_SC_CLOCK_HH__
29 #define __SYSTEMC_EXT_CHANNEL_SC_CLOCK_HH__
30 
31 #include "../core/sc_time.hh"
32 #include "sc_signal.hh"
33 
34 namespace sc_gem5
35 {
36 
37 class ClockTick;
38 
39 } // namespace sc_gem5
40 
41 namespace sc_core
42 {
43 
44 template <class T>
45 class sc_in;
46 
47 class sc_time;
48 
49 class sc_clock : public sc_signal<bool>
50 {
51  public:
52  sc_clock();
53  explicit sc_clock(const char *name);
54 
55  sc_clock(const char *name, const sc_time &period,
56  double duty_cycle=0.5, const sc_time &start_time=SC_ZERO_TIME,
57  bool posedge_first=true);
58 
59  sc_clock(const char *name, double period_v, sc_time_unit period_tu,
60  double duty_cycle=0.5);
61 
62  sc_clock(const char *name, double period_v, sc_time_unit period_tu,
63  double duty_cycle, double start_time_v,
64  sc_time_unit start_time_tu, bool posedge_first=true);
65 
66  // Deprecated.
67  sc_clock(const char *name, double period, double duty_cycle=0.5,
68  double start_time=0.0, bool posedge_first=true);
69 
70  virtual ~sc_clock();
71 
72  virtual void write(const bool &);
73 
74  const sc_time &period() const;
75  double duty_cycle() const;
76  const sc_time &start_time() const;
77  bool posedge_first() const;
78 
79  // Nonstandard
80  static const sc_time &time_stamp();
81 
82  virtual const char *kind() const { return "sc_clock"; }
83 
84  protected:
85  virtual void before_end_of_elaboration();
86 
87  private:
88  friend class ::sc_gem5::ClockTick;
89 
90  // Disabled
91  sc_clock(const sc_clock &) : sc_interface(), sc_signal<bool>() {}
92  sc_clock &operator = (const sc_clock &) { return *this; }
93 
95  double _dutyCycle;
98 
101 
102  void
104  {
105  m_new_val = true;
106  request_update();
107  }
108  void
110  {
111  m_new_val = false;
112  request_update();
113  }
114 };
115 
117 
118 // Deprecated
121 
122 } // namespace sc_core
123 
124 #endif //__SYSTEMC_EXT_CHANNEL_SC_CLOCK_HH__
sc_core::sc_in< bool >
Definition: sc_in.hh:165
sc_core::sc_clock::_startTime
sc_time _startTime
Definition: sc_clock.hh:96
sc_core::sc_inout_clk
sc_inout< bool > sc_inout_clk
Definition: sc_clock.hh:119
sc_core::sc_clock::_dutyCycle
double _dutyCycle
Definition: sc_clock.hh:95
sc_core::sc_clock::duty_cycle
double duty_cycle() const
Definition: sc_clock.cc:170
sc_core::sc_clock
Definition: sc_clock.hh:49
sc_core::sc_clock::kind
virtual const char * kind() const
Definition: sc_clock.hh:82
sc_core::sc_clock::time_stamp
static const sc_time & time_stamp()
Definition: sc_clock.cc:175
sc_core::sc_clock::_posedgeFirst
bool _posedgeFirst
Definition: sc_clock.hh:97
sc_core
Definition: messages.cc:31
sc_core::sc_time_unit
sc_time_unit
Definition: sc_time.hh:40
sc_core::sc_interface
Definition: sc_interface.hh:37
sc_signal.hh
sc_core::SC_ZERO_TIME
const sc_time SC_ZERO_TIME
Definition: sc_time.cc:290
sc_core::sc_clock::operator=
sc_clock & operator=(const sc_clock &)
Definition: sc_clock.hh:92
sc_core::sc_signal
Definition: sc_signal.hh:272
sc_core::sc_clock::start_time
const sc_time & start_time() const
Definition: sc_clock.cc:171
sc_core::sc_clock::sc_clock
sc_clock()
Definition: sc_clock.cc:93
sc_core::sc_prim_channel::request_update
void request_update()
Definition: sc_prim.cc:70
sc_core::sc_clock::tickUp
void tickUp()
Definition: sc_clock.hh:103
sc_core::sc_clock::period
const sc_time & period() const
Definition: sc_clock.cc:169
sc_core::sc_clock::_period
sc_time _period
Definition: sc_clock.hh:94
sc_gem5::ClockTick
Definition: sc_clock.cc:44
sc_core::sc_clock::before_end_of_elaboration
virtual void before_end_of_elaboration()
Definition: sc_clock.cc:181
sc_core::sc_time
Definition: sc_time.hh:49
sc_core::sc_clock::sc_clock
sc_clock(const sc_clock &)
Definition: sc_clock.hh:91
sc_core::sc_in_clk
sc_in< bool > sc_in_clk
Definition: sc_clock.hh:116
sc_gem5::ScSignalBaseT< bool, SC_ONE_WRITER >::m_new_val
bool m_new_val
Definition: sc_signal.hh:236
sc_core::sc_out_clk
sc_out< bool > sc_out_clk
Definition: sc_clock.hh:120
sc_core::sc_in
Definition: sc_clock.hh:45
sc_core::sc_clock::tickDown
void tickDown()
Definition: sc_clock.hh:109
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
sc_core::sc_clock::~sc_clock
virtual ~sc_clock()
Definition: sc_clock.cc:153
sc_core::sc_out< bool >
sc_core::sc_inout< bool >
Definition: sc_inout.hh:193
sc_gem5
Definition: sc_clock.cc:41
sc_core::sc_clock::write
virtual void write(const bool &)
Definition: sc_clock.cc:164
sc_core::sc_clock::posedge_first
bool posedge_first() const
Definition: sc_clock.cc:172
sc_core::sc_clock::_gem5UpEdge
::sc_gem5::ClockTick * _gem5UpEdge
Definition: sc_clock.hh:99
sc_core::sc_clock::_gem5DownEdge
::sc_gem5::ClockTick * _gem5DownEdge
Definition: sc_clock.hh:100

Generated on Tue Dec 21 2021 11:34:36 for gem5 by doxygen 1.8.17