sc_clock.hh revision 12931:2dd5b061490b
12632Sstever@eecs.umich.edu/*
22632Sstever@eecs.umich.edu * Copyright 2018 Google, Inc.
32632Sstever@eecs.umich.edu *
42632Sstever@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
54479Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are
64479Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright
74479Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer;
84479Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright
92632Sstever@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
102632Sstever@eecs.umich.edu * documentation and/or other materials provided with the distribution;
112632Sstever@eecs.umich.edu * neither the name of the copyright holders nor the names of its
122632Sstever@eecs.umich.edu * contributors may be used to endorse or promote products derived from
132632Sstever@eecs.umich.edu * this software without specific prior written permission.
142632Sstever@eecs.umich.edu *
152632Sstever@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162632Sstever@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172632Sstever@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182632Sstever@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192632Sstever@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202632Sstever@eecs.umich.edu * 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
36namespace sc_core
37{
38
39template <class T>
40class sc_in;
41
42class sc_time;
43
44class sc_clock : public sc_signal<bool>
45{
46  public:
47    sc_clock();
48    explicit sc_clock(const char *name);
49
50    sc_clock(const char *name, const sc_time &period,
51             double duty_cycle=0.5, const sc_time &start_time=SC_ZERO_TIME,
52             bool posedge_first=true);
53
54    sc_clock(const char *name, double period_v, sc_time_unit period_tu,
55             double duty_cycle=0.5);
56
57    sc_clock(const char *name, double period_v, sc_time_unit period_tu,
58             double duty_cycle, double start_time_v,
59             sc_time_unit start_time_tu, bool posedge_first=true);
60
61    // Deprecated.
62    sc_clock(const char *name, double period, double duty_cycle=0.5,
63             double start_time=0.0, bool posedge_first=true);
64
65    virtual ~sc_clock();
66
67    virtual void write(const bool &);
68
69    const sc_time &period() const;
70    double duty_cycle() const;
71    const sc_time &start_time() const;
72    bool posedge_first() const;
73
74    // Nonstandard
75    static const sc_time &time_stamp();
76
77    virtual const char *kind() const;
78
79  protected:
80    virtual void before_end_of_elaboration();
81
82  private:
83    // Disabled
84    sc_clock(const sc_clock &) : sc_interface(), sc_signal<bool>() {}
85    sc_clock &operator = (const sc_clock &) { return *this; }
86};
87
88typedef sc_in<bool> sc_in_clk;
89
90// Deprecated
91typedef sc_inout<bool> sc_inout_clk;
92typedef sc_out<bool> sc_out_clk;
93
94} // namespace sc_core
95
96#endif  //__SYSTEMC_EXT_CHANNEL_SC_CLOCK_HH__
97