sc_fifo_in.hh revision 13123:c86a8a2bc851
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_FIFO_IN_HH__
31#define __SYSTEMC_EXT_CHANNEL_SC_FIFO_IN_HH__
32
33#include "../core/sc_event.hh"
34#include "../core/sc_port.hh"
35#include "sc_fifo_in_if.hh"
36#include "warn_unimpl.hh"
37
38namespace sc_core
39{
40
41class sc_event;
42class sc_event_finder;
43
44template <class T>
45class sc_fifo_in : public sc_port<sc_fifo_in_if<T>, 0>
46{
47  public:
48    sc_fifo_in() : sc_port<sc_fifo_in_if<T>, 0>(),
49        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
50    {}
51    explicit sc_fifo_in(const char *name) :
52        sc_port<sc_fifo_in_if<T>, 0>(name),
53        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
54    {}
55    virtual ~sc_fifo_in() {}
56
57    // Deprecated binding constructors.
58    explicit sc_fifo_in(const sc_fifo_in_if<T> &interface) :
59        sc_port<sc_fifo_in_if<T>, 0>(interface),
60        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
61    {}
62    sc_fifo_in(const char *name, const sc_fifo_in_if<T> &interface) :
63        sc_port<sc_fifo_in_if<T>, 0>(name, interface),
64        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
65    {}
66    explicit sc_fifo_in(sc_port_b<sc_fifo_in_if<T> > &parent) :
67        sc_port<sc_fifo_in_if<T>, 0>(parent),
68        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
69    {}
70    sc_fifo_in(const char *name, sc_port_b<sc_fifo_in_if<T> > &parent) :
71        sc_port<sc_fifo_in_if<T>, 0>(name, parent),
72        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
73    {}
74    explicit sc_fifo_in(sc_port<sc_fifo_in_if<T>, 0> &parent) :
75        sc_port<sc_fifo_in_if<T>, 0>(parent),
76        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
77    {}
78    sc_fifo_in(const char *name, sc_port<sc_fifo_in_if<T>, 0> &parent) :
79        sc_port<sc_fifo_in_if<T>, 0>(name, parent),
80        _dataWrittenFinder(*this, &sc_fifo_in_if<T>::data_written_event)
81    {}
82
83    void read(T &t) { (*this)->read(t); }
84    T read() { return (*this)->read(); }
85    bool nb_read(T &t) { return (*this)->nb_read(t); }
86    const sc_event &
87    data_written_event() const
88    {
89        return (*this)->data_written_event();
90    }
91    sc_event_finder &data_written() const { return _dataWrittenFinder; }
92    int num_available() const { return (*this)->num_available(); }
93    virtual const char *kind() const { return "sc_fifo_in"; }
94
95  private:
96    // Disabled
97    sc_fifo_in(const sc_fifo_in<T> &) : sc_port<sc_fifo_in_if<T>, 0>() {}
98    sc_fifo_in<T> &operator = (const sc_fifo_in<T> &) { return *this; }
99
100    mutable sc_event_finder_t<sc_fifo_in_if<T> > _dataWrittenFinder;
101};
102
103} // namespace sc_core
104
105#endif  //__SYSTEMC_EXT_CHANNEL_SC_FIFO_IN_HH__
106