0

I am a novice. I have a cyclone V board. I have generated several 32-bit ASCII codes through verilog on the FPGA side. I want to send them to the HPS side through the H2F AXI bus and program the HPS side to read them. . I connected the FIFO and H2F AXI bus as shown in the picture, I don't know if such connection is correct.

Can someone give me some idea, any help would be greatly appreciated.

I wrote preloader, u-boot, device tree file, rbf file, and linux kernel to sd card, but I don't know what to do next.

rid
  • 61,078
  • 31
  • 152
  • 193
2258432
  • 1
  • 1
  • Avalon is quite a bit simpler to use than AXI, and you can use Avalon<->AXI bridge provided by the Altera tooling for free. – SK-logic Jul 04 '23 at 10:42

1 Answers1

0

Use address mapping on the HPS side to read data. qsys

/* Code for reading data on HPS side */
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdint.h>
#include <unistd.h>


#define HW_REGS_BASE (0xC0000000)
#define HW_REGS_SPAN (0x04000000)
#define ALT_H2F_OFST  (0xFF500000)
#define HW_REGS_MASK (HW_REGS_SPAN - 1)
#define LED_PIO_OFFSET (0x00000408)

int main()
{
int fd;
void *h2f_axi_base;
void *led_pio_addr;


fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd == -1) {
    perror("could not open /dev/mem\n");
    return 1;
}


  h2f_axi_base = mmap(NULL, HW_REGS_SPAN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, HW_REGS_BASE);
if (h2f_axi_base == MAP_FAILED) {
    perror("could not mirror the H2F AXI address\n");
    close(fd);
    return 1;
}


led_pio_addr = h2f_axi_base + ( ( unsigned long ) (ALT_H2F_OFST+LED_PIO_OFFSET) & (unsigned long ) (HW_REGS_MASK) );


while (1) {

    uint32_t data = *((volatile uint32_t *)led_pio_addr);         
    printf("read data:   %x\n", data);
    usleep(10000);

   
}

munmap(h2f_axi_base, HW_REGS_SPAN);
close(fd);

return 0;
}
2258432
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 07 '23 at 10:23