sc_in.hh revision 12841
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_IN_HH__ 31#define __SYSTEMC_EXT_CHANNEL_SC_IN_HH__ 32 33#include <string> 34 35#include "../core/sc_port.hh" 36#include "sc_signal_in_if.hh" 37#include "sc_signal_inout_if.hh" 38#include "warn_unimpl.hh" 39 40namespace sc_core 41{ 42 43class sc_event; 44class sc_event_finder; 45class sc_trace_file; 46 47template <class T> 48class sc_in : public sc_port<sc_signal_in_if<T>, 1> 49{ 50 public: 51 sc_in() : sc_port<sc_signal_in_if<T>, 1>() {} 52 explicit sc_in(const char *name) : sc_port<sc_signal_in_if<T>, 1>(name) {} 53 virtual ~sc_in() {} 54 55 virtual void 56 bind(const sc_signal_in_if<T> &) 57 { 58 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 59 } 60 void 61 operator () (const sc_signal_in_if<T> &) 62 { 63 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 64 } 65 66 virtual void 67 bind(sc_port<sc_signal_in_if<T>, 1> &) 68 { 69 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 70 } 71 void 72 operator () (sc_port<sc_signal_in_if<T>, 1> &) 73 { 74 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 75 } 76 77 virtual void 78 bind(sc_port<sc_signal_inout_if<T>, 1> &) 79 { 80 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 81 } 82 void 83 operator () (sc_port<sc_signal_inout_if<T>, 1> &) 84 { 85 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 86 } 87 88 virtual void 89 end_of_elaboration() 90 { 91 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 92 } 93 94 const T & 95 read() const 96 { 97 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 98 return *(const T *)nullptr; 99 } 100 operator const T& () const 101 { 102 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 103 return *(const T *)nullptr; 104 } 105 106 const sc_event & 107 default_event() const 108 { 109 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 110 return *(const sc_event *)nullptr; 111 } 112 const sc_event & 113 value_changed_event() const 114 { 115 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 116 return *(const sc_event *)nullptr; 117 } 118 bool 119 event() const 120 { 121 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 122 return false; 123 } 124 sc_event_finder & 125 value_changed() const 126 { 127 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 128 return *(sc_event_finder *)nullptr; 129 } 130 131 virtual const char *kind() const { return "sc_in"; } 132 133 private: 134 // Disabled 135 sc_in(const sc_in<T> &) : sc_port<sc_signal_in_if<T>, 1>() {} 136 sc_in<T> &operator = (const sc_in<T> &) { return *this; } 137}; 138 139template <class T> 140inline void 141sc_trace(sc_trace_file *, const sc_in<T> &, const std::string &) 142{ 143 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 144} 145 146template <> 147class sc_in<bool> : public sc_port<sc_signal_in_if<bool>, 1> 148{ 149 public: 150 sc_in() : sc_port<sc_signal_in_if<bool>, 1>() {} 151 explicit sc_in(const char *name) : 152 sc_port<sc_signal_in_if<bool>, 1>(name) {} 153 virtual ~sc_in() {} 154 155 virtual void 156 bind(const sc_signal_in_if<bool> &) 157 { 158 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 159 } 160 void 161 operator () (const sc_signal_in_if<bool> &) 162 { 163 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 164 } 165 166 virtual void 167 bind(sc_port<sc_signal_in_if<bool>, 1> &) 168 { 169 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 170 } 171 void 172 operator () (sc_port<sc_signal_in_if<bool>, 1> &) 173 { 174 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 175 } 176 177 virtual void 178 bind(sc_port<sc_signal_inout_if<bool>, 1> &) 179 { 180 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 181 } 182 void 183 operator () (sc_port<sc_signal_inout_if<bool>, 1> &) 184 { 185 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 186 } 187 188 virtual void 189 end_of_elaboration() 190 { 191 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 192 } 193 194 const bool & 195 read() const 196 { 197 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 198 return *(const bool *)nullptr; 199 } 200 operator const bool& () const 201 { 202 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 203 return *(const bool *)nullptr; 204 } 205 206 const sc_event & 207 default_event() const 208 { 209 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 210 return *(const sc_event *)nullptr; 211 } 212 const sc_event & 213 value_changed_event() const 214 { 215 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 216 return *(const sc_event *)nullptr; 217 } 218 const sc_event & 219 posedge_event() const 220 { 221 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 222 return *(const sc_event *)nullptr; 223 } 224 const sc_event & 225 negedge_event() const 226 { 227 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 228 return *(const sc_event *)nullptr; 229 } 230 231 bool 232 event() const 233 { 234 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 235 return false; 236 } 237 bool 238 posedge() const 239 { 240 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 241 return false; 242 } 243 bool 244 negedge() const 245 { 246 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 247 return false; 248 } 249 250 sc_event_finder & 251 value_changed() const 252 { 253 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 254 return *(sc_event_finder *)nullptr; 255 } 256 sc_event_finder & 257 pos() const 258 { 259 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 260 return *(sc_event_finder *)nullptr; 261 } 262 sc_event_finder & 263 neg() const 264 { 265 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 266 return *(sc_event_finder *)nullptr; 267 } 268 269 virtual const char *kind() const { return "sc_in"; } 270 271 private: 272 // Disabled 273 sc_in(const sc_in<bool> &) : sc_port<sc_signal_in_if<bool>, 1>() {} 274 sc_in<bool> &operator = (const sc_in<bool> &) { return *this; } 275}; 276 277template <> 278inline void 279sc_trace<bool>(sc_trace_file *, const sc_in<bool> &, const std::string &) 280{ 281 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 282} 283 284template <> 285class sc_in<sc_dt::sc_logic> : 286 public sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> 287{ 288 public: 289 sc_in() : sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>() {} 290 explicit sc_in(const char *name) : 291 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name) 292 {} 293 virtual ~sc_in() {} 294 295 virtual void 296 bind(const sc_signal_in_if<sc_dt::sc_logic> &) 297 { 298 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 299 } 300 void 301 operator () (const sc_signal_in_if<sc_dt::sc_logic> &) 302 { 303 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 304 } 305 306 virtual void 307 bind(sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &) 308 { 309 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 310 } 311 void 312 operator () (sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &) 313 { 314 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 315 } 316 317 virtual void 318 bind(sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &) 319 { 320 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 321 } 322 void 323 operator () (sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &) 324 { 325 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 326 } 327 328 virtual void 329 end_of_elaboration() 330 { 331 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 332 } 333 334 const sc_dt::sc_logic & 335 read() const 336 { 337 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 338 return *(const sc_dt::sc_logic *)nullptr; 339 } 340 operator const sc_dt::sc_logic& () const 341 { 342 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 343 return *(const sc_dt::sc_logic *)nullptr; 344 } 345 346 const sc_event & 347 default_event() const 348 { 349 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 350 return *(const sc_event *)nullptr; 351 } 352 const sc_event & 353 value_changed_event() const 354 { 355 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 356 return *(const sc_event *)nullptr; 357 } 358 const sc_event & 359 posedge_event() const 360 { 361 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 362 return *(const sc_event *)nullptr; 363 } 364 const sc_event & 365 negedge_event() const 366 { 367 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 368 return *(const sc_event *)nullptr; 369 } 370 371 bool 372 event() const 373 { 374 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 375 return false; 376 } 377 bool 378 posedge() const 379 { 380 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 381 return false; 382 } 383 bool 384 negedge() const 385 { 386 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 387 return false; 388 } 389 390 sc_event_finder & 391 value_changed() const 392 { 393 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 394 return *(sc_event_finder *)nullptr; 395 } 396 sc_event_finder & 397 pos() const 398 { 399 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 400 return *(sc_event_finder *)nullptr; 401 } 402 sc_event_finder & 403 neg() const 404 { 405 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 406 return *(sc_event_finder *)nullptr; 407 } 408 409 virtual const char *kind() const { return "sc_in"; } 410 411 private: 412 // Disabled 413 sc_in(const sc_in<sc_dt::sc_logic> &) : 414 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>() 415 {} 416 sc_in<sc_dt::sc_logic> & 417 operator = (const sc_in<sc_dt::sc_logic> &) 418 { 419 return *this; 420 } 421}; 422 423template <> 424inline void 425sc_trace<sc_dt::sc_logic>( 426 sc_trace_file *, const sc_in<sc_dt::sc_logic> &, const std::string &) 427{ 428 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 429} 430 431} // namespace sc_core 432 433#endif //__SYSTEMC_EXT_CHANNEL_SC_IN_HH__ 434