// Located in: microblaze_0/include/xparameters.h #include "xparameters.h" #include "stdio.h" #include "xbasic_types.h" #include "gpio_header.h" //==================================================== int main (void) { Xuint32 status, *customLogicPtr; Xuint32 data,data1,data2,result; int a = 0xFFFFFFFF, b = 0x00000001, c = 0x999999, i=0; print("Software Test Data\r\n"); c=a+b; xil_printf("%d + %d = %d \r\n", a,b,c); xil_printf("%x + %x = %x \r\n\n", a,b,c); print("-- Entering main() --\r\n\n"); do{ // read a new 8-bit values from dip switches and signal to accept the new number for addition with the 3 push buttons do{ status = GpioInputExample(XPAR_PUSH_BUTTONS_3BIT_DEVICE_ID, &data); status = GpioInputExample(XPAR_DIP_SWITCHES_8BIT_DEVICE_ID, &data1); }while(data == 0); for(i=0; i <= 0x1FFFF; i++) { ; } xil_printf("Data read from Push_Buttons_3Bit: 0x%x\r\n", data); xil_printf("Data read from DIP_Switches_8Bit: 0x%x\r\n", data1); // loop for delay for time to release switch and debounce a = data; b = data1; // write values to software addressable register 0 and register 1 customLogicPtr = (Xuint32 *)XPAR_CUSTOM_LOGIC_ADDER_0_BASEADDR; *(customLogicPtr) = a; // send variable a to register 0 of custom logic *(customLogicPtr + 0x1) = b; // send variable b to register 1 of custom logic c = *(customLogicPtr + 0x2); print("Custom Logic\r\n"); xil_printf("%d + %d = %d \r\n", a,b,c); xil_printf("%x + %x = %x \r\n\n", a,b,c); // do MicroBlaze addition and display on RS232 terminal print("Software\r\n"); c=a+b; xil_printf("%d + %d = %d \r\n", a,b,c); xil_printf("%x + %x = %x \r\n\n", a,b,c); }while(1); // continues for ever to get user input print("-- Exiting main() --\r\n"); return 0; }