10 typedef unsigned int UINT32;
11 typedef unsigned short UINT16;
12 typedef unsigned char UINT8;
15 template<
class T>
void nios_write(UINT32 address, T val);
16 template<
class T> T nios_read(UINT32 address);
19 template<
class T> UINT32 nios_copyto(UINT32 address, UINT32 src, UINT32 bytes);
20 template<
class T> UINT32 nios_copyfrom(UINT32 address, UINT32 src, UINT32 bytes);
24 #ifndef REAL_NIOS_WRITE_FUNCTIONS
25 template<
class T>
void nios_write(UINT32 address, T val)
27 T *addr = (T *)address;
32 template<
class T> T nios_read(UINT32 address)
34 T *addr = (T *)address;
39 template<
class T> UINT32 nios_copyto(UINT32 dest, UINT32 src, UINT32 sz)
41 memcpy((UINT32 *)dest, (UINT32 *)src, sz);
45 template<
class T> UINT32 nios_copyfrom(UINT32 dest, UINT32 src, UINT32 sz)
47 memcpy((UINT32 *)dest, (UINT32 *)src, sz);
73 nios_write<T>(ptr, x);
79 T x = nios_read<T>(ptr);
97 for(
int i=0;i<size;i++) {
98 shadow[i].ptr = base +
sizeof(T) * i;
103 if(shadow) free(shadow);
110 UINT32 copyto(
nios_int<T> *dest, T *src, UINT32 bytes) {
111 return nios_copyto<T>(dest->ptr, (UINT32)src, bytes);
114 UINT32 copyto(UINT32 dest, T *src, UINT32 bytes) {
115 return nios_copyto<T>(dest+base_addr,(UINT32)src,bytes);
118 UINT32 copyfrom(T *dest,
nios_int<T> *src, UINT32 bytes) {
119 return nios_copyfrom<T>((UINT32)dest, src->ptr, bytes);
122 UINT32 copyfrom(T * dest, UINT32 src, UINT32 bytes) {
123 return nios_copyfrom<T>(dest, src+base_addr, bytes);
136 char *t = (
char *)
this;
137 nios_write<T>((UINT32)t, x);
144 char *t = (
char *)
this;
145 x = nios_read<T>((UINT32)t);
165 UINT32 copyto(
nios_int<T> *dest, T *src, UINT32 bytes) {
166 return nios_copyto<T>((UINT32)dest, (UINT32)src, bytes);
169 UINT32 copyto(UINT32 dest, T *src, UINT32 bytes) {
170 return nios_copyto<T>(dest+base_addr,(UINT32)src,bytes);
173 UINT32 copyfrom(T *dest,
nios_int<T> *src, UINT32 bytes) {
174 return nios_copyfrom<T>((UINT32)dest, (UINT32)src, bytes);
177 UINT32 copyfrom(T * dest, UINT32 src, UINT32 bytes) {
178 return nios_copyfrom<T>(dest, src+base_addr, bytes);