| 454 | |
| 455 | template<int T, int ROWS, int COLS, int NPPC> |
| 456 | inline void Mat<T, ROWS, COLS, NPPC>::init(int _rows, int _cols, bool allocate) { |
| 457 | #pragma HLS inline |
| 458 | |
| 459 | assert((_rows > 0) && (_rows <= ROWS) && (_cols > 0) && (_cols <= COLS) |
| 460 | && "The number of rows and columns must be less than the template arguments."); |
| 461 | |
| 462 | rows = _rows; |
| 463 | cols = _cols; |
| 464 | size = _rows * (_cols >> (XF_BITSHIFT(NPPC))); |
| 465 | |
| 466 | if(allocate){ |
| 467 | #ifndef __SYNTHESIS__ |
| 468 | #ifdef __SDSCC__ |
| 469 | data = (DATATYPE*)sds_alloc_non_cacheable(rows*(cols>>(XF_BITSHIFT(NPPC)))*sizeof(DATATYPE)); |
| 470 | #else |
| 471 | data = (DATATYPE*)malloc(rows*(cols>>(XF_BITSHIFT(NPPC)))*sizeof(DATATYPE)); |
| 472 | #endif |
| 473 | |
| 474 | if (data == NULL) { |
| 475 | fprintf(stderr, "\nFailed to allocate memory\n"); |
| 476 | } else { |
| 477 | allocatedFlag = 1; |
| 478 | } |
| 479 | #else |
| 480 | //#if (defined __SDSCC__) || (defined __SYNTHESIS__) |
| 481 | //void _ssdm_op_alloc(XF_TNAME(T,NPPC)*&); |
| 482 | #ifndef __SDA_MEM_MAP__ |
| 483 | void _ssdm_op_alloc(DATATYPE *&); |
| 484 | _ssdm_op_alloc(data); |
| 485 | #endif |
| 486 | #endif |
| 487 | } |
| 488 | |
| 489 | } |
| 490 | |
| 491 | /* |
| 492 | template <int T, int ROWS, int COLS, int NPC> |
nothing calls this directly
no outgoing calls
no test coverage detected