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