/* * my_test.c * * Created on: May 1, 2015 * Author: jfrenzel */ /* Write Reg1 with value of n, then write a 1 to Reg0[0]. * Then poll Reg2[0] for a 1, after which read Reg3 for result. * Then need to set Reg0[0] back to 0 before next operation! */ #include "myip.h" #include "xparameters.h" #include "xil_printf.h" #include "xil_io.h" /* Define the base memory address of the AXI slave IP core */ #define MYIP_BASE XPAR_MYIP_0_S00_AXI_BASEADDR int main(void){ u32 reg1, reg3; // for holding register values xil_printf("Factorial Co-processor test begin.\r\n"); while(1){ for (reg1=1; reg1<11; reg1++){ MYIP_mWriteReg(MYIP_BASE, 0, 0); // reset go MYIP_mWriteReg(MYIP_BASE, 4, reg1); // load n MYIP_mWriteReg(MYIP_BASE, 0, 1); // set go xil_printf("Wrote Register 0 and 1\r\n"); while (!MYIP_mReadReg(MYIP_BASE, 8)); // poll done reg3 = MYIP_mReadReg(MYIP_BASE, 12); // read result xil_printf("The factorial of %d is equal to %d\r\n", reg1, reg3); } // end for } // end while return 1; } // end my_test