-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
37 lines (28 loc) · 890 Bytes
/
main.c
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
31
32
33
34
35
36
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#define SIZE 4
int main(int argc, char** argv)
{
int i;
int foo = open("/dev/mem", O_RDWR);
int *fpga_bram = mmap(NULL, SIZE * sizeof(int), PROT_READ|PROT_WRITE, MAP_SHARED, foo, 0x40000000);
int *fpga_ip = mmap(NULL, sizeof(int), PROT_READ|PROT_WRITE, MAP_SHARED, foo, 0x43C00000);
// initialize memory
for (i = 0; i < SIZE; i++)
*(fpga_bram + i) = (i * 2);
for (i = SIZE; i < SIZE * 2; i++)
*(fpga_bram + i) = 0.0f;
printf("%-10s%-10s\n", "addr", "FPGA(hex)");
for (i = 0; i < SIZE * 2; i++)
printf("%-10d%-10X\n", i, *(fpga_bram + i));
// run ip
*(fpga_ip) = 0x5555;
while (*fpga_ip == 0x5555);
printf("%-10s%-10s\n", "addr", "FPGA(hex)");
for (i = 0; i < SIZE * 2; i++)
printf("%-10d%-10X\n", i, *(fpga_bram + i));
return 0;
}