MATLAB DESIGN HDL CODER RELEASE NOTES User's Guide Page 176

  • Download
  • Add to my manuals
  • Print
  • Page
    / 410
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 175
176 www.xilinx.com System Generator for DSP User Guide
UG640 (v 12.2) July 23, 2010
Chapter 2: Hardware/Software Co-Design
Write Software
Create a new software application in your XPS project. Again, information on how to do
this can be found in the topic Using XPS. Add the following code to your application and
compile the software.
#include "xparameters.h"
#include "stdio.h"
#include "xutil.h"
// header file of System Generator Pcore
#include "rgb2gray_plbw.h"
int main (void) {
int i;
uint32_t gray, red, green, blue;
print("-- Entering main() --\n\r");
xc_iface_t *iface;
xc_from_reg_t *fromreg_gray;
xc_to_reg_t *toreg_red, *toreg_green, *toreg_blue;
// initialize the software driver
xc_create(&iface, &RGB2GRAY_PLBW_ConfigTable[0]);
// obtain the memory locations
xc_get_shmem(iface, "result", (void **) &fromreg_gray);
xc_get_shmem(iface, "red", (void **) &toreg_red);
xc_get_shmem(iface, "green", (void **) &toreg_green);
xc_get_shmem(iface, "blue", (void **) &toreg_blue);
for (i=15; i<30; i++){
red = i;
green = i + 10;
blue = i + 20;
// Write RGB value to peripheral
xc_write(iface, toreg_red->din, red);
xc_write(iface, toreg_green->din, green);
xc_write(iface, toreg_blue->din, blue);
xil_printf("R = 0x%x, G = 0x%x, B = 0x%x -- ",
red, green, blue);
xc_read(iface, fromreg_gray->dout, &gray);
xil_printf("Gray = %x \n\r", gray);
}
print("-- Exiting main() --\n\r");
return 0;
}
Page view 175
1 2 ... 171 172 173 174 175 176 177 178 179 180 181 ... 409 410

Comments to this Manuals

No comments