sc_inout.hh (13071:91e07c3feb64) sc_inout.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

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

30#ifndef __SYSTEMC_EXT_CHANNEL_SC_INOUT_HH__
31#define __SYSTEMC_EXT_CHANNEL_SC_INOUT_HH__
32
33#include <string>
34
35#include "../core/sc_event.hh"
36#include "../core/sc_port.hh"
37#include "../dt/bit/sc_logic.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

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

30#ifndef __SYSTEMC_EXT_CHANNEL_SC_INOUT_HH__
31#define __SYSTEMC_EXT_CHANNEL_SC_INOUT_HH__
32
33#include <string>
34
35#include "../core/sc_event.hh"
36#include "../core/sc_port.hh"
37#include "../dt/bit/sc_logic.hh"
38#include "../utils/sc_trace_file.hh"
38#include "sc_signal_inout_if.hh"
39#include "sc_signal_inout_if.hh"
39#include "warn_unimpl.hh"
40
41namespace sc_dt
42{
43
44class sc_logic;
45
46} // namespace sc_dt
47

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

106 virtual void
107 end_of_elaboration()
108 {
109 if (initValue) {
110 write(*initValue);
111 delete initValue;
112 initValue = nullptr;
113 }
40
41namespace sc_dt
42{
43
44class sc_logic;
45
46} // namespace sc_dt
47

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

106 virtual void
107 end_of_elaboration()
108 {
109 if (initValue) {
110 write(*initValue);
111 delete initValue;
112 initValue = nullptr;
113 }
114
115 for (auto params: traceParamsVec)
116 sc_trace(params->tf, (*this)->read(), params->name);
117
118 traceParamsVec.clear();
114 }
115
116 const T &read() const { return (*this)->read(); }
117 operator const T& () const { return (*this)->read(); }
118
119 void write(const T &t) { (*this)->write(t); }
120 sc_inout<T> &
121 operator = (const T &t)

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

154 {
155 return (*this)->value_changed_event();
156 }
157 bool event() const { return (*this)->event(); }
158 sc_event_finder &value_changed() const { return _valueChangedFinder; }
159
160 virtual const char *kind() const { return "sc_inout"; }
161
119 }
120
121 const T &read() const { return (*this)->read(); }
122 operator const T& () const { return (*this)->read(); }
123
124 void write(const T &t) { (*this)->write(t); }
125 sc_inout<T> &
126 operator = (const T &t)

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

159 {
160 return (*this)->value_changed_event();
161 }
162 bool event() const { return (*this)->event(); }
163 sc_event_finder &value_changed() const { return _valueChangedFinder; }
164
165 virtual const char *kind() const { return "sc_inout"; }
166
167 void
168 add_trace(sc_trace_file *tf, const std::string &name) const
169 {
170 traceParamsVec.push_back(new sc_trace_params(tf, name));
171 }
172
162 private:
163 T *initValue;
164 mutable sc_event_finder_t<sc_signal_inout_if<T> > _valueChangedFinder;
165
173 private:
174 T *initValue;
175 mutable sc_event_finder_t<sc_signal_inout_if<T> > _valueChangedFinder;
176
177 mutable sc_trace_params_vec traceParamsVec;
178
166 // Disabled
167 sc_inout(const sc_inout<T> &);
168};
169
170template <class T>
171inline void
179 // Disabled
180 sc_inout(const sc_inout<T> &);
181};
182
183template <class T>
184inline void
172sc_trace(sc_trace_file *, const sc_inout<T> &, const std::string &)
185sc_trace(sc_trace_file *tf, const sc_inout<T> &i, const std::string &name)
173{
186{
174 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
187 if (i.size())
188 sc_trace(tf, i->read(), name);
189 else
190 i.add_trace(tf, name);
175}
176
177template <>
178class sc_inout<bool> : public sc_port<sc_signal_inout_if<bool>, 1>
179{
180 public:
181 sc_inout() : sc_port<sc_signal_inout_if<bool>, 1>(), initValue(nullptr),
182 _valueChangedFinder(*this,

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

254 virtual void
255 end_of_elaboration()
256 {
257 if (initValue) {
258 write(*initValue);
259 delete initValue;
260 initValue = nullptr;
261 }
191}
192
193template <>
194class sc_inout<bool> : public sc_port<sc_signal_inout_if<bool>, 1>
195{
196 public:
197 sc_inout() : sc_port<sc_signal_inout_if<bool>, 1>(), initValue(nullptr),
198 _valueChangedFinder(*this,

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

270 virtual void
271 end_of_elaboration()
272 {
273 if (initValue) {
274 write(*initValue);
275 delete initValue;
276 initValue = nullptr;
277 }
278
279 for (auto params: traceParamsVec)
280 sc_trace(params->tf, (*this)->read(), params->name);
281
282 traceParamsVec.clear();
262 }
263
264 const bool &read() const { return (*this)->read(); }
265 operator const bool& () const { return (*this)->read(); }
266
267 void write(const bool &b) { (*this)->write(b); }
268 sc_inout<bool> &
269 operator = (const bool &b)

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

309 bool negedge() const { return (*this)->negedge(); }
310
311 sc_event_finder &value_changed() const { return _valueChangedFinder; }
312 sc_event_finder &pos() const { return _posFinder; }
313 sc_event_finder &neg() const { return _negFinder; }
314
315 virtual const char *kind() const { return "sc_inout"; }
316
283 }
284
285 const bool &read() const { return (*this)->read(); }
286 operator const bool& () const { return (*this)->read(); }
287
288 void write(const bool &b) { (*this)->write(b); }
289 sc_inout<bool> &
290 operator = (const bool &b)

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

330 bool negedge() const { return (*this)->negedge(); }
331
332 sc_event_finder &value_changed() const { return _valueChangedFinder; }
333 sc_event_finder &pos() const { return _posFinder; }
334 sc_event_finder &neg() const { return _negFinder; }
335
336 virtual const char *kind() const { return "sc_inout"; }
337
338 void
339 add_trace(sc_trace_file *tf, const std::string &name) const
340 {
341 traceParamsVec.push_back(new sc_trace_params(tf, name));
342 }
343
317 private:
318 bool *initValue;
319 mutable sc_event_finder_t<sc_signal_inout_if<bool> > _valueChangedFinder;
320 mutable sc_event_finder_t<sc_signal_inout_if<bool> > _posFinder;
321 mutable sc_event_finder_t<sc_signal_inout_if<bool> > _negFinder;
322
344 private:
345 bool *initValue;
346 mutable sc_event_finder_t<sc_signal_inout_if<bool> > _valueChangedFinder;
347 mutable sc_event_finder_t<sc_signal_inout_if<bool> > _posFinder;
348 mutable sc_event_finder_t<sc_signal_inout_if<bool> > _negFinder;
349
350 mutable sc_trace_params_vec traceParamsVec;
351
323 // Disabled
324 sc_inout(const sc_inout<bool> &);
325};
326
327template <>
328inline void sc_trace<bool>(
352 // Disabled
353 sc_inout(const sc_inout<bool> &);
354};
355
356template <>
357inline void sc_trace<bool>(
329 sc_trace_file *, const sc_inout<bool> &, const std::string &)
358 sc_trace_file *tf, const sc_inout<bool> &i, const std::string &name)
330{
359{
331 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
360 if (i.size())
361 sc_trace(tf, i->read(), name);
362 else
363 i.add_trace(tf, name);
332}
333
334template <>
335class sc_inout<sc_dt::sc_logic> :
336 public sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1>
337{
338 public:
339 sc_inout() : sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1>(),

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

428 virtual void
429 end_of_elaboration()
430 {
431 if (initValue) {
432 write(*initValue);
433 delete initValue;
434 initValue = nullptr;
435 }
364}
365
366template <>
367class sc_inout<sc_dt::sc_logic> :
368 public sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1>
369{
370 public:
371 sc_inout() : sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1>(),

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

460 virtual void
461 end_of_elaboration()
462 {
463 if (initValue) {
464 write(*initValue);
465 delete initValue;
466 initValue = nullptr;
467 }
468
469 for (auto params: traceParamsVec)
470 sc_trace(params->tf, (*this)->read(), params->name);
471
472 traceParamsVec.clear();
436 }
437
438 const sc_dt::sc_logic &read() const { return (*this)->read(); }
439 operator const sc_dt::sc_logic& () const { return (*this)->read(); }
440
441 void write(const sc_dt::sc_logic &l) { (*this)->write(l); }
442 sc_inout<sc_dt::sc_logic> &
443 operator = (const sc_dt::sc_logic &l)

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

483 bool negedge() const { return (*this)->negedge(); }
484
485 sc_event_finder &value_changed() const { return _valueChangedFinder; }
486 sc_event_finder &pos() const { return _posFinder; }
487 sc_event_finder &neg() const { return _negFinder; }
488
489 virtual const char *kind() const { return "sc_inout"; }
490
473 }
474
475 const sc_dt::sc_logic &read() const { return (*this)->read(); }
476 operator const sc_dt::sc_logic& () const { return (*this)->read(); }
477
478 void write(const sc_dt::sc_logic &l) { (*this)->write(l); }
479 sc_inout<sc_dt::sc_logic> &
480 operator = (const sc_dt::sc_logic &l)

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

520 bool negedge() const { return (*this)->negedge(); }
521
522 sc_event_finder &value_changed() const { return _valueChangedFinder; }
523 sc_event_finder &pos() const { return _posFinder; }
524 sc_event_finder &neg() const { return _negFinder; }
525
526 virtual const char *kind() const { return "sc_inout"; }
527
528 void
529 add_trace(sc_trace_file *tf, const std::string &name) const
530 {
531 traceParamsVec.push_back(new sc_trace_params(tf, name));
532 }
533
491 private:
492 sc_dt::sc_logic *initValue;
493 mutable sc_event_finder_t<
494 sc_signal_inout_if<sc_dt::sc_logic> > _valueChangedFinder;
495 mutable sc_event_finder_t<sc_signal_inout_if<sc_dt::sc_logic> > _posFinder;
496 mutable sc_event_finder_t<sc_signal_inout_if<sc_dt::sc_logic> > _negFinder;
497
534 private:
535 sc_dt::sc_logic *initValue;
536 mutable sc_event_finder_t<
537 sc_signal_inout_if<sc_dt::sc_logic> > _valueChangedFinder;
538 mutable sc_event_finder_t<sc_signal_inout_if<sc_dt::sc_logic> > _posFinder;
539 mutable sc_event_finder_t<sc_signal_inout_if<sc_dt::sc_logic> > _negFinder;
540
541 mutable sc_trace_params_vec traceParamsVec;
542
498 // Disabled
499 sc_inout(const sc_inout<sc_dt::sc_logic> &);
500};
501
502template <>
503inline void
543 // Disabled
544 sc_inout(const sc_inout<sc_dt::sc_logic> &);
545};
546
547template <>
548inline void
504sc_trace<sc_dt::sc_logic>(sc_trace_file *, const sc_inout<sc_dt::sc_logic> &,
505 const std::string &)
549sc_trace<sc_dt::sc_logic>(sc_trace_file *tf,
550 const sc_inout<sc_dt::sc_logic> &i, const std::string &name)
506{
551{
507 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
552 if (i.size())
553 sc_trace(tf, i->read(), name);
554 else
555 i.add_trace(tf, name);
508}
509
510} // namespace sc_core
511
512#endif //__SYSTEMC_EXT_CHANNEL_SC_INOUT_HH__
556}
557
558} // namespace sc_core
559
560#endif //__SYSTEMC_EXT_CHANNEL_SC_INOUT_HH__