-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quartus custom Stream & distinction between g++ (nnet::stream) and i+…
…+ (ihc::stream)
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef NNET_STREAM_H | ||
#define NNET_STREAM_H | ||
|
||
#include <deque> | ||
|
||
namespace nnet { | ||
|
||
/* | ||
* A struct with the same high-level functionality as Intel's HLS ihc::stream | ||
* This struct is used during GCC compilation / hls4ml model.predict(...) | ||
* This is because GCC does not have access to HLS source files (ihc::stream) | ||
* Software-wise, this struct behaves like a first-in, first-out (FIFO) buffer | ||
* However, it cannot be used for HLS synthesis, since it uses dynamic memory allocation (deque) | ||
*/ | ||
template<typename T> | ||
struct stream { | ||
private: | ||
std::deque<T> _data; | ||
|
||
public: | ||
stream() {} | ||
|
||
T read() { | ||
T element = _data.front(); | ||
_data.pop_front(); | ||
return element; | ||
} | ||
|
||
void write(const T& element) { | ||
_data.push_back(element); | ||
} | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters