68 static const int BankSelWidth =
70 static const int AddrWidth =
72 typedef NVUINTW(BankSelWidth) BankIdx;
73 typedef NVUINTW(AddrWidth) FifoIdx;
74 typedef NVUINTW(AddrWidth+1) FifoIdxPlusOne;
76 FifoIdx head[NumBanks];
77 FifoIdx tail[NumBanks];
80 bool last_action_was_push[NumBanks];
84 FifoIdx ModIncr(FifoIdx curr_idx) {
85 if (curr_idx == FifoLen - 1) {
94 for (
unsigned i = 0; i < NumBanks; i++) {
97 last_action_was_push[i] =
false;
102 void push(DataType wr_data, BankIdx bidx = 0) {
104 FifoIdx tail_local = tail[bidx];
105 fifo_body.write(tail_local, bidx, wr_data);
106 tail[bidx] = ModIncr(tail_local);
107 last_action_was_push[bidx] =
true;
111 DataType pop(BankIdx bidx = 0) {
113 FifoIdx head_local = head[bidx];
114 DataType rd_data = fifo_body.read(head_local, bidx);
115 head[bidx] = ModIncr(head_local);
116 last_action_was_push[bidx] =
false;
121 void incrHead(BankIdx bidx = 0) {
123 FifoIdx head_local = head[bidx];
124 head[bidx] = ModIncr(head_local);
125 last_action_was_push[bidx] =
false;
129 DataType peek(BankIdx bidx = 0) {
131 FifoIdx head_local = head[bidx];
132 return fifo_body.read(head_local, bidx);
135 #pragma map_to_operator [CCORE]
136 #pragma ccore_type combinational
137 bool is_equal_core(FifoIdx a1, FifoIdx a2) {
142 bool isEmpty(BankIdx bidx = 0) {
143 FifoIdx head_local = head[bidx];
144 FifoIdx tail_local = tail[bidx];
145 return is_equal_core(tail_local, head_local) && (!last_action_was_push[bidx]);
149 bool isFull(BankIdx bidx = 0) {
150 FifoIdx head_local = head[bidx];
151 FifoIdx tail_local = tail[bidx];
152 return is_equal_core(tail_local, head_local) && (last_action_was_push[bidx]);
156 FifoIdxPlusOne NumFilled(BankIdx bidx = 0) {
157 FifoIdx head_local = head[bidx];
158 FifoIdx tail_local = tail[bidx];
165 if (head_local < tail_local) {
166 return (tail_local - head_local);
168 return (FifoLen - head_local + tail_local);
173 FifoIdxPlusOne NumAvailable(BankIdx bidx = 0) {
174 return (FifoLen - NumFilled(bidx));
179#pragma hls_unroll yes
180 for (
unsigned i = 0; i < NumBanks; i++) {
183 last_action_was_push[i] =
false;
187 FifoIdx get_head(BankIdx bidx = 0) {
return head[bidx]; }
188 FifoIdx get_tail(BankIdx bidx = 0) {
return tail[bidx]; }
190 template<
unsigned int Size>
191 void Marshall(Marshaller<Size>& m) {
192 for (
unsigned i = 0; i < NumBanks; i++) {
195 for (
unsigned i = 0; i < NumBanks; i++) {
199 for (
unsigned i = 0; i < NumBanks; i++) {
200 m & last_action_was_push[i];
207class FIFO<DataType, 0, NumBanks> {
210 static const int BankSelWidth =
214 typedef NVUINTW(BankSelWidth) BankIdx;
218 void push(DataType wr_data, BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero");}
220 DataType pop(BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero");
return DataType(); }
222 void incrHead(BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero"); }
224 DataType peek(BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero");
return DataType(); }
226 bool isEmpty(BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero");
return true; }
228 bool isFull(BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero");
return true; }
230 FifoIdx NumFilled(BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero");
return 0; }
232 FifoIdx NumAvailable(BankIdx bidx = 0) {
NVHLS_ASSERT_MSG(0,
"FIFO size is zero");
return 0; }
317class FIFO<DataType, 1, NumBanks> {
318 DataType data[NumBanks];
319 bool valid[NumBanks];
320 static const int width = NumBanks * Wrapped<DataType>::width + NumBanks;
323 static const int BankSelWidth =
325 typedef NVUINTW(BankSelWidth) BankIdx;
332 inline void push(DataType wr_data, BankIdx bidx = 0) {
334 data[bidx] = wr_data;
338 inline DataType pop(BankIdx bidx = 0) {
343 inline void incrHead(BankIdx bidx = 0) {
348 inline DataType peek(BankIdx bidx = 0) {
353 inline bool isEmpty(BankIdx bidx = 0) {
357 inline bool isFull(BankIdx bidx = 0) {
361 inline T NumFilled(T bidx = 0) {
365 inline T NumAvailable(T bidx = 0) {
369 inline void reset() {
370 #pragma hls_unroll yes
371 for(
unsigned i=0; i<NumBanks; i++) {
375 template<
unsigned int Size>
376 void Marshall(Marshaller<Size>& m) {
377 for (
unsigned i = 0; i < NumBanks; i++) {
380 for (
unsigned i = 0; i < NumBanks; i++) {