gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Gabe Black
28  */
29 
30 #ifndef __SYSTEMC_EXT_CHANNEL_SC_CLOCK_HH__
31 #define __SYSTEMC_EXT_CHANNEL_SC_CLOCK_HH__
32 
33 #include "../core/sc_time.hh"
34 #include "sc_signal.hh"
35 
36 namespace sc_gem5
37 {
38 
39 class ClockTick;
40 
41 } // namespace sc_gem5
42 
43 namespace sc_core
44 {
45 
46 template <class T>
47 class sc_in;
48 
49 class sc_time;
50 
51 class sc_clock : public sc_signal<bool>
52 {
53  public:
54  sc_clock();
55  explicit sc_clock(const char *name);
56 
57  sc_clock(const char *name, const sc_time &period,
58  double duty_cycle=0.5, const sc_time &start_time=SC_ZERO_TIME,
59  bool posedge_first=true);
60 
61  sc_clock(const char *name, double period_v, sc_time_unit period_tu,
62  double duty_cycle=0.5);
63 
64  sc_clock(const char *name, double period_v, sc_time_unit period_tu,
65  double duty_cycle, double start_time_v,
66  sc_time_unit start_time_tu, bool posedge_first=true);
67 
68  // Deprecated.
69  sc_clock(const char *name, double period, double duty_cycle=0.5,
70  double start_time=0.0, bool posedge_first=true);
71 
72  virtual ~sc_clock();
73 
74  virtual void write(const bool &);
75 
76  const sc_time &period() const;
77  double duty_cycle() const;
78  const sc_time &start_time() const;
79  bool posedge_first() const;
80 
81  // Nonstandard
82  static const sc_time &time_stamp();
83 
84  virtual const char *kind() const { return "sc_clock"; }
85 
86  protected:
87  virtual void before_end_of_elaboration();
88 
89  private:
90  friend class ::sc_gem5::ClockTick;
91 
92  // Disabled
93  sc_clock(const sc_clock &) : sc_interface(), sc_signal<bool>() {}
94  sc_clock &operator = (const sc_clock &) { return *this; }
95 
97  double _dutyCycle;
100 
103 
104  void
106  {
107  m_new_val = true;
108  request_update();
109  }
110  void
112  {
113  m_new_val = false;
114  request_update();
115  }
116 };
117 
119 
120 // Deprecated
123 
124 } // namespace sc_core
125 
126 #endif //__SYSTEMC_EXT_CHANNEL_SC_CLOCK_HH__
const std::string & name()
Definition: trace.cc:54
sc_time_unit
Definition: sc_time.hh:42
sc_time _startTime
Definition: sc_clock.hh:98
::sc_gem5::ClockTick * _gem5DownEdge
Definition: sc_clock.hh:102
::sc_gem5::ClockTick * _gem5UpEdge
Definition: sc_clock.hh:101
sc_clock(const sc_clock &)
Definition: sc_clock.hh:93
const sc_time SC_ZERO_TIME
Definition: sc_time.cc:292
sc_time _period
Definition: sc_clock.hh:96
sc_in< bool > sc_in_clk
Definition: sc_clock.hh:118
sc_out< bool > sc_out_clk
Definition: sc_clock.hh:122
sc_inout< bool > sc_inout_clk
Definition: sc_clock.hh:121
double _dutyCycle
Definition: sc_clock.hh:97
virtual const char * kind() const
Definition: sc_clock.hh:84

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13