1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_signal_ifs.h -- The sc_signal<T> interface classes. 23 24 Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21 25 26 CHANGE LOG IS AT THE END OF THE FILE 27 *****************************************************************************/ 28 29#ifndef SC_SIGNAL_IFS_H 30#define SC_SIGNAL_IFS_H 31 32 33#include "sysc/communication/sc_interface.h" 34#include "sysc/communication/sc_writer_policy.h" 35 36 37namespace sc_dt 38{ 39 class sc_logic; 40} 41 42namespace sc_core { 43 44class sc_signal_bool_deval; 45class sc_signal_logic_deval; 46 47 48// ---------------------------------------------------------------------------- 49// CLASS : sc_signal_in_if<T> 50// 51// The sc_signal<T> input interface class. 52// ---------------------------------------------------------------------------- 53 54template <class T> 55class sc_signal_in_if 56: virtual public sc_interface 57{ 58public: 59 60 // get the value changed event 61 virtual const sc_event& value_changed_event() const = 0; 62 63 64 // read the current value 65 virtual const T& read() const = 0; 66 67 // get a reference to the current value (for tracing) 68 virtual const T& get_data_ref() const = 0; 69 70 71 // was there a value changed event? 72 virtual bool event() const = 0; 73 74protected: 75 76 // constructor 77 78 sc_signal_in_if() 79 {} 80 81private: 82 83 // disabled 84 sc_signal_in_if( const sc_signal_in_if<T>& ); 85 sc_signal_in_if<T>& operator = ( const sc_signal_in_if<T>& ); 86}; 87 88 89// ---------------------------------------------------------------------------- 90// CLASS : sc_signal_in_if<bool> 91// 92// Specialization of sc_signal_in_if<T> for type bool. 93// ---------------------------------------------------------------------------- 94 95class sc_reset; 96 97template <> 98class sc_signal_in_if<bool> 99: virtual public sc_interface 100{ 101 friend class sc_reset; 102public: 103 104 // get the value changed event 105 virtual const sc_event& value_changed_event() const = 0; 106 107 // get the positive edge event 108 virtual const sc_event& posedge_event() const = 0; 109 110 // get the negative edge event 111 virtual const sc_event& negedge_event() const = 0; 112 113 114 // read the current value 115 virtual const bool& read() const = 0; 116 117 // get a reference to the current value (for tracing) 118 virtual const bool& get_data_ref() const = 0; 119 120 121 // was there a value changed event? 122 virtual bool event() const = 0; 123 124 // was there a positive edge event? 125 virtual bool posedge() const = 0; 126 127 // was there a negative edge event? 128 virtual bool negedge() const = 0; 129 130protected: 131 132 // constructor 133 134 sc_signal_in_if() 135 {} 136 137private: 138 139 // disabled 140 sc_signal_in_if( const sc_signal_in_if<bool>& ); 141 sc_signal_in_if<bool>& operator = ( const sc_signal_in_if<bool>& ); 142 143 // designate this object as a reset signal 144 virtual sc_reset* is_reset() const 145 { return NULL; } 146}; 147 148 149// ---------------------------------------------------------------------------- 150// CLASS : sc_signal_in_if<sc_dt::sc_logic> 151// 152// Specialization of sc_signal_in_if<T> for type sc_dt::sc_logic. 153// ---------------------------------------------------------------------------- 154 155template <> 156class sc_signal_in_if<sc_dt::sc_logic> 157: virtual public sc_interface 158{ 159public: 160 161 // get the value changed event 162 virtual const sc_event& value_changed_event() const = 0; 163 164 // get the positive edge event 165 virtual const sc_event& posedge_event() const = 0; 166 167 // get the negative edge event 168 virtual const sc_event& negedge_event() const = 0; 169 170 171 // read the current value 172 virtual const sc_dt::sc_logic& read() const = 0; 173 174 // get a reference to the current value (for tracing) 175 virtual const sc_dt::sc_logic& get_data_ref() const = 0; 176 177 178 // was there a value changed event? 179 virtual bool event() const = 0; 180 181 // was there a positive edge event? 182 virtual bool posedge() const = 0; 183 184 // was there a negative edge event? 185 virtual bool negedge() const = 0; 186 187 188protected: 189 190 // constructor 191 192 sc_signal_in_if() 193 {} 194 195private: 196 197 // disabled 198 sc_signal_in_if( const sc_signal_in_if<sc_dt::sc_logic>& ); 199 sc_signal_in_if<sc_dt::sc_logic>& operator = ( 200 const sc_signal_in_if<sc_dt::sc_logic>& ); 201}; 202 203 204// ---------------------------------------------------------------------------- 205// CLASS : sc_signal_write_if<T> 206// 207// The standard output interface class. 208// ---------------------------------------------------------------------------- 209template< typename T > 210class sc_signal_write_if : public virtual sc_interface 211{ 212public: 213 sc_signal_write_if() {} 214 // write the new value 215 virtual void write( const T& ) = 0; 216 virtual sc_writer_policy get_writer_policy() const 217 { return SC_DEFAULT_WRITER_POLICY; } 218private: 219 // disabled 220 sc_signal_write_if( const sc_signal_write_if<T>& ); 221 sc_signal_write_if<T>& operator = ( const sc_signal_write_if<T>& ); 222}; 223 224 225// ---------------------------------------------------------------------------- 226// CLASS : sc_signal_inout_if<T> 227// 228// The sc_signal<T> input/output interface class. 229// ---------------------------------------------------------------------------- 230 231template <class T> 232class sc_signal_inout_if 233: public sc_signal_in_if<T>, public sc_signal_write_if<T> 234{ 235 236protected: 237 238 // constructor 239 240 sc_signal_inout_if() 241 {} 242 243private: 244 245 // disabled 246 sc_signal_inout_if( const sc_signal_inout_if<T>& ); 247 sc_signal_inout_if<T>& operator = ( const sc_signal_inout_if<T>& ); 248}; 249 250 251// ---------------------------------------------------------------------------- 252// CLASS : sc_signal_out_if<T> 253// 254// The sc_signal<T> output interface class. 255// ---------------------------------------------------------------------------- 256 257// sc_signal_out_if can also be read from, hence no difference with 258// sc_signal_inout_if. 259 260#define sc_signal_out_if sc_signal_inout_if 261 262} // namespace sc_core 263 264//$Log: sc_signal_ifs.h,v $ 265//Revision 1.4 2011/08/26 20:45:43 acg 266// Andy Goodrich: moved the modification log to the end of the file to 267// eliminate source line number skew when check-ins are done. 268// 269//Revision 1.3 2011/02/18 20:23:45 acg 270// Andy Goodrich: Copyright update. 271// 272//Revision 1.2 2010/12/07 19:50:37 acg 273// Andy Goodrich: addition of writer policies, courtesy of Philipp Hartmann. 274// 275//Revision 1.1.1.1 2006/12/15 20:20:04 acg 276//SystemC 2.3 277// 278//Revision 1.4 2006/08/29 23:35:00 acg 279// Andy Goodrich: added bind_count() method to allow users to determine which 280// ports are connected in before_end_of_elaboration(). 281// 282//Revision 1.3 2006/04/11 23:11:57 acg 283// Andy Goodrich: Changes for reset support that only includes 284// sc_cthread_process instances. 285// 286//Revision 1.2 2006/01/03 23:18:26 acg 287//Changed copyright to include 2006. 288// 289//Revision 1.1.1.1 2005/12/19 23:16:43 acg 290//First check in of SystemC 2.1 into its own archive. 291// 292//Revision 1.10 2005/09/15 23:01:51 acg 293//Added std:: prefix to appropriate methods and types to get around 294//issues with the Edison Front End. 295// 296//Revision 1.9 2005/06/29 18:12:12 acg 297//Added $log. 298// 299//Revision 1.8 2005/06/10 22:43:55 acg 300//Added CVS change log annotation. 301// 302 303#endif 304 305// Taf! 306