20 return nsukitStatus_t::NSUKIT_STATUS_ACCEPT_FAIL;
25 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
33 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
40 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
68 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
80 auto st = std::chrono::high_resolution_clock::now();
84 std::this_thread::sleep_for(std::chrono::milliseconds(5));
87 auto _use_time = (double )(std::chrono::high_resolution_clock::now()-st).count() * 1e-9;
90 return nsukitStatus_t::NSUKIT_STATUS_TIMEOUT;
99 if (size <= 0)
return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
100 if (buf ==
nullptr)
return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
102 auto res = nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
111 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
117 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
121 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
127 std::this_thread::sleep_for(std::chrono::milliseconds(5));
129 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
133 unsigned int cnt = 0;
135 std::this_thread::sleep_for(std::chrono::milliseconds(5));
137 if (cnt >= 30*1000*10 -1){
138 return nsukitStatus_t::NSUKIT_STATUS_TIMEOUT;
144 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
173 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
182 if ((chnl >= maxChnl) || (length % byteWidth != 0) || (offset % byteWidth != 0)) {
183 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
186 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
190 return nsukitStatus_t::NSUKIT_STATUS_STREAM_FAIL;
195 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
200 if ((chnl >= maxChnl) || (length % byteWidth != 0) || (offset % byteWidth != 0)) {
201 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
204 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
208 return nsukitStatus_t::NSUKIT_STATUS_STREAM_FAIL;
213 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
220 if (process ==
nullptr) {
221 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
224 process->
current = res*byteWidth;
226 return nsukitStatus_t::NSUKIT_STATUS_STREAM_RUNNING;
228 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
235 if (process ==
nullptr) {
236 return nsukitStatus_t::NSUKIT_STATUS_INVALID_VALUE;
240 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
245 bool(*stop_event) (),
float timeout,
int flag) {
247 if (stop_event ==
nullptr) {
248 stop_event = []() {
return false; };
253 return nsukitStatus_t::NSUKIT_STATUS_STREAM_FAIL;
258 if (res == nsukitStatus_t::NSUKIT_STATUS_SUCCESS) {
266 bool(*stop_event) (),
float timeout,
int flag) {
268 if (stop_event ==
nullptr) {
269 stop_event = []() {
return false; };
274 return nsukitStatus_t::NSUKIT_STATUS_STREAM_FAIL;
279 if (res == nsukitStatus_t::NSUKIT_STATUS_SUCCESS) {
310 mem->mem_size = length;
311 mem->finish_event.setEvent();
321 if (!mem->finish_event.isSet()) {
322 return nsukitStatus_t::NSUKIT_STATUS_STREAM_RUNNING;
324 mem->finish_event.resetEvent();
327 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
333 std::unique_lock<std::mutex> lock(mem->mtx);
340 auto res = nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
343 return nsukitStatus_t::NSUKIT_STATUS_STREAM_FAIL;
345 DEBUG_PRINT_CLASS(
"chnl="+std::to_string(chnl)+
", length="+std::to_string(length));
347 std::unique_lock<std::mutex> lock(mem->mtx);
363 std::unique_lock<std::mutex> lock(mem->mtx);
367 if (buffer ==
nullptr) {
371 return nsukitStatus_t::NSUKIT_STATUS_STREAM_RUNNING;
373 mem->memory = buffer;
375 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
382 std::unique_lock<std::mutex> lock(mem->mtx);
383 if (mem->ring ==
nullptr) {
384 return nsukitStatus_t::NSUKIT_STATUS_STREAM_FAIL;
389 return nsukitStatus_t::NSUKIT_STATUS_SUCCESS;
nsukitStatus_t increment_read(nsuRegAddr_t addr, nsuSize_t length, nsuVoidBuf_p value, nsuSize_t reg_len=NSU_REG_BWIDTH)
nsukitStatus_t increment_write(nsuRegAddr_t addr, nsuVoidBuf_p value, nsuSize_t length, nsuSize_t reg_len=NSU_REG_BWIDTH)
nsukitStatus_t close() override
nsukitStatus_t write(nsuRegAddr_t addr, nsuRegValue_t value) override
nsukitStatus_t accept(nsuInitParam_t *param) override
static unsigned int irqNum
nsukitStatus_t read(nsuRegAddr_t addr, nsuRegValue_t *buf) override
nsukitStatus_t set_timeout(float s) override
nsuRegAddr_t sentDownBase
nsukitStatus_t reset_irq()
nsukitStatus_t recv_bytes(nsuSize_t size, nsuCharBuf_p buf) override
nsukitStatus_t per_recv()
nsukitStatus_t send_bytes(nsuBytes_t &bytes) override
std::map< uint32_t, HANDLE > ringCache
nsukitStatus_t close() override
nsuVoidBuf_p get_buffer(nsuMemory_p fd, nsuStreamLen_t length) override
nsuMemory_p alloc_buffer(nsuStreamLen_t length, nsuVoidBuf_p buf=nullptr) override
nsukitStatus_t free_buffer(nsuMemory_p fd) override
nsukitStatus_t break_stream(nsuMemory_p fd) override
std::map< unsigned int, Memory * > memory_dict
nsukitStatus_t open_recv(nsuChnlNum_t chnl, nsuMemory_p fd, nsuStreamLen_t length, nsuStreamLen_t offset=0) override
nsukitStatus_t accept(nsuInitParam_t *param) override
nsukitStatus_t wait_stream(nsuMemory_p fd, float timeout=1.) override
unsigned int memory_index
nsukitStatus_t open_recv(nsuChnlNum_t chnl, nsuMemory_p fd, nsuStreamLen_t length, nsuStreamLen_t offset=0) override
nsukitStatus_t stream_recv(nsuChnlNum_t chnl, nsuMemory_p fd, nsuStreamLen_t length, nsuStreamLen_t offset=0, bool(*stop_event)()=nullptr, float timeout=5., int flag=1) override
nsuVoidBuf_p get_buffer(nsuMemory_p fd, nsuStreamLen_t length) override
nsukitStatus_t stream_send(nsuChnlNum_t chnl, nsuMemory_p fd, nsuStreamLen_t length, nsuStreamLen_t offset=0, bool(*stop_event)()=nullptr, float timeout=5., int flag=1) override
nsukitStatus_t accept(nsuInitParam_t *param) override
nsuMemory_p alloc_buffer(nsuStreamLen_t length, nsuVoidBuf_p buf=nullptr) override
nsukitStatus_t free_buffer(nsuMemory_p fd) override
std::map< nsuMemory_p, StreamProcess > downloadProcess
nsukitStatus_t break_stream(nsuMemory_p fd) override
nsukitStatus_t set_timeout(float s) override
std::map< nsuMemory_p, StreamProcess > uploadProcess
nsukitStatus_t open_send(nsuChnlNum_t chnl, nsuMemory_p fd, nsuStreamLen_t length, nsuStreamLen_t offset=0) override
nsukitStatus_t close() override
nsukitStatus_t wait_stream(nsuMemory_p fd, float timeout=1.) override
virtual nsukitStatus_t set_timeout(float s)
nsukitStatus_t close_xdma_board(int board)
nsukitStatus_t open_xdma_board(int board)
std::map< int, int > openedBoard
#define DEBUG_PRINT_CLASS(message)
static XDMAOperation_t xdmaOp
std::map< nsuChnlNum_t, nsuSize_t > ring_chnl_size
nsuRegAddr_t cmd_irq_base
nsuRegAddr_t cmd_sent_down_base
nsuRegAddr_t cmd_sent_base
nsuBoardNum_t stream_board
nsuRegAddr_t cmd_recv_base
DLLEXTERN typedef nsuSize_t nsuStreamLen_t
DLLEXTERN typedef size_t nsuSize_t
DLLEXTERN typedef void * nsuVoidBuf_p
DLLEXTERN typedef void * nsuMemory_p
DLLEXTERN typedef char * nsuCharBuf_p
DLLEXTERN typedef std::vector< char > nsuBytes_t
DLLEXTERN typedef uint32_t nsuRegValue_t
DLLEXTERN typedef uint8_t nsuChnlNum_t
DLLEXTERN typedef uint32_t nsuRegAddr_t
DLLEXPORT HANDLE _API_CALL fpga_ring_create(unsigned int boardn, unsigned int chnl, unsigned int c2h, unsigned long long len32)
DLLEXPORT void _API_CALL fpga_free_dma(HANDLE dma)
DLLEXPORT void _API_CALL fpga_close(unsigned int boardn)
DLLEXPORT unsigned long long _API_CALL fpga_send(unsigned int boardn, unsigned int chnl, HANDLE dma, unsigned long long len32, unsigned long long offset=0, unsigned int last=1, unsigned int mm_addr=0, unsigned int mm_addr_inc=0, unsigned int timeout=DMA_WAIT_FOR_EVER)
DLLEXPORT void _API_CALL fpga_ring_close(HANDLE ring)
DLLEXPORT unsigned int _API_CALL fpga_rd_lite(unsigned int boardn, unsigned int addr8)
DLLEXPORT HANDLE _API_CALL fpga_alloc_dma(unsigned int boardn, unsigned long long len32, void *buffer=NULL, HANDLE share_dma=NULL)
DLLEXPORT void _API_CALL fpga_wr_lite(unsigned int boardn, unsigned int addr8, unsigned int data)
DLLEXPORT unsigned long long _API_CALL fpga_recv(unsigned int boardn, unsigned int chnl, HANDLE dma, unsigned long long len32, unsigned long long offset=0, unsigned int last=1, unsigned int mm_addr=0, unsigned int mm_addr_inc=0, unsigned int timeout=DMA_WAIT_FOR_EVER)
DLLEXPORT unsigned long long _API_CALL fpga_break_dma(HANDLE dma)
DLLEXPORT char *_API_CALL fpga_info_string(unsigned int boardn)
DLLEXPORT void _API_CALL fpga_ring_resume(HANDLE ring)
DLLEXPORT void *_API_CALL fpga_ring_next_buffer(HANDLE ring, unsigned long long len32, int timeout)
DLLEXPORT void * fpga_get_dma_buffer(HANDLE dma)
DLLEXPORT bool _API_CALL fpga_open(unsigned int boardn, unsigned int poll_interval_ms=0, unsigned int test_print=0)
DLLEXPORT unsigned long long _API_CALL fpga_wait_dma(HANDLE dma, unsigned int timeout=DMA_WAIT_FOR_EVER)