The batch file mentioned above is called as generate_hps_qsys_header.sh. It is located in the same
folder as DE10_NANO_SoC_GHRD Quartus project. To generate the header file, launch SoC EDS
command shell, go to the Quartus project folder, and execute generate_hps_qsys_header.sh by
typing ‘./generate_hps_qys_header.sh”. Then, press ENTER key, a header file hps_0.h will be
generated. In the header file, the led_pio base address is represented by a constant
LED_PIO_BASE as show in Figure 7-5. The led_pio width is represented by a constant
LED_PIO_DATA_WIDTH. These two constants will be used in the C program demonstration code.
Figure 7-5 pio_led information defined in hps_0.h
Map LED_PIO Address
This section will describe how to map the pio_led physical address into a virtual address which is
accessible by an application software. Figure 7-6 shows the C program to derive the virtual
address of led_pio base address. First, open system-call is used to open memory device driver
“/dev/mem”, and then the mmap system-call is used to map HPS physical address into a virtual
address represented by the void pointer variable virtual_base. The demo code maps the physical
base address (HW_REGS_BASE = 0xfc000000) of the peripheral region into a based virtual
address virtual_base. For any controller in the peripheral region, users can calculate their virtual
address by adding their offset relative to the peripheral region to the based virtual address
virtual_base. Based on the rule, the virtual address of led_pio can be calculated by adding the
below two offset addresses to virtual_base.
Offset address of Lightweight HPS-to-FPGA AXI bus relative to HPS base address
Offset address of Pio_led relative to Lightweight HPS-to-FPGA AXI bus