100
Figure 7-1 HPS Control FPGA LED and HEX
LED and HEX control
The Lightweight HPS-to-FPGA Bridge is a peripheral of the HPS. The software running on linux
operation system can’t access the physical address of the HPS peripheral. You must map the
physical address to the user space at first then you can access to the peripheral or you can write a
device driver module and add it to the kernel. We only show the first method to the users in this
demonstration. We actually map in the entire CSR span of the HPS since we want to access various
registers within that span. If the users want to access any other peripherals whose physical address
is in this span, they can reuse the mapping function and the macro we defined below.
The lwaxi bridge start address after being mapped can be get using the ALT_LWFPGASLVS_OFST
which is defined in altera_hps hardware library. Then the slave IP connected to the lwaxi bridge can
be accessed through the base address and the register offset in these IPs. For instance, the base
address of the PIO slave IP in this system is 0x0001_0040 and the direction control register offset is
0x01, the data register offset is 0x00. The following statement can be used to get the base address of
PIO slave IP.
h2p_lw_led_addr=virtu( ( unsigned long )( ALT_LWFPGASLVS_OFST
+ LED_PIO_BASE ) & ( unsigned long)( HW_REGS_MASK ) );
In this demonstration, we just need to set the PIO’s direction as output which is the default direction
of the PIO IP, so we can skip this step. The following statement is used to set the output state of the
PIO.