21 #include <nvhls_connections.h> 22 #include <nvhls_assert.h> 23 #include <nvhls_message.h> 24 #include <nvhls_module.h> 26 #include <UIntOrEmpty.h> 28 #include <axi/axi4_encoding.h> 29 #include <axi/axi4_configs.h> 57 template <
typename Cfg>
63 DATA_WIDTH = Cfg::dataWidth,
64 ADDR_WIDTH = Cfg::addrWidth,
65 ID_WIDTH = Cfg::idWidth,
66 BID_WIDTH = (Cfg::useWriteResponses == 0 ? 0 : Cfg::idWidth),
69 ASIZE_WIDTH = (Cfg::useVariableBeatSize != 0 ? 3 : 0),
70 LAST_WIDTH = (Cfg::useLast != 0 ? 1 : 0),
71 CACHE_WIDTH = (Cfg::useCache != 0 ? Enc::ARCACHE::_WIDTH : 0),
72 BURST_WIDTH = ((Cfg::useBurst != 0 &&
73 (Cfg::useFixedBurst != 0 || Cfg::useWrapBurst != 0))
74 ? Enc::AXBURST::_WIDTH
76 WSTRB_WIDTH = (Cfg::useWriteStrobes != 0 ? (DATA_WIDTH >> 3) : 0),
77 RESP_WIDTH = Enc::XRESP::_WIDTH,
82 AUSER_WIDTH = Cfg::aUserWidth,
83 WUSER_WIDTH = Cfg::wUserWidth,
84 BUSER_WIDTH = (Cfg::useWriteResponses == 0 ? 0 : Cfg::bUserWidth),
85 RUSER_WIDTH = Cfg::rUserWidth,
88 typedef NVUINTW(ADDR_WIDTH) Addr;
89 typedef NVUINTW(DATA_WIDTH) Data;
90 typedef typename nvhls::UIntOrEmpty<ID_WIDTH>::T Id;
91 typedef typename nvhls::UIntOrEmpty<BID_WIDTH>::T BId;
92 typedef typename nvhls::UIntOrEmpty<ALEN_WIDTH>::T BeatNum;
93 typedef typename nvhls::UIntOrEmpty<ASIZE_WIDTH>::T BeatSize;
94 typedef typename nvhls::UIntOrEmpty<LAST_WIDTH>::T Last;
95 typedef typename nvhls::UIntOrEmpty<WSTRB_WIDTH>::T Wstrb;
96 typedef typename nvhls::UIntOrEmpty<CACHE_WIDTH>::T Cache;
97 typedef typename nvhls::UIntOrEmpty<BURST_WIDTH>::T Burst;
98 typedef NVUINTW(RESP_WIDTH) Resp;
100 typedef typename nvhls::UIntOrEmpty<AUSER_WIDTH>::T AUser;
101 typedef typename nvhls::UIntOrEmpty<WUSER_WIDTH>::T WUser;
102 typedef typename nvhls::UIntOrEmpty<BUSER_WIDTH>::T BUser;
103 typedef typename nvhls::UIntOrEmpty<RUSER_WIDTH>::T RUser;
117 static const unsigned int width = ADDR_WIDTH + ID_WIDTH + ALEN_WIDTH +
118 ASIZE_WIDTH + BURST_WIDTH + CACHE_WIDTH +
137 template <
unsigned int Size>
138 void Marshall(Marshaller<Size> &m) {
148 #ifdef CONNECTIONS_SIM_ONLY 149 inline friend void sc_trace(sc_trace_file *tf,
const AddrPayload& v,
const std::string& NAME ) {
150 sc_trace(tf,v.id, NAME +
".id");
151 sc_trace(tf,v.addr, NAME +
".addr");
152 sc_trace(tf,v.len, NAME +
".len");
156 inline friend std::ostream& operator<<(ostream& os,
const AddrPayload& rhs)
159 os << dec <<
"id:" << rhs.id <<
" ";
160 os << hex <<
"addr:" << rhs.addr <<
" ";
162 os << dec <<
"len:" << rhs.len <<
" ";
164 os << dec <<
"size:" << rhs.size <<
" ";
166 os << dec <<
"burst:" << rhs.burst <<
" ";
168 os << dec <<
"cache:" << rhs.cache <<
" ";
170 os << hex <<
"auser:" << rhs.auser <<
" ";
187 static const unsigned int width =
188 DATA_WIDTH + RESP_WIDTH + ID_WIDTH + LAST_WIDTH + RUSER_WIDTH;
201 template <
unsigned int Size>
202 void Marshall(Marshaller<Size> &m) {
210 #ifdef CONNECTIONS_SIM_ONLY 211 inline friend void sc_trace(sc_trace_file *tf,
const ReadPayload& v,
const std::string& NAME ) {
212 sc_trace(tf,v.id, NAME +
".id");
213 sc_trace(tf,v.data, NAME +
".data");
214 sc_trace(tf,v.last, NAME +
".last");
218 inline friend std::ostream& operator<<(ostream& os,
const ReadPayload& rhs)
221 os << dec <<
"id:" << rhs.id <<
" ";
222 os << hex <<
"data:" << rhs.data <<
" ";
223 os << dec <<
"resp:" << rhs.resp <<
" ";
225 os << dec <<
"last:" << rhs.last <<
" ";
227 os << hex <<
"user:" << rhs.ruser <<
" ";
241 static const unsigned int width = RESP_WIDTH + BID_WIDTH + BUSER_WIDTH;
251 template <
unsigned int Size>
252 void Marshall(Marshaller<Size> &m) {
258 #ifdef CONNECTIONS_SIM_ONLY 259 inline friend void sc_trace(sc_trace_file *tf,
const WRespPayload& v,
const std::string& NAME ) {
260 sc_trace(tf,v.id, NAME +
".id");
261 sc_trace(tf,v.resp, NAME +
".resp");
265 inline friend std::ostream& operator<<(ostream& os,
const WRespPayload& rhs)
268 os << dec <<
"id:" << rhs.id <<
" ";
269 os << dec <<
"resp:" << rhs.resp <<
" ";
271 os << hex <<
"buser:" << rhs.buser <<
" ";
296 static const unsigned int width =
297 DATA_WIDTH + LAST_WIDTH + WSTRB_WIDTH + WUSER_WIDTH;
299 template <
unsigned int Size>
300 void Marshall(Marshaller<Size> &m) {
307 #ifdef CONNECTIONS_SIM_ONLY 308 inline friend void sc_trace(sc_trace_file *tf,
const WritePayload& v,
const std::string& NAME ) {
309 sc_trace(tf,v.data, NAME +
".data");
310 sc_trace(tf,v.last, NAME +
".last");
311 sc_trace(tf,v.wstrb, NAME +
".wstrb");
315 inline friend std::ostream& operator<<(ostream& os,
const WritePayload& rhs)
317 os << hex <<
"data:" << rhs.data <<
" ";
319 os << dec <<
"last:" << rhs.last <<
" ";
321 os << hex <<
"wstrb:" << rhs.wstrb <<
" ";
323 os << hex <<
"wuser:" << rhs.wuser <<
" ";
339 template <Connections::connections_port_t PortType = AUTO_PORT>
342 typedef Connections::Combinational<AddrPayload, PortType> ARChan;
343 typedef Connections::Combinational<ReadPayload, PortType> RChan;
348 chan(
const char *name)
357 template <Connections::connections_port_t PortType = AUTO_PORT>
360 typedef Connections::Out<AddrPayload, PortType> ARPort;
361 typedef Connections::In<ReadPayload, PortType> RPort;
381 void operator()(C &c) {
390 template <Connections::connections_port_t PortType = AUTO_PORT>
393 typedef Connections::In<AddrPayload, PortType> ARPort;
394 typedef Connections::Out<ReadPayload, PortType> RPort;
399 slave(
const char *name)
409 bool nb_aread(
AddrPayload &addr) {
return ar.PopNB(addr); }
411 void rwrite(
const ReadPayload &data) { r.Push(data); }
413 bool nb_rwrite(
const ReadPayload &data) {
return r.PushNB(data); }
416 void operator()(C &c) {
434 template <Connections::connections_port_t PortType = AUTO_PORT>
437 typedef Connections::Combinational<AddrPayload, PortType> AWChan;
438 typedef Connections::Combinational<WritePayload, PortType> WChan;
439 typedef Connections::Combinational<WRespPayload, PortType> BChan;
445 chan(
const char *name)
456 template <Connections::connections_port_t PortType = AUTO_PORT>
459 typedef Connections::Out<AddrPayload, PortType> AWPort;
460 typedef Connections::Out<WritePayload, PortType> WPort;
461 typedef Connections::In<WRespPayload, PortType> BPort;
486 void operator()(C &c) {
496 template <Connections::connections_port_t PortType = AUTO_PORT>
499 typedef Connections::In<AddrPayload, PortType> AWPort;
500 typedef Connections::In<WritePayload, PortType> WPort;
501 typedef Connections::Out<WRespPayload, PortType> BPort;
510 slave(
const char *name)
529 if (!aw.PopNB(addr)) {
549 bool nb_bwrite(
const WRespPayload &resp) {
return b.PushNB(resp); }
552 void operator()(C &c) {
#define nvhls_concat(s1, s2)
nvhls_concat define: Concatenate two strings, separate with an underscore.Useful for concatenating tw...
A struct composed of the signals associated with an AXI write response.
The AXI read channel, used for connecting an AXI master and AXI slave.
A struct composed of the signals associated with AXI write data.
A struct composed of the signals associated with AXI read and write requests.
The AXI read slave port. This port has an AR request channel as input and an R response channel as ou...
The AXI write channel, used for connecting an AXI master and AXI slave.
A struct composed of the signals associated with an AXI read response.
The AXI write master port. This port has AW and W request channels as outputs and a B response channe...
The base axi4 class parameterized according a valid config.
Compute Celing of log2 of a constant.
The AXI read master port. This port has an AR request channel as output and an R response channel as ...
Hardcoded values associated with the AXI4 standard.
The AXI write slave port. This port has AW and W request channels as inputs and a B response channel ...
The axi namespace contains classes and definitions related to the AXI standard.