gem5 v24.0.0.0
Loading...
Searching...
No Matches
sc_in.hh
Go to the documentation of this file.
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
28#ifndef __SYSTEMC_EXT_CHANNEL_SC_IN_HH__
29#define __SYSTEMC_EXT_CHANNEL_SC_IN_HH__
30
31#include <string>
32
33#include "../core/sc_event.hh"
34#include "../core/sc_main.hh"
35#include "../core/sc_port.hh"
37#include "sc_signal_in_if.hh"
38#include "sc_signal_inout_if.hh"
39
40namespace sc_core
41{
42
43class sc_event;
44class sc_trace_file;
45
46template <class T>
47class sc_in : public sc_port<sc_signal_in_if<T>, 1>
48{
49 public:
53 explicit sc_in(const char *name) : sc_port<sc_signal_in_if<T>, 1>(name),
55 {}
56 virtual ~sc_in() {}
57
58 // Deprecated binding constructors.
59 explicit sc_in(const sc_signal_in_if<T> &interface) :
60 sc_port<sc_signal_in_if<T>, 1>(interface),
62 {}
63 sc_in(const char *name, const sc_signal_in_if<T> &interface) :
64 sc_port<sc_signal_in_if<T>, 1>(name, interface),
66 {}
71 sc_in(const char *name, sc_port_b<sc_signal_in_if<T> > &parent) :
72 sc_port<sc_signal_in_if<T>, 1>(name, parent),
74 {}
75 explicit sc_in(sc_port<sc_signal_in_if<T>, 1> &parent) :
76 sc_port<sc_signal_in_if<T>, 1>(parent),
78 {}
79 sc_in(const char *name, sc_port<sc_signal_in_if<T>, 1> &parent) :
80 sc_port<sc_signal_in_if<T>, 1>(name, parent),
82 {}
83
85 virtual void
87 {
89 const_cast<sc_signal_in_if<T> &>(i));
90 }
91 void operator () (const sc_signal_in_if<T> &i) { bind(i); }
92
93 virtual void
98 void
100 {
101 bind(p);
102 }
103
104 virtual void
109 void
111 {
112 bind(p);
113 }
114
115 virtual void
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 &
130 {
131 return (*this)->value_changed_event();
132 }
133 bool event() const { return (*this)->event(); }
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:
146
148
149 // Disabled
150 sc_in(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{
159 i.add_trace(tf, name);
160 else
161 sc_trace(tf, i->read(), name);
162}
163
164template <>
165class sc_in<bool> : public sc_port<sc_signal_in_if<bool>, 1>
166{
167 public:
171 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
172 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
173 {}
174 explicit sc_in(const char *name) :
175 sc_port<sc_signal_in_if<bool>, 1>(name),
178 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
179 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
180 {}
181 virtual ~sc_in() {}
182
183 // Deprecated binding constructors.
184 explicit sc_in(const sc_signal_in_if<bool> &interface) :
185 sc_port<sc_signal_in_if<bool>, 1>(interface),
188 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
189 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
190 {}
191 sc_in(const char *name, const sc_signal_in_if<bool> &interface) :
192 sc_port<sc_signal_in_if<bool>, 1>(name, interface),
195 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
196 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
197 {}
199 sc_port<sc_signal_in_if<bool>, 1>(parent),
202 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
203 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
204 {}
205 sc_in(const char *name, sc_port_b<sc_signal_in_if<bool> > &parent) :
206 sc_port<sc_signal_in_if<bool>, 1>(name, parent),
209 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
210 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
211 {}
212 explicit sc_in(sc_port<sc_signal_in_if<bool>, 1> &parent) :
213 sc_port<sc_signal_in_if<bool>, 1>(parent),
216 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
217 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
218 {}
219 sc_in(const char *name, sc_port<sc_signal_in_if<bool>, 1> &parent) :
220 sc_port<sc_signal_in_if<bool>, 1>(name, parent),
223 _posFinder(*this, &sc_signal_in_if<bool>::posedge_event),
224 _negFinder(*this, &sc_signal_in_if<bool>::negedge_event)
225 {}
226
228
229 virtual void
231 {
233 const_cast<sc_signal_in_if<bool> &>(i));
234 }
236
237 virtual void
242 void
244 {
245 bind(p);
246 }
247
248 virtual void
253 void
258
259 virtual void
261 {
262 for (auto params: traceParamsVec)
263 sc_trace(params->tf, (*this)->read(), params->name);
264
265 traceParamsVec.clear();
266 }
267
268 const bool &read() const { return (*this)->read(); }
269 operator const bool& () const { return (*this)->read(); }
270
271 const sc_event &default_event() const { return (*this)->default_event(); }
272 const sc_event &
274 {
275 return (*this)->value_changed_event();
276 }
277 const sc_event &
279 {
280 return (*this)->posedge_event();
281 }
282 const sc_event &
284 {
285 return (*this)->negedge_event();
286 }
287
288 bool event() const { return (*this)->event(); }
289 bool posedge() const { return (*this)->posedge(); }
290 bool negedge() const { return (*this)->negedge(); }
291
293 sc_event_finder &pos() const { return _posFinder; }
294 sc_event_finder &neg() const { return _negFinder; }
295
296 virtual const char *kind() const { return "sc_in"; }
297
298 void
299 add_trace(sc_trace_file *tf, const std::string &name) const
300 {
301 traceParamsVec.push_back(new sc_trace_params(tf, name));
302 }
303
304 private:
308
310
311 // Disabled
314};
315
316template <>
317inline void
319 const std::string &name)
320{
322 i.add_trace(tf, name);
323 else
324 sc_trace(tf, i->read(), name);
325}
326
327template <>
328class sc_in<sc_dt::sc_logic> :
329 public sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>
330{
331 public:
332 sc_in() : sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(),
335 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
336 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
337 {}
338 explicit sc_in(const char *name) :
339 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name),
342 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
343 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
344 {}
345 virtual ~sc_in() {}
346
347 // Deprecated binding constructors.
348 explicit sc_in(const sc_signal_in_if<sc_dt::sc_logic> &interface) :
349 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(interface),
352 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
353 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
354 {}
355 sc_in(const char *name,
356 const sc_signal_in_if<sc_dt::sc_logic> &interface) :
357 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, interface),
360 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
361 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
362 {}
364 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(parent),
367 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
368 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
369 {}
370 sc_in(const char *name,
372 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, parent),
375 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
376 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
377 {}
379 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(parent),
382 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
383 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
384 {}
385 sc_in(const char *name,
387 sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, parent),
390 _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event),
391 _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event)
392 {}
393
395
396 virtual void
402 void
404
405 virtual void
410 void
415
416 virtual void
421 void
426
427 virtual void
429 {
430 for (auto params: traceParamsVec)
431 sc_trace(params->tf, (*this)->read(), params->name);
432
433 traceParamsVec.clear();
434 }
435
436 const sc_dt::sc_logic &read() const { return (*this)->read(); }
437 operator const sc_dt::sc_logic& () const { return (*this)->read(); }
438
439 const sc_event &default_event() const { return (*this)->default_event(); }
440 const sc_event &
442 {
443 return (*this)->value_changed_event();
444 }
445 const sc_event &posedge_event() const { return (*this)->posedge_event(); }
446 const sc_event &negedge_event() const { return (*this)->negedge_event(); }
447
448 bool event() const { return (*this)->event(); }
449 bool posedge() const { return (*this)->posedge(); }
450 bool negedge() const { return (*this)->negedge(); }
451
453 sc_event_finder &pos() const { return _posFinder; }
454 sc_event_finder &neg() const { return _negFinder; }
455
456 virtual const char *kind() const { return "sc_in"; }
457
458 void
459 add_trace(sc_trace_file *tf, const std::string &name) const
460 {
461 traceParamsVec.push_back(new sc_trace_params(tf, name));
462 }
463
464 private:
469
471
472 // Disabled
475};
476
477template <>
478inline void
480 const std::string &name)
481{
483 i.add_trace(tf, name);
484 else
485 sc_trace(tf, i->read(), name);
486}
487
488} // namespace sc_core
489
490#endif //__SYSTEMC_EXT_CHANNEL_SC_IN_HH__
const sc_event & default_event() const
Definition sc_in.hh:271
const sc_event & posedge_event() const
Definition sc_in.hh:278
virtual void bind(const sc_signal_in_if< bool > &i)
Definition sc_in.hh:230
virtual void bind(sc_port< sc_signal_in_if< bool >, 1 > &p)
Definition sc_in.hh:238
virtual void end_of_elaboration()
Definition sc_in.hh:260
virtual const char * kind() const
Definition sc_in.hh:296
sc_event_finder_t< sc_signal_in_if< bool > > _negFinder
Definition sc_in.hh:307
sc_event_finder & value_changed() const
Definition sc_in.hh:292
bool negedge() const
Definition sc_in.hh:290
sc_in(const sc_signal_in_if< bool > &interface)
Definition sc_in.hh:184
void add_trace(sc_trace_file *tf, const std::string &name) const
Definition sc_in.hh:299
sc_event_finder_t< sc_signal_in_if< bool > > _posFinder
Definition sc_in.hh:306
const sc_event & value_changed_event() const
Definition sc_in.hh:273
sc_in(const sc_in< bool > &)
const sc_event & negedge_event() const
Definition sc_in.hh:283
sc_trace_params_vec traceParamsVec
Definition sc_in.hh:309
sc_in(sc_port_b< sc_signal_in_if< bool > > &parent)
Definition sc_in.hh:198
sc_in(sc_port< sc_signal_in_if< bool >, 1 > &parent)
Definition sc_in.hh:212
sc_event_finder & pos() const
Definition sc_in.hh:293
sc_event_finder_t< sc_signal_in_if< bool > > _valueChangedFinder
Definition sc_in.hh:305
sc_event_finder & neg() const
Definition sc_in.hh:294
sc_in(const char *name, sc_port_b< sc_signal_in_if< bool > > &parent)
Definition sc_in.hh:205
bool event() const
Definition sc_in.hh:288
const bool & read() const
Definition sc_in.hh:268
sc_in(const char *name, sc_port< sc_signal_in_if< bool >, 1 > &parent)
Definition sc_in.hh:219
virtual void bind(sc_port< sc_signal_inout_if< bool >, 1 > &p)
Definition sc_in.hh:249
bool posedge() const
Definition sc_in.hh:289
sc_in(const char *name)
Definition sc_in.hh:174
sc_in(const char *name, const sc_signal_in_if< bool > &interface)
Definition sc_in.hh:191
sc_trace_params_vec traceParamsVec
Definition sc_in.hh:470
sc_in(sc_port< sc_signal_in_if< sc_dt::sc_logic >, 1 > &parent)
Definition sc_in.hh:378
void add_trace(sc_trace_file *tf, const std::string &name) const
Definition sc_in.hh:459
virtual void bind(sc_port< sc_signal_in_if< sc_dt::sc_logic >, 1 > &i)
Definition sc_in.hh:406
const sc_event & posedge_event() const
Definition sc_in.hh:445
sc_in(const sc_signal_in_if< sc_dt::sc_logic > &interface)
Definition sc_in.hh:348
const sc_event & default_event() const
Definition sc_in.hh:439
sc_in(const char *name, sc_port_b< sc_signal_in_if< sc_dt::sc_logic > > &parent)
Definition sc_in.hh:370
sc_in(const char *name, sc_port< sc_signal_in_if< sc_dt::sc_logic >, 1 > &parent)
Definition sc_in.hh:385
sc_event_finder_t< sc_signal_in_if< sc_dt::sc_logic > > _valueChangedFinder
Definition sc_in.hh:466
virtual const char * kind() const
Definition sc_in.hh:456
sc_event_finder & value_changed() const
Definition sc_in.hh:452
sc_in(const char *name, const sc_signal_in_if< sc_dt::sc_logic > &interface)
Definition sc_in.hh:355
const sc_event & negedge_event() const
Definition sc_in.hh:446
sc_in(const sc_in< sc_dt::sc_logic > &)
const sc_dt::sc_logic & read() const
Definition sc_in.hh:436
virtual void end_of_elaboration()
Definition sc_in.hh:428
const sc_event & value_changed_event() const
Definition sc_in.hh:441
sc_event_finder & pos() const
Definition sc_in.hh:453
sc_event_finder_t< sc_signal_in_if< sc_dt::sc_logic > > _negFinder
Definition sc_in.hh:468
sc_in(sc_port_b< sc_signal_in_if< sc_dt::sc_logic > > &parent)
Definition sc_in.hh:363
virtual void bind(const sc_signal_in_if< sc_dt::sc_logic > &i)
Definition sc_in.hh:397
virtual void bind(sc_port< sc_signal_inout_if< sc_dt::sc_logic >, 1 > &p)
Definition sc_in.hh:417
sc_event_finder & neg() const
Definition sc_in.hh:454
sc_event_finder_t< sc_signal_in_if< sc_dt::sc_logic > > _posFinder
Definition sc_in.hh:467
sc_in< T > & operator=(const sc_in< T > &)
void add_trace(sc_trace_file *tf, const std::string &name) const
Definition sc_in.hh:139
sc_trace_params_vec traceParamsVec
Definition sc_in.hh:147
void operator()(const sc_signal_in_if< T > &i)
Definition sc_in.hh:91
sc_in(sc_port< sc_signal_in_if< T >, 1 > &parent)
Definition sc_in.hh:75
virtual void bind(sc_port< sc_signal_inout_if< T >, 1 > &p)
Definition sc_in.hh:105
virtual const char * kind() const
Definition sc_in.hh:136
virtual void bind(sc_port< sc_signal_in_if< T >, 1 > &i)
Definition sc_in.hh:94
sc_in(const char *name)
Definition sc_in.hh:53
sc_event_finder_t< sc_signal_in_if< T > > _valueChangedFinder
Definition sc_in.hh:145
const T & read() const
Definition sc_in.hh:124
sc_in(const char *name, sc_port_b< sc_signal_in_if< T > > &parent)
Definition sc_in.hh:71
const sc_event & value_changed_event() const
Definition sc_in.hh:129
const sc_event & default_event() const
Definition sc_in.hh:127
virtual ~sc_in()
Definition sc_in.hh:56
bool event() const
Definition sc_in.hh:133
sc_in(const sc_in< T > &)
virtual void end_of_elaboration()
Definition sc_in.hh:116
virtual void bind(const sc_signal_in_if< T > &i)
Definition sc_in.hh:86
sc_in(const char *name, const sc_signal_in_if< T > &interface)
Definition sc_in.hh:63
sc_in(const sc_signal_in_if< T > &interface)
Definition sc_in.hh:59
sc_in(sc_port_b< sc_signal_in_if< T > > &parent)
Definition sc_in.hh:67
sc_in(const char *name, sc_port< sc_signal_in_if< T >, 1 > &parent)
Definition sc_in.hh:79
sc_event_finder & value_changed() const
Definition sc_in.hh:134
void bind(sc_interface &)
Definition sc_port.cc:109
sc_status sc_get_status()
Definition sc_main.cc:172
@ SC_START_OF_SIMULATION
Definition sc_main.hh:86
void sc_trace< bool >(sc_trace_file *tf, const sc_in< bool > &i, const std::string &name)
Definition sc_in.hh:318
void sc_trace(sc_trace_file *tf, const sc_in< T > &i, const std::string &name)
Definition sc_in.hh:156
void sc_trace< sc_dt::sc_logic >(sc_trace_file *tf, const sc_in< sc_dt::sc_logic > &i, const std::string &name)
Definition sc_in.hh:479
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0