Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

6. Overview of the Hardware Abstraction Layer

The HAL is a lightweight embedded runtime environment that provides a simple device driver interface for programs to connect to the underlying hardware. The HAL application program interface (API) is integrated with the ANSI C standard library. The HAL API allows you to access devices and files using familiar C library functions, such as printf(), fopen(), fwrite(), etc.

The HAL serves as a device driver package for Nios® II processor systems, providing a consistent interface to the peripherals in your system. The Nios® II software development tools extract system information from your SOPC Information File (.sopcinfo). The Nios® II Software Build Tools (SBT) generate a custom HAL board support package (BSP) specific to your hardware configuration. Changes in the hardware configuration automatically propagate to the HAL device driver configuration. As a result, changes in the underlying hardware are prevented from creating bugs.

HAL device driver abstraction provides a clear distinction between application and device driver software. This driver abstraction promotes reusable application code that is resistant to changes in the underlying hardware. In addition, the HAL standard makes it straightforward to write drivers for new hardware peripherals that are consistent with existing peripheral drivers.