The memory mapped address is defined in the configuration of Or1ksim (see Section 5.6) to be 0x90000000. This is set as a defined constant in the test program.
#define BASEADDR 0x90000000
The memory mapped structure consists of a byte, half word (16 bits)
and full word (32 bits), all declared as volatile
within the struct
. These are all declared with
the C types, which for the OpenRISC 1000 tool chain are known to correspond
to these sizes.
struct testdev { volatile unsigned char byte; volatile unsigned short int halfword; volatile unsigned long int fullword; };
The main program declares a pointer to this
struct
at the BASEADDR
, along
with 3 variables to hold the results of the various sized results
when reading.
main() { struct testdev *dev = (struct testdev *)BASEADDR; unsigned char byteRes; unsigned short int halfwordRes; unsigned long int fullwordRes;