User guide
152 www.xilinx.com System Generator for DSP User Guide
UG640 (v 12.2) July 23, 2010
Chapter 2: Hardware/Software Co-Design
// obtain the memory location for storing the settings of shared memory
"t"
xc_get_shmem(iface, "toreg", &toreg);
// write value to the "din" port of shared memory "toreg"
xc_write(iface, toreg->din, (const unsigned) value);
Single-Word Reads
The following code snippet reads data stored in the "From Register" shared memory
named "fromreg" into "value".
uint32_t value;
xc_iface_t *iface;
xc_from_reg_t *fromreg;
// initialize the software driver, assuming the Pcore device ID is 0
xc_create(&iface, &SG_PLBIFACE_ConfigTable[0]);
// obtain the memory location for storing the settings of shared memory
"fromreg"
xc_get_shmem(iface, "fromreg", (void **) &fromreg);
// read data from the "dout" port of shared memory "fromreg" and store
at value
xc_read(iface, fromreg->dout, &value);
Accessing "From FIFO" and "To FIFO" shared memories
Single-Word Writes
The following code snippet writes value to the "To FIFO" shared memory named "tofifo".
uint32_t full;
uint32_t value;
xc_iface_t *iface;
xc_to_fifo_t *tofifo;
// initialize the software driver, assuming the Pcore device ID is 0
xc_create(&iface, &SG_PLBIFACE_ConfigTable[0]);
// obtain the memory location for storing the settings of shared memory
"t"
xc_get_shmem(iface, "tofifo", (void **) &tofifo);
// check the "full" port of shared memory "tofifo"
do {
xc_read(iface, tofifo->full, &full);
} while (full == 1);
// write value to the "din" port of shared memory "tofifo"
value = 100;
xc_write(iface, tofifo->din, value);