source: trunk/soclib/soclib/communication/vci/caba/source/include/vci_initiator.h @ 2200

Revision 2163, 5.4 KB checked in by bouyer, 2 months ago (diff)

Revert previous, the warning was caused by a local change ...

Line 
1/* -*- c++ -*-
2 *
3 * SOCLIB_LGPL_HEADER_BEGIN
4 *
5 * This file is part of SoCLib, GNU LGPLv2.1.
6 *
7 * SoCLib is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; version 2.1 of the License.
10 *
11 * SoCLib is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with SoCLib; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 * SOCLIB_LGPL_HEADER_END
22 *
23 * Copyright (c) UPMC, Lip6, Asim
24 *         Nicolas Pouillon <nipo@ssji.net>, 2007
25 *
26 * Maintainers: nipo
27 */
28#ifndef SOCLIB_CABA_SIGNAL_VCI_INITIATOR_H_
29#define SOCLIB_CABA_SIGNAL_VCI_INITIATOR_H_
30
31#include <systemc>
32#include "vci_signals.h"
33#include "vci_param.h"
34
35namespace soclib { namespace caba {
36
37using namespace sc_core;
38
39/**
40 * VCI Initiator port
41 */
42template <typename vci_param>
43class VciInitiator
44{
45public:
46        sc_out<typename vci_param::ack_t>     rspack;
47        sc_in<typename vci_param::val_t>      rspval;
48        sc_in<typename vci_param::data_t>     rdata;
49        sc_in<bool>                           reop;
50        sc_in<typename vci_param::rerror_t>   rerror;
51        sc_in<typename vci_param::srcid_t>    rsrcid;
52        sc_in<typename vci_param::trdid_t >   rtrdid;
53        sc_in<typename vci_param::pktid_t >   rpktid;
54
55        sc_in<typename vci_param::ack_t>      cmdack;
56        sc_out<typename vci_param::val_t>     cmdval;
57        sc_out<typename vci_param::addr_t>    address;
58        sc_out<typename vci_param::be_t>      be;
59        sc_out<typename vci_param::cmd_t>     cmd;
60        sc_out<typename vci_param::contig_t>  contig;
61        sc_out<typename vci_param::data_t>    wdata;
62        sc_out<typename vci_param::eop_t>     eop;
63        sc_out<typename vci_param::const_t>   cons;
64        sc_out<typename vci_param::plen_t>    plen;
65        sc_out<typename vci_param::wrap_t>    wrap;
66        sc_out<typename vci_param::cfixed_t>  cfixed;
67        sc_out<typename vci_param::clen_t>    clen;
68        sc_out<typename vci_param::srcid_t>   srcid;
69        sc_out<typename vci_param::trdid_t>   trdid;
70        sc_out<typename vci_param::pktid_t>   pktid;
71
72#define __ren(x) x((name+"_" #x).c_str())
73    VciInitiator(const std::string &name = sc_gen_unique_name("vci_initiator"))
74                : __ren(rspack),
75          __ren(rspval),
76          __ren(rdata),
77          __ren(reop),
78          __ren(rerror),
79          __ren(rsrcid),
80          __ren(rtrdid),
81          __ren(rpktid),
82          __ren(cmdack),
83          __ren(cmdval),
84          __ren(address),
85          __ren(be),
86          __ren(cmd),
87          __ren(contig),
88          __ren(wdata),
89          __ren(eop),
90          __ren(cons),
91          __ren(plen),
92          __ren(wrap),
93          __ren(cfixed),
94          __ren(clen),
95          __ren(srcid),
96          __ren(trdid),
97          __ren(pktid)
98        {
99        }
100#undef __ren
101
102        void operator()(VciSignals<vci_param> &sig)
103        {
104                cmdack  (sig.cmdack);
105                address (sig.address);
106                be      (sig.be);
107                cfixed  (sig.cfixed);
108                clen    (sig.clen);
109                cmd     (sig.cmd);
110                cmdval  (sig.cmdval);
111                cons    (sig.cons);
112                contig  (sig.contig);
113                eop     (sig.eop);
114                pktid   (sig.pktid);
115                plen    (sig.plen);
116                rdata   (sig.rdata);
117                reop    (sig.reop);
118                rerror  (sig.rerror);
119                rpktid  (sig.rpktid);
120                rsrcid  (sig.rsrcid);
121                rspack  (sig.rspack);
122                rspval  (sig.rspval);
123                rtrdid  (sig.rtrdid);
124                srcid   (sig.srcid);
125                trdid   (sig.trdid);
126                wdata   (sig.wdata);
127                wrap    (sig.wrap);
128        }
129
130        void operator()(VciInitiator<vci_param> &ports)
131        {
132                cmdack  (ports.cmdack);
133                address (ports.address);
134                be      (ports.be);
135                cfixed  (ports.cfixed);
136                clen    (ports.clen);
137                cmd     (ports.cmd);
138                cmdval  (ports.cmdval);
139                cons    (ports.cons);
140                contig  (ports.contig);
141                eop     (ports.eop);
142                pktid   (ports.pktid);
143                plen    (ports.plen);
144                rdata   (ports.rdata);
145                reop    (ports.reop);
146                rerror  (ports.rerror);
147                rpktid  (ports.rpktid);
148                rsrcid  (ports.rsrcid);
149                rspack  (ports.rspack);
150                rspval  (ports.rspval);
151                rtrdid  (ports.rtrdid);
152                srcid   (ports.srcid);
153                trdid   (ports.trdid);
154                wdata   (ports.wdata);
155                wrap    (ports.wrap);
156        }
157
158    inline bool getAck() const
159    {
160        return cmdack;
161    }
162
163    inline bool getVal() const
164    {
165        return rspval;
166    }
167
168    inline void setAck( bool x )
169    {
170        rspack = x;
171    }
172
173    inline void setVal( bool x )
174    {
175        cmdval = x;
176    }
177
178    inline bool iProposed() const
179    {
180        return cmdval;
181    }
182
183    inline bool iAccepted() const
184    {
185        return rspval && rspack;
186    }
187
188    inline bool peerAccepted() const
189    {
190        return cmdval && cmdack;
191    }
192
193    inline bool toPeerEnd() const
194    {
195        return peerAccepted() && eop;
196    }
197
198    void cmdNop()
199    {
200        cmdval = false;
201    }
202
203    friend sc_core::sc_sensitive &operator <<(
204        sc_core::sc_sensitive &ss,
205        VciInitiator<vci_param> &sig )
206    {
207        ss << sig.rspval
208           << sig.rdata
209           << sig.reop
210           << sig.rerror
211           << sig.rsrcid
212           << sig.rtrdid
213           << sig.rpktid
214           << sig.cmdack;
215        return ss;
216    }
217};
218
219}}
220
221#endif /* SOCLIB_CABA_SIGNAL_VCI_INITIATOR_H_ */
222
223// Local Variables:
224// tab-width: 4
225// c-basic-offset: 4
226// c-file-offsets:((innamespace . 0)(inline-open . 0))
227// indent-tabs-mode: nil
228// End:
229
230// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
231
Note: See TracBrowser for help on using the repository browser.