Specifications

alt_getchar()
Equivalent to getchar(). In conjunction with the lightweight device driver API, this function further
reduces code footprint. In the absence of the lightweight API, it calls getchar().
For more information about the minimal character-mode functions, refer to the "HAL API Reference"
chapter.
Related Information
HAL API Reference on page 14-1
Eliminate Unused Device Drivers
If a hardware device is present in the system, by default the Nios II development flows assume the device
needs drivers, and configure the HAL BSP accordingly. If the HAL can find an appropriate driver, it
creates an instance of this driver. If your program never actually accesses the device, resources are being
used unnecessarily to initialize the device driver.
If the hardware includes a device that your program never uses, consider removing the device from the
hardware. This reduces both code footprint and FPGA resource usage.
However, there are cases when a device must be present, but runtime software does not require a driver.
The most common example is flash memory. The user program might boot from flash, but not use it at
runtime; thus, it does not need a flash driver.
You can selectively omit any individual driver, select a specific driver version, or substitute your own
driver.
For more information about controlling driver configurations, refer to the "Nios II Software Build Tools"
chapter.
Another way to control the device driver initialization process is to use the free-standing environment.
For more information, refer to the “Boot Sequence and Entry Point” chapter.
Related Information
Boot Sequence and Entry Point on page 6-34
Nios II Software Build Tools on page 4-1
Boot Sequence and Entry Point on page 6-34
Eliminate Unneeded Exit Code
The HAL calls the exit() function at system shutdown to provide a clean exit from the program. exit()
flushes all of the C library internal I/O buffers and calls any C++ functions registered with atexit(). In
particular, exit() is called on return from main(). Two HAL options allow you to minimize or eliminate
this exit code.
Eliminate Clean Exit
To avoid the overhead associated with providing a clean exit, your program can use the function _exit()
in place of exit(). This function does not require you to change source code. You can select the _exit()
function through a BSP setting.
NII5V2
2015.05.14
alt_getchar()
6-33
Developing Programs Using the Hardware Abstraction Layer
Altera Corporation
Send Feedback