| 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_TARGET_H_ |
|---|
| 29 | #define SOCLIB_CABA_SIGNAL_VCI_TARGET_H_ |
|---|
| 30 | |
|---|
| 31 | #include <systemc> |
|---|
| 32 | #include "vci_param.h" |
|---|
| 33 | #include "vci_signals.h" |
|---|
| 34 | |
|---|
| 35 | namespace soclib { |
|---|
| 36 | namespace caba { |
|---|
| 37 | |
|---|
| 38 | using namespace sc_core; |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | * VCI Target port |
|---|
| 42 | */ |
|---|
| 43 | template <typename vci_param> |
|---|
| 44 | class VciTarget |
|---|
| 45 | { |
|---|
| 46 | public: |
|---|
| 47 | sc_in<typename vci_param::ack_t> rspack; |
|---|
| 48 | sc_out<typename vci_param::val_t> rspval; |
|---|
| 49 | sc_out<typename vci_param::data_t> rdata; |
|---|
| 50 | sc_out<bool> reop; |
|---|
| 51 | sc_out<typename vci_param::rerror_t> rerror; |
|---|
| 52 | sc_out<typename vci_param::srcid_t> rsrcid; |
|---|
| 53 | sc_out<typename vci_param::trdid_t > rtrdid; |
|---|
| 54 | sc_out<typename vci_param::pktid_t > rpktid; |
|---|
| 55 | |
|---|
| 56 | sc_out<typename vci_param::ack_t> cmdack; |
|---|
| 57 | sc_in<typename vci_param::val_t> cmdval; |
|---|
| 58 | sc_in<typename vci_param::addr_t> address; |
|---|
| 59 | sc_in<typename vci_param::be_t> be; |
|---|
| 60 | sc_in<typename vci_param::cmd_t> cmd; |
|---|
| 61 | sc_in<typename vci_param::contig_t> contig; |
|---|
| 62 | sc_in<typename vci_param::data_t> wdata; |
|---|
| 63 | sc_in<typename vci_param::eop_t> eop; |
|---|
| 64 | sc_in<typename vci_param::const_t> cons; |
|---|
| 65 | sc_in<typename vci_param::plen_t> plen; |
|---|
| 66 | sc_in<typename vci_param::wrap_t> wrap; |
|---|
| 67 | sc_in<typename vci_param::cfixed_t> cfixed; |
|---|
| 68 | sc_in<typename vci_param::clen_t> clen; |
|---|
| 69 | sc_in<typename vci_param::srcid_t> srcid; |
|---|
| 70 | sc_in<typename vci_param::trdid_t> trdid; |
|---|
| 71 | sc_in<typename vci_param::pktid_t> pktid; |
|---|
| 72 | |
|---|
| 73 | #define __ren(x) x((name+"_" #x).c_str()) |
|---|
| 74 | VciTarget(const std::string &name = sc_gen_unique_name("vci_target")) |
|---|
| 75 | : __ren(rspack), |
|---|
| 76 | __ren(rspval), |
|---|
| 77 | __ren(rdata), |
|---|
| 78 | __ren(reop), |
|---|
| 79 | __ren(rerror), |
|---|
| 80 | __ren(rsrcid), |
|---|
| 81 | __ren(rtrdid), |
|---|
| 82 | __ren(rpktid), |
|---|
| 83 | __ren(cmdack), |
|---|
| 84 | __ren(cmdval), |
|---|
| 85 | __ren(address), |
|---|
| 86 | __ren(be), |
|---|
| 87 | __ren(cmd), |
|---|
| 88 | __ren(contig), |
|---|
| 89 | __ren(wdata), |
|---|
| 90 | __ren(eop), |
|---|
| 91 | __ren(cons), |
|---|
| 92 | __ren(plen), |
|---|
| 93 | __ren(wrap), |
|---|
| 94 | __ren(cfixed), |
|---|
| 95 | __ren(clen), |
|---|
| 96 | __ren(srcid), |
|---|
| 97 | __ren(trdid), |
|---|
| 98 | __ren(pktid) |
|---|
| 99 | { |
|---|
| 100 | } |
|---|
| 101 | #undef __ren |
|---|
| 102 | |
|---|
| 103 | void operator()(VciSignals<vci_param> &sig) |
|---|
| 104 | { |
|---|
| 105 | cmdack (sig.cmdack); |
|---|
| 106 | address (sig.address); |
|---|
| 107 | be (sig.be); |
|---|
| 108 | cfixed (sig.cfixed); |
|---|
| 109 | clen (sig.clen); |
|---|
| 110 | cmd (sig.cmd); |
|---|
| 111 | cmdval (sig.cmdval); |
|---|
| 112 | cons (sig.cons); |
|---|
| 113 | contig (sig.contig); |
|---|
| 114 | eop (sig.eop); |
|---|
| 115 | pktid (sig.pktid); |
|---|
| 116 | plen (sig.plen); |
|---|
| 117 | rdata (sig.rdata); |
|---|
| 118 | reop (sig.reop); |
|---|
| 119 | rerror (sig.rerror); |
|---|
| 120 | rpktid (sig.rpktid); |
|---|
| 121 | rsrcid (sig.rsrcid); |
|---|
| 122 | rspack (sig.rspack); |
|---|
| 123 | rspval (sig.rspval); |
|---|
| 124 | rtrdid (sig.rtrdid); |
|---|
| 125 | srcid (sig.srcid); |
|---|
| 126 | trdid (sig.trdid); |
|---|
| 127 | wdata (sig.wdata); |
|---|
| 128 | wrap (sig.wrap); |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | void operator()(VciTarget<vci_param> &ports) |
|---|
| 132 | { |
|---|
| 133 | cmdack (ports.cmdack); |
|---|
| 134 | address (ports.address); |
|---|
| 135 | be (ports.be); |
|---|
| 136 | cfixed (ports.cfixed); |
|---|
| 137 | clen (ports.clen); |
|---|
| 138 | cmd (ports.cmd); |
|---|
| 139 | cmdval (ports.cmdval); |
|---|
| 140 | cons (ports.cons); |
|---|
| 141 | contig (ports.contig); |
|---|
| 142 | eop (ports.eop); |
|---|
| 143 | pktid (ports.pktid); |
|---|
| 144 | plen (ports.plen); |
|---|
| 145 | rdata (ports.rdata); |
|---|
| 146 | reop (ports.reop); |
|---|
| 147 | rerror (ports.rerror); |
|---|
| 148 | rpktid (ports.rpktid); |
|---|
| 149 | rsrcid (ports.rsrcid); |
|---|
| 150 | rspack (ports.rspack); |
|---|
| 151 | rspval (ports.rspval); |
|---|
| 152 | rtrdid (ports.rtrdid); |
|---|
| 153 | srcid (ports.srcid); |
|---|
| 154 | trdid (ports.trdid); |
|---|
| 155 | wdata (ports.wdata); |
|---|
| 156 | wrap (ports.wrap); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | inline bool getAck() const |
|---|
| 160 | { |
|---|
| 161 | return rspack; |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | inline bool getVal() const |
|---|
| 165 | { |
|---|
| 166 | return cmdval; |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | inline void setAck( bool x ) |
|---|
| 170 | { |
|---|
| 171 | cmdack = x; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | inline void setVal( bool x ) |
|---|
| 175 | { |
|---|
| 176 | rspval = x; |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | inline bool iProposed() const |
|---|
| 180 | { |
|---|
| 181 | return rspval; |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | inline bool iAccepted() const |
|---|
| 185 | { |
|---|
| 186 | return cmdval && cmdack; |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | inline bool peerAccepted() const |
|---|
| 190 | { |
|---|
| 191 | return rspval && rspack; |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | inline bool toPeerEnd() const |
|---|
| 195 | { |
|---|
| 196 | return peerAccepted() && reop; |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | void rspSetIds( typename vci_param::srcid_t srcid, |
|---|
| 200 | typename vci_param::trdid_t trdid, |
|---|
| 201 | typename vci_param::pktid_t pktid ) |
|---|
| 202 | { |
|---|
| 203 | rsrcid = srcid; |
|---|
| 204 | rtrdid = trdid; |
|---|
| 205 | rpktid = pktid; |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | void rspError( bool eop ) |
|---|
| 209 | { |
|---|
| 210 | rspval = true; |
|---|
| 211 | rdata = 0; |
|---|
| 212 | rerror = true; |
|---|
| 213 | reop = eop; |
|---|
| 214 | } |
|---|
| 215 | void rspRead( bool eop, typename vci_param::data_t data ) |
|---|
| 216 | { |
|---|
| 217 | rspval = true; |
|---|
| 218 | rdata = data; |
|---|
| 219 | rerror = false; |
|---|
| 220 | reop = eop; |
|---|
| 221 | } |
|---|
| 222 | inline void rspWrite( bool eop ) |
|---|
| 223 | { |
|---|
| 224 | rspRead(eop, 0); |
|---|
| 225 | } |
|---|
| 226 | void rspNop() |
|---|
| 227 | { |
|---|
| 228 | rspval = false; |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | friend sc_core::sc_sensitive &operator <<( |
|---|
| 232 | sc_core::sc_sensitive &ss, |
|---|
| 233 | VciTarget<vci_param> &sig ) |
|---|
| 234 | { |
|---|
| 235 | ss << sig.rspack |
|---|
| 236 | << sig.cmdval |
|---|
| 237 | << sig.address |
|---|
| 238 | << sig.be |
|---|
| 239 | << sig.cmd |
|---|
| 240 | << sig.contig |
|---|
| 241 | << sig.wdata |
|---|
| 242 | << sig.eop |
|---|
| 243 | << sig.cons |
|---|
| 244 | << sig.plen |
|---|
| 245 | << sig.wrap |
|---|
| 246 | << sig.cfixed |
|---|
| 247 | << sig.clen |
|---|
| 248 | << sig.srcid |
|---|
| 249 | << sig.trdid |
|---|
| 250 | << sig.pktid; |
|---|
| 251 | return ss; |
|---|
| 252 | } |
|---|
| 253 | }; |
|---|
| 254 | |
|---|
| 255 | }} |
|---|
| 256 | |
|---|
| 257 | #endif /* SOCLIB_CABA_SIGNAL_VCI_TARGET_H_ */ |
|---|
| 258 | |
|---|
| 259 | // Local Variables: |
|---|
| 260 | // tab-width: 4 |
|---|
| 261 | // c-basic-offset: 4 |
|---|
| 262 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
|---|
| 263 | // indent-tabs-mode: nil |
|---|
| 264 | // End: |
|---|
| 265 | |
|---|
| 266 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 267 | |
|---|