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.

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. Commented Jul 4, 2023 at 10:42

1 Answer 1

1

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;
}
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.