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_SIGNAL_IN_IF_HH__ 31#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_IN_IF_HH__ 32 33#include "../core/sc_interface.hh" 34 35namespace sc_dt 36{ 37 38class sc_logic; 39 40}; 41 42namespace sc_gem5 43{ 44 45class Reset; 46 47} // namespace sc_gem5 48 49namespace sc_core 50{ 51 52class sc_event; 53 54template <class T> 55class sc_signal_in_if : virtual public sc_interface 56{ 57 public: 58 virtual const T &read() const = 0; 59 virtual const sc_event &value_changed_event() const = 0; 60 virtual bool event() const = 0; 61 62 protected: 63 sc_signal_in_if() : sc_interface() {} 64 65 private: 66 // Disabled 67 sc_signal_in_if(const sc_signal_in_if<T> &) : sc_interface() {} 68 sc_signal_in_if<T> & 69 operator = (const sc_signal_in_if<T> &) 70 { 71 return *this; 72 } 73}; 74 75template <> 76class sc_signal_in_if<bool> : virtual public sc_interface 77{ 78 public: 79 virtual const bool &read() const = 0; 80 81 virtual const sc_event &value_changed_event() const = 0; 82 virtual const sc_event &posedge_event() const = 0; 83 virtual const sc_event &negedge_event() const = 0; 84 85 virtual bool event() const = 0; 86 virtual bool posedge() const = 0; 87 virtual bool negedge() const = 0; 88 89 protected: 90 sc_signal_in_if() : sc_interface() {} 91 92 private: 93 friend class sc_gem5::Reset; 94 virtual bool 95 _addReset(sc_gem5::Reset *reset) const 96 { 97 return false; 98 } 99 100 // Disabled 101 sc_signal_in_if(const sc_signal_in_if<bool> &) : sc_interface() {} 102 sc_signal_in_if<bool> & 103 operator = (const sc_signal_in_if<bool> &) 104 { 105 return *this; 106 } 107}; 108 109template <> 110class sc_signal_in_if<sc_dt::sc_logic> : virtual public sc_interface 111{ 112 public: 113 virtual const sc_dt::sc_logic &read() const = 0; 114 115 virtual const sc_event &value_changed_event() const = 0; 116 virtual const sc_event &posedge_event() const = 0; 117 virtual const sc_event &negedge_event() const = 0; 118 119 virtual bool event() const = 0; 120 virtual bool posedge() const = 0; 121 virtual bool negedge() const = 0; 122 123 protected: 124 sc_signal_in_if() : sc_interface() {} 125 126 private: 127 // Disabled 128 sc_signal_in_if(const sc_signal_in_if<sc_dt::sc_logic> &) : 129 sc_interface() 130 {} 131 sc_signal_in_if<sc_dt::sc_logic> & 132 operator = (const sc_signal_in_if<sc_dt::sc_logic> &) 133 { 134 return *this; 135 } 136}; 137 138} // namespace sc_core 139 140#endif //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_IN_IF_HH__ 141