#define VTA_MAX_XFER (1<<22)
#endif
+/*! PAGE SIZE */
+#define VTA_PAGE_BITS 12
+#define VTA_PAGE_BYTES (1 << VTA_PAGE_BITS)
+
/*! \brief Device resource context */
typedef void * VTADeviceHandle;
}
uint32_t GetElemBytes(uint32_t memory_id) {
+ uint32_t elem_bytes = 0;
switch (memory_id) {
- case VTA_MEM_ID_UOP: return VTA_UOP_ELEM_BYTES;
- case VTA_MEM_ID_INP: return VTA_INP_ELEM_BYTES;
- case VTA_MEM_ID_WGT: return VTA_WGT_ELEM_BYTES;
- case VTA_MEM_ID_ACC: return VTA_ACC_ELEM_BYTES;
- case VTA_MEM_ID_OUT: return VTA_INP_ELEM_BYTES;
- default: break;
+ case VTA_MEM_ID_UOP:
+ elem_bytes = VTA_UOP_ELEM_BYTES;
+ break;
+ case VTA_MEM_ID_INP:
+ elem_bytes = VTA_INP_ELEM_BYTES;
+ break;
+ case VTA_MEM_ID_WGT:
+ elem_bytes = VTA_WGT_ELEM_BYTES;
+ break;
+ case VTA_MEM_ID_ACC:
+ elem_bytes = VTA_ACC_ELEM_BYTES;
+ break;
+ case VTA_MEM_ID_OUT:
+ elem_bytes = VTA_INP_ELEM_BYTES;
+ break;
+ default:
+ LOG(FATAL) << "Memory id not recognized:" << memory_id;
+ break;
}
- LOG(FATAL) << "Memory id not recognized:" << memory_id;
- return 0;
+ /*
+ * elements size should not larger than VTA_PAGE_BYTES.
+ *
+ */
+ CHECK_GE(VTA_PAGE_BYTES, elem_bytes);
+ return elem_bytes;
}
void LoadBuffer2D(void* src_dram_addr,
private:
// The bits in page table
- static constexpr vta_phy_addr_t kPageBits = 12;
+ static constexpr vta_phy_addr_t kPageBits = VTA_PAGE_BITS;
// page size, also the maximum allocable size 16 K
- static constexpr vta_phy_addr_t kPageSize = 1 << kPageBits;
+ static constexpr vta_phy_addr_t kPageSize = VTA_PAGE_BYTES;
/*! \brief A page in the DRAM */
struct Page {
/*! \brief Data Type */