diff --git a/tapa-lib/tapa/host/mmap.h b/tapa-lib/tapa/host/mmap.h index 72a6b805..4805f025 100644 --- a/tapa-lib/tapa/host/mmap.h +++ b/tapa-lib/tapa/host/mmap.h @@ -176,6 +176,20 @@ class mmap { uint64_t size_; }; +template +class immap : public mmap { + public: + // Inherit all constructors from mmap + using mmap::mmap; +}; + +template +class ommap : public mmap { + public: + // Inherit all constructors from mmap + using mmap::mmap; +}; + /// Defines a view of a piece of consecutive memory with asynchronous random /// accesses. template @@ -475,6 +489,57 @@ TAPA_DEFINE_MMAP(read_only); TAPA_DEFINE_MMAP(write_only); TAPA_DEFINE_MMAP(read_write); #undef TAPA_DEFINE_MMAP + +// Host-only immap types that must have correct size. +#define TAPA_DEFINE_IMMAP(tag) \ + template \ + class tag##_immap : public immap { \ + tag##_immap(T* ptr) : immap(ptr) {} \ + \ + public: \ + using immap::immap; \ + tag##_immap(const immap& base) : immap(base) {} \ + \ + template \ + tag##_immap> vectorized() const { \ + return immap::template vectorized(); \ + } \ + template \ + tag##_immap reinterpret() const { \ + return immap::template reinterpret(); \ + } \ + } +TAPA_DEFINE_IMMAP(placeholder); +TAPA_DEFINE_IMMAP(read_only); +TAPA_DEFINE_IMMAP(write_only); +TAPA_DEFINE_IMMAP(read_write); +#undef TAPA_DEFINE_IMMAP + +// Host-only ommap types that must have correct size. +#define TAPA_DEFINE_OMMAP(tag) \ + template \ + class tag##_ommap : public ommap { \ + tag##_ommap(T* ptr) : ommap(ptr) {} \ + \ + public: \ + using ommap::ommap; \ + tag##_ommap(const ommap& base) : ommap(base) {} \ + \ + template \ + tag##_ommap> vectorized() const { \ + return ommap::template vectorized(); \ + } \ + template \ + tag##_ommap reinterpret() const { \ + return ommap::template reinterpret(); \ + } \ + } +TAPA_DEFINE_OMMAP(placeholder); +TAPA_DEFINE_OMMAP(read_only); +TAPA_DEFINE_OMMAP(write_only); +TAPA_DEFINE_OMMAP(read_write); +#undef TAPA_DEFINE_OMMAP + #define TAPA_DEFINE_MMAPS(tag) \ template \ class tag##_mmaps : public mmaps { \ @@ -605,4 +670,19 @@ struct accessor, mmaps> { } // namespace tapa +// Generalized window_readincr for AIE +template +T window_readincr(tapa::immap& mem) { + T res = *mem; + mem++; + return res; +} + +// Generalized window_writeincr for AIE +template +void window_writeincr(tapa::ommap& mem, const T& val) { + *mem = val; + mem++; +} + #endif // TAPA_HOST_MMAP_H_