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