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 --- 20 unchanged lines hidden (view full) --- 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_event.hh" 36#include "../core/sc_port.hh" |
37#include "../utils/sc_trace_file.hh" |
38#include "sc_signal_in_if.hh" 39#include "sc_signal_inout_if.hh" |
40 41namespace sc_core 42{ 43 44class sc_event; 45class sc_trace_file; 46 47template <class T> --- 59 unchanged lines hidden (view full) --- 107 sc_port_base::bind(p); 108 } 109 void 110 operator () (sc_port<sc_signal_inout_if<T>, 1> &p) 111 { 112 bind(p); 113 } 114 |
115 virtual void 116 end_of_elaboration() 117 { 118 for (auto params: traceParamsVec) 119 sc_trace(params->tf, (*this)->read(), params->name); |
120 |
121 traceParamsVec.clear(); 122 } 123 |
124 const T &read() const { return (*this)->read(); } 125 operator const T& () const { return (*this)->read(); } 126 127 const sc_event &default_event() const { return (*this)->default_event(); } 128 const sc_event & 129 value_changed_event() const 130 { 131 return (*this)->value_changed_event(); 132 } 133 bool event() const { return (*this)->event(); } 134 sc_event_finder &value_changed() const { return _valueChangedFinder; } 135 136 virtual const char *kind() const { return "sc_in"; } 137 |
138 void 139 add_trace(sc_trace_file *tf, const std::string &name) const 140 { 141 traceParamsVec.push_back(new sc_trace_params(tf, name)); 142 } 143 |
144 private: 145 mutable sc_event_finder_t<sc_signal_in_if<T> > _valueChangedFinder; 146 |
147 mutable sc_trace_params_vec traceParamsVec; 148 |
149 // Disabled 150 sc_in(const sc_in<T> &); 151 sc_in<T> &operator = (const sc_in<T> &); 152}; 153 154template <class T> 155inline void |
156sc_trace(sc_trace_file *tf, const sc_in<T> &i, const std::string &name) |
157{ |
158 if (i.size()) 159 sc_trace(tf, i->read(), name); 160 else 161 i.add_trace(tf, name); |
162} 163 164template <> 165class sc_in<bool> : public sc_port<sc_signal_in_if<bool>, 1> 166{ 167 public: 168 sc_in() : sc_port<sc_signal_in_if<bool>, 1>(), 169 _valueChangedFinder(*this, --- 79 unchanged lines hidden (view full) --- 249 sc_port_base::bind(p); 250 } 251 void 252 operator () (sc_port<sc_signal_inout_if<bool>, 1> &p) 253 { 254 bind(p); 255 } 256 |
257 virtual void 258 end_of_elaboration() 259 { 260 for (auto params: traceParamsVec) 261 sc_trace(params->tf, (*this)->read(), params->name); |
262 |
263 traceParamsVec.clear(); 264 } 265 |
266 const bool &read() const { return (*this)->read(); } 267 operator const bool& () const { return (*this)->read(); } 268 269 const sc_event &default_event() const { return (*this)->default_event(); } 270 const sc_event & 271 value_changed_event() const 272 { 273 return (*this)->value_changed_event(); --- 14 unchanged lines hidden (view full) --- 288 bool negedge() const { return (*this)->negedge(); } 289 290 sc_event_finder &value_changed() const { return _valueChangedFinder; } 291 sc_event_finder &pos() const { return _posFinder; } 292 sc_event_finder &neg() const { return _negFinder; } 293 294 virtual const char *kind() const { return "sc_in"; } 295 |
296 void 297 add_trace(sc_trace_file *tf, const std::string &name) const 298 { 299 traceParamsVec.push_back(new sc_trace_params(tf, name)); 300 } 301 |
302 private: 303 mutable sc_event_finder_t<sc_signal_in_if<bool> > _valueChangedFinder; 304 mutable sc_event_finder_t<sc_signal_in_if<bool> > _posFinder; 305 mutable sc_event_finder_t<sc_signal_in_if<bool> > _negFinder; 306 |
307 mutable sc_trace_params_vec traceParamsVec; 308 |
309 // Disabled 310 sc_in(const sc_in<bool> &); 311 sc_in<bool> &operator = (const sc_in<bool> &); 312}; 313 314template <> 315inline void |
316sc_trace<bool>(sc_trace_file *tf, const sc_in<bool> &i, 317 const std::string &name) |
318{ |
319 if (i.size()) 320 sc_trace(tf, i->read(), name); 321 else 322 i.add_trace(tf, name); |
323} 324 325template <> 326class sc_in<sc_dt::sc_logic> : 327 public sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> 328{ 329 public: 330 sc_in() : sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(), --- 84 unchanged lines hidden (view full) --- 415 sc_port_base::bind(p); 416 } 417 void 418 operator () (sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &p) 419 { 420 bind(p); 421 } 422 |
423 virtual void 424 end_of_elaboration() 425 { 426 for (auto params: traceParamsVec) 427 sc_trace(params->tf, (*this)->read(), params->name); |
428 |
429 traceParamsVec.clear(); 430 } 431 |
432 const sc_dt::sc_logic &read() const { return (*this)->read(); } 433 operator const sc_dt::sc_logic& () const { return (*this)->read(); } 434 435 const sc_event &default_event() const { return (*this)->default_event(); } 436 const sc_event & 437 value_changed_event() const 438 { 439 return (*this)->value_changed_event(); --- 6 unchanged lines hidden (view full) --- 446 bool negedge() const { return (*this)->negedge(); } 447 448 sc_event_finder &value_changed() const { return _valueChangedFinder; } 449 sc_event_finder &pos() const { return _posFinder; } 450 sc_event_finder &neg() const { return _negFinder; } 451 452 virtual const char *kind() const { return "sc_in"; } 453 |
454 void 455 add_trace(sc_trace_file *tf, const std::string &name) const 456 { 457 traceParamsVec.push_back(new sc_trace_params(tf, name)); 458 } 459 |
460 private: 461 mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > 462 _valueChangedFinder; 463 mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _posFinder; 464 mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _negFinder; 465 |
466 mutable sc_trace_params_vec traceParamsVec; 467 |
468 // Disabled 469 sc_in(const sc_in<sc_dt::sc_logic> &); 470 sc_in<sc_dt::sc_logic> &operator = (const sc_in<sc_dt::sc_logic> &); 471}; 472 473template <> 474inline void |
475sc_trace<sc_dt::sc_logic>(sc_trace_file *tf, const sc_in<sc_dt::sc_logic> &i, 476 const std::string &name) |
477{ |
478 if (i.size()) 479 sc_trace(tf, i->read(), name); 480 else 481 i.add_trace(tf, name); |
482} 483 484} // namespace sc_core 485 486#endif //__SYSTEMC_EXT_CHANNEL_SC_IN_HH__ |