// DMA_pow2_test3.c
// 2021/08/01 by marsee
//
#include <stdio.h>
#include "xdma_pow2.h"
#include "xparameters.h"
#include "xil_io.h"
#include "xdma_square_root8_hw.h"
volatile int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
volatile int result[10];
void Xil_DCacheFlush(void);
void Xil_DCacheInvalidate(void);
#define XPAR_XDMA_SQUARE_ROOT8_0_BASEADDR 0x40000000
int main(){
XDma_pow2 XDMA_pow2_ap;
XDma_pow2_Config *XDMA_pow2_apPtr;
int i, inbyte_in;
u32 status;
// Look Up the device configuration
XDMA_pow2_apPtr = XDma_pow2_LookupConfig(0);
if (!XDMA_pow2_apPtr){
fprintf(stderr, "XDma_pow2 configuration failed.\n");
return(-1);
}
// Initialize the Device
int Xlap_status = XDma_pow2_CfgInitialize(&XDMA_pow2_ap, XDMA_pow2_apPtr);
if (Xlap_status != XST_SUCCESS){
fprintf(stderr, "Could not Initialize XDma_pow2\n");
return(-1);
}
XDma_pow2_Set_data(&XDMA_pow2_ap, (u32)&data[0]);
XDma_pow2_Set_result(&XDMA_pow2_ap, (u32)&result[0]);
Xil_DCacheFlush(); // Flush data[10] cache to memory
XDma_pow2_Start(&XDMA_pow2_ap);
while(!XDma_pow2_IsDone(&XDMA_pow2_ap)) ;
Xil_DCacheInvalidate(); // Invalidate result[10]
for(i=0; i<10; i++){
printf("data[%d] = %d, result[%d] = %d\n", i, data[i], i, result[i]);
}
Xil_Out32(XPAR_DFX_DECOUPLER_0_BASEADDR, 1); // 1: Turn decoupling on
printf("Configure the partial bit file in Vivado and then press any key.");
fflush(stdout);
inbyte_in = inbyte();
printf("\n"); fflush(stdout);
Xil_Out32(XPAR_DFX_DECOUPLER_0_BASEADDR, 0); // 1: Turn decoupling off
Xil_Out32((XPAR_XDMA_SQUARE_ROOT8_0_BASEADDR+XDMA_SQUARE_ROOT8_CONTROL_ADDR_DATA_DATA), (u32)&data[0]);
Xil_Out32((XPAR_XDMA_SQUARE_ROOT8_0_BASEADDR+XDMA_SQUARE_ROOT8_CONTROL_ADDR_RESULT_DATA), (u32)&result[0]);
Xil_DCacheFlush(); // Flush data[10] cache to memory
Xil_Out32(XPAR_XDMA_SQUARE_ROOT8_0_BASEADDR,(u32)1); // Start
status = Xil_In32(XPAR_XDMA_SQUARE_ROOT8_0_BASEADDR);
//while(!(status & 0x2)) // Wait ap_done
//status = Xil_In32(XPAR_XDMA_SQUARE_ROOT8_0_BASEADDR);
sleep(1);
Xil_DCacheInvalidate(); // Invalidate result[10]
for(i=0; i<10; i++){
printf("data[%d] = %d, result[%d] = %d\n", i, data[i], i, result[i]);
}
return 0;
}
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |