17 #ifndef __REORDERBUF_H__
18 #define __REORDERBUF_H__
21 #include <nvhls_types.h>
22 #include <mem_array.h>
23 #include <nvhls_assert.h>
67 template <
typename Data,
unsigned int Depth,
unsigned int InFlight>
75 typedef sc_uint<nvhls::index_width<InFlight>::val> Id;
82 typedef NVUINTW(InFlight) IdRepository;
85 typedef typename VBits::FifoIdx EntryNum;
90 bool get_next_avail_id(Id&
id, IdRepository& id_repository)
92 #pragma hls_unroll yes
93 for (
int i=0; i<static_cast<int>(InFlight); ++i)
95 if (id_repository[i]==0)
106 bool canAcceptRequest()
108 return ((idrep !=
static_cast<IdRepository
>(~0)) && !vbits.isFull());
114 bool success = get_next_avail_id(
id, idrep);
117 id2entry.write(
static_cast<typename Id2Entry::LocalIndex
>(
id), 0, vbits.get_tail());
123 bool topResponseReady()
132 void addResponse(
const Id&
id,
const Data& data)
134 EntryNum entryNum = id2entry.read(
static_cast<typename Id2Entry::LocalIndex
>(
id), 0);
135 storage.write(entryNum, 0, data);
136 vbits.fifo_body.write(
static_cast<typename VBits::FifoIdx
>(entryNum), 0,
true);
138 idrep[
static_cast<int>(id)]=0;
145 Data result = storage.read( vbits.get_head(), 0);
159 return vbits.isEmpty();
Reorder Buffer that allows out-of-order writes to queue and in-order reads.
#define NVHLS_ASSERT_MSG(X, MSG)