16 #ifndef __AXI_SPLITTER_H__
17 #define __AXI_SPLITTER_H__
20 #include <nvhls_connections.h>
21 #include <nvhls_serdes.h>
22 #include <nvhls_packet.h>
23 #include <nvhls_int.h>
24 #include <nvhls_array.h>
27 #include "TypeToBits.h"
61 template <
typename axiCfg,
int numSubordinates,
int numAddrBitsToInspect = axiCfg::addrW
idth,
bool default_output = false,
bool translate_addr = false>
64 static const int kDebugLevel = 5;
66 sc_in<bool> reset_bar;
70 typedef typename axi4_::read::template manager<>::ARPort axi_rd_manager_ar;
71 typedef typename axi4_::read::template manager<>::RPort axi_rd_manager_r;
72 typedef typename axi4_::write::template manager<>::AWPort axi_wr_manager_aw;
73 typedef typename axi4_::write::template manager<>::WPort axi_wr_manager_w;
74 typedef typename axi4_::write::template manager<>::BPort axi_wr_manager_b;
86 typename axi4_::read::template subordinate<> axi_rd_m;
87 typename axi4_::write::template subordinate<> axi_wr_m;
89 sc_in<
NVUINTW(numAddrBitsToInspect)> addrBound[numSubordinates][2];
96 reset_bar(
"reset_bar"),
97 axi_rd_s_ar(
"axi_rd_s_ar"),
98 axi_rd_s_r(
"axi_rd_s_r"),
99 axi_wr_s_aw(
"axi_wr_s_aw"),
100 axi_wr_s_w(
"axi_wr_s_w"),
101 axi_wr_s_b(
"axi_wr_s_b"),
102 axi_rd_m(
"axi_rd_m"),
107 sensitive << clk.pos();
108 async_reset_signal_is(reset_bar,
false);
111 sensitive << clk.pos();
112 async_reset_signal_is(reset_bar,
false);
119 #pragma hls_unroll yes
120 for (
int i=0; i<numSubordinates; i++) {
121 axi_rd_s_ar[i].Reset();
122 axi_rd_s_r[i].Reset();
130 bool read_inFlight = 0;
131 NVUINTW(log_numSubordinates) pushedTo = numSubordinates;
133 #pragma hls_pipeline_init_interval 1
134 #pragma pipeline_stall_mode flush
138 switch (read_inFlight) {
140 if (axi_rd_m.ar.PopNB(AR_reg)) {
142 addr(
static_cast<sc_uint<numAddrBitsToInspect>
>(AR_reg.addr));
143 pushedTo = numSubordinates;
145 for (
int i=0; i<numSubordinates; i++) {
146 if (addr >= addrBound[i][0].read() && addr <= addrBound[i][1].read() && pushedTo == numSubordinates) {
150 if (default_output && pushedTo == numSubordinates) {
151 pushedTo = numSubordinates-1;
154 NVHLS_ASSERT_MSG(pushedTo != numSubordinates,
"Read address did not fall into any output address range, and default output is not set");
157 AR_reg.addr -= addrBound[pushedTo][0].read();
159 axi_rd_s_ar[pushedTo].Push(AR_reg);
164 if (axi_rd_s_r[pushedTo].PopNB(R_reg)) {
165 axi_rd_m.r.Push(R_reg);
166 if (R_reg.last == 1) read_inFlight = 0;
174 #pragma hls_unroll yes
175 for (
int i=0; i<numSubordinates; i++) {
176 axi_wr_s_aw[i].Reset();
177 axi_wr_s_w[i].Reset();
178 axi_wr_s_b[i].Reset();
188 NVUINTW(log_numSubordinates) pushedTo = numSubordinates;
196 #pragma hls_pipeline_init_interval 1
197 #pragma pipeline_stall_mode flush
203 if (axi_wr_m.aw.PopNB(AW_reg)) {
205 addr(
static_cast<sc_uint<numAddrBitsToInspect>
>(AW_reg.addr));
206 pushedTo = numSubordinates;
208 for (
int i=0; i<numSubordinates; i++) {
209 if (addr >= addrBound[i][0].read() && addr <= addrBound[i][1].read() && pushedTo == numSubordinates) {
213 if (default_output && pushedTo == numSubordinates) {
214 pushedTo = numSubordinates-1;
216 NVHLS_ASSERT_MSG(pushedTo != numSubordinates,
"Write address did not fall into any output address range, and default output is not set");
218 AW_reg.addr -= addrBound[pushedTo][0].read();
220 axi_wr_s_aw[pushedTo].Push(AW_reg);
225 NVHLS_ASSERT_MSG(pushedTo != numSubordinates,
"Write address did not fall into any output address range, and default output is not set");
226 if (axi_wr_m.w.PopNB(W_reg)) {
227 axi_wr_s_w[pushedTo].Push(W_reg);
228 if (W_reg.last == 1) {
229 if (axiCfg::useWriteResponses) {
238 if (axiCfg::useWriteResponses) {
239 if (axi_wr_s_b[pushedTo].PopNB(B_reg)) {
240 axi_wr_m.b.Push(B_reg);
245 NVHLS_ASSERT_MSG(0,
"Should never reach this state if write responses are disabled");
An n-way splitter that connects a single AXI manager port to a multiple AXI subordinate ports.
The base axi4 class parameterized according a valid config.
#define NVHLS_ASSERT_MSG(X, MSG)
NVUINTW(Wrapped< T >::width) TypeToNVUINT(T in)
Convert Type to NVUINT.
A struct composed of the signals associated with AXI read and write requests.
A struct composed of the signals associated with an AXI read response.
A struct composed of the signals associated with an AXI write response.
A struct composed of the signals associated with AXI write data.
Compute Celing of log2 of a constant.