sc_in.hh (13054:bce8a8124325) sc_in.hh (13245:c666c5d4996b)
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"
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"
37#include "sc_signal_in_if.hh"
38#include "sc_signal_inout_if.hh"
38#include "sc_signal_in_if.hh"
39#include "sc_signal_inout_if.hh"
39#include "warn_unimpl.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
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 end_of_elaboration() { /* Implementation defined. */ }
115 virtual void
116 end_of_elaboration()
117 {
118 for (auto params: traceParamsVec)
119 sc_trace(params->tf, (*this)->read(), params->name);
116
120
121 traceParamsVec.clear();
122 }
123
117 const T &read() const { return (*this)->read(); }
118 operator const T& () const { return (*this)->read(); }
119
120 const sc_event &default_event() const { return (*this)->default_event(); }
121 const sc_event &
122 value_changed_event() const
123 {
124 return (*this)->value_changed_event();
125 }
126 bool event() const { return (*this)->event(); }
127 sc_event_finder &value_changed() const { return _valueChangedFinder; }
128
129 virtual const char *kind() const { return "sc_in"; }
130
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
131 private:
132 mutable sc_event_finder_t<sc_signal_in_if<T> > _valueChangedFinder;
133
144 private:
145 mutable sc_event_finder_t<sc_signal_in_if<T> > _valueChangedFinder;
146
147 mutable sc_trace_params_vec traceParamsVec;
148
134 // Disabled
135 sc_in(const sc_in<T> &);
136 sc_in<T> &operator = (const sc_in<T> &);
137};
138
139template <class T>
140inline void
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
141sc_trace(sc_trace_file *, const sc_in<T> &, const std::string &)
156sc_trace(sc_trace_file *tf, const sc_in<T> &i, const std::string &name)
142{
157{
143 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
158 if (i.size())
159 sc_trace(tf, i->read(), name);
160 else
161 i.add_trace(tf, name);
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 _valueChangedFinder(*this,

--- 79 unchanged lines hidden (view full) ---

231 sc_port_base::bind(p);
232 }
233 void
234 operator () (sc_port<sc_signal_inout_if<bool>, 1> &p)
235 {
236 bind(p);
237 }
238
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
239 virtual void end_of_elaboration() { /* Implementation defined. */ }
257 virtual void
258 end_of_elaboration()
259 {
260 for (auto params: traceParamsVec)
261 sc_trace(params->tf, (*this)->read(), params->name);
240
262
263 traceParamsVec.clear();
264 }
265
241 const bool &read() const { return (*this)->read(); }
242 operator const bool& () const { return (*this)->read(); }
243
244 const sc_event &default_event() const { return (*this)->default_event(); }
245 const sc_event &
246 value_changed_event() const
247 {
248 return (*this)->value_changed_event();

--- 14 unchanged lines hidden (view full) ---

263 bool negedge() const { return (*this)->negedge(); }
264
265 sc_event_finder &value_changed() const { return _valueChangedFinder; }
266 sc_event_finder &pos() const { return _posFinder; }
267 sc_event_finder &neg() const { return _negFinder; }
268
269 virtual const char *kind() const { return "sc_in"; }
270
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
271 private:
272 mutable sc_event_finder_t<sc_signal_in_if<bool> > _valueChangedFinder;
273 mutable sc_event_finder_t<sc_signal_in_if<bool> > _posFinder;
274 mutable sc_event_finder_t<sc_signal_in_if<bool> > _negFinder;
275
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
276 // Disabled
277 sc_in(const sc_in<bool> &);
278 sc_in<bool> &operator = (const sc_in<bool> &);
279};
280
281template <>
282inline void
309 // Disabled
310 sc_in(const sc_in<bool> &);
311 sc_in<bool> &operator = (const sc_in<bool> &);
312};
313
314template <>
315inline void
283sc_trace<bool>(sc_trace_file *, const sc_in<bool> &, const std::string &)
316sc_trace<bool>(sc_trace_file *tf, const sc_in<bool> &i,
317 const std::string &name)
284{
318{
285 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
319 if (i.size())
320 sc_trace(tf, i->read(), name);
321 else
322 i.add_trace(tf, name);
286}
287
288template <>
289class sc_in<sc_dt::sc_logic> :
290 public sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>
291{
292 public:
293 sc_in() : sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(),

--- 84 unchanged lines hidden (view full) ---

378 sc_port_base::bind(p);
379 }
380 void
381 operator () (sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &p)
382 {
383 bind(p);
384 }
385
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
386 virtual void end_of_elaboration() { /* Implementation defined. */ }
423 virtual void
424 end_of_elaboration()
425 {
426 for (auto params: traceParamsVec)
427 sc_trace(params->tf, (*this)->read(), params->name);
387
428
429 traceParamsVec.clear();
430 }
431
388 const sc_dt::sc_logic &read() const { return (*this)->read(); }
389 operator const sc_dt::sc_logic& () const { return (*this)->read(); }
390
391 const sc_event &default_event() const { return (*this)->default_event(); }
392 const sc_event &
393 value_changed_event() const
394 {
395 return (*this)->value_changed_event();

--- 6 unchanged lines hidden (view full) ---

402 bool negedge() const { return (*this)->negedge(); }
403
404 sc_event_finder &value_changed() const { return _valueChangedFinder; }
405 sc_event_finder &pos() const { return _posFinder; }
406 sc_event_finder &neg() const { return _negFinder; }
407
408 virtual const char *kind() const { return "sc_in"; }
409
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
410 private:
411 mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> >
412 _valueChangedFinder;
413 mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _posFinder;
414 mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _negFinder;
415
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
416 // Disabled
417 sc_in(const sc_in<sc_dt::sc_logic> &);
418 sc_in<sc_dt::sc_logic> &operator = (const sc_in<sc_dt::sc_logic> &);
419};
420
421template <>
422inline void
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
423sc_trace(
424 sc_trace_file *, const sc_in<sc_dt::sc_logic> &, const std::string &)
475sc_trace<sc_dt::sc_logic>(sc_trace_file *tf, const sc_in<sc_dt::sc_logic> &i,
476 const std::string &name)
425{
477{
426 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
478 if (i.size())
479 sc_trace(tf, i->read(), name);
480 else
481 i.add_trace(tf, name);
427}
428
429} // namespace sc_core
430
431#endif //__SYSTEMC_EXT_CHANNEL_SC_IN_HH__
482}
483
484} // namespace sc_core
485
486#endif //__SYSTEMC_EXT_CHANNEL_SC_IN_HH__