21 #ifndef COMBINATIONAL_BUFFERED_PORTS_H_
22 #define COMBINATIONAL_BUFFERED_PORTS_H_
24 #include <nvhls_connections.h>
26 namespace Connections {
28 template <
typename Message,
int BufferSizeRead = 1,
int BufferSizeWrite = 1>
36 : Combinational<Message>(),
42 : Combinational<Message>(name),
48 Combinational<Message>::ResetRead();
53 Combinational<Message>::ResetWrite();
58 bool EmptyRead() {
return fifo_read.isEmpty(); }
60 Message Pop() {
return fifo_read.pop(); }
62 void IncrHeadRead() { fifo_read.incrHead(); }
64 Message PeekRead() {
return fifo_read.peek(); }
66 void TransferNBRead() {
67 if (!fifo_read.isFull()) {
69 if (Combinational<Message>::PopNB(msg)) {
76 bool FullWrite() {
return fifo_write.isFull(); }
78 bool EmptyWrite() {
return fifo_write.isEmpty(); }
80 AddressPlusOne NumAvailableWrite() {
return fifo_write.NumAvailable(); }
82 void Push(
const Message& msg) { fifo_write.push(msg); }
84 void TransferNBWrite() {
85 if (!fifo_write.isEmpty()) {
86 Message msg = fifo_write.peek();
87 if (Combinational<Message>::PushNB(msg)) {
94 virtual bool PopNB(Message& data) {
NVHLS_ASSERT_MSG(0,
"Calling PopNB on Buffered port is not valid");
return false; }
95 virtual bool PushNB(
const Message& m) {
NVHLS_ASSERT_MSG(0,
"Calling PushNB on Buffered port is not valid");
return false; }
99 template <
typename Message,
int BufferSizeRead>
105 : Combinational<Message>(),
110 : Combinational<Message>(name),
115 Combinational<Message>::ResetRead();
120 bool EmptyRead() {
return fifo_read.isEmpty(); }
122 Message Pop() {
return fifo_read.pop(); }
124 void IncrHeadRead() { fifo_read.incrHead(); }
126 Message PeekRead() {
return fifo_read.peek(); }
128 void TransferNBRead() {
129 if (!fifo_read.isFull()) {
131 if (Combinational<Message>::PopNB(msg)) {
138 virtual bool PopNB(Message& data) {
NVHLS_ASSERT_MSG(0,
"Calling PopNB on Buffered port is not valid");
return false; }
141 template <
typename Message,
int BufferSizeWrite>
148 : Combinational<Message>(),
153 : Combinational<Message>(name),
158 Combinational<Message>::ResetWrite();
163 bool FullWrite() {
return fifo_write.isFull(); }
165 bool EmptyWrite() {
return fifo_write.isEmpty(); }
167 AddressPlusOne NumAvailableWrite() {
return fifo_write.NumAvailable(); }
169 void Push(
const Message& msg) { fifo_write.push(msg); }
171 void TransferNBWrite() {
172 if (!fifo_write.isEmpty()) {
173 Message msg = fifo_write.peek();
174 if (Combinational<Message>::PushNB(msg)) {
181 virtual bool PushNB(
const Message& m) {
NVHLS_ASSERT_MSG(0,
"Calling PushNB on Buffered port is not valid");
return false; }
#define NVHLS_ASSERT_MSG(X, MSG)
Compute index width of a constant.