AN 947: Testing the Nios® II Software with Unit-Test Framework

ID 683606
Date 4/30/2021
Public

Testing the Nios® II Software with Unit-Test Framework

This document describes a unit-test framework for testing embedded software known as System Mock that runs on the Intel FPGA Nios® II processor. At a high level, it simulates the FPGA environment that interacts with Nios® II software. Under this framework, you can test Nios® II code with little to no modification. Through System Mock, developers can inject simulated hardware stimuli to exercise different code paths.

System Mock unit-test framework is a wrapper that allows Nios® II user code to execute as if it is on hardware. This framework focuses on modeling the hardware interaction and memory access of a Nios® II process. In FPGA designs, Nios® II system is usually connected to other hardware components via an Avalon® Memory-Mapped Interface. System Mock overwrites the Nios® II intrinsic functions to intercept the Nios® II outgoing Avalon® memory-mapped interface memory accesses. This key technique allows you to test unmodified Nios® II user code from beginning to end. The intercepted memory accesses require appropriate responses. In System Mock, a list of IP mock modules which model hardware behaviors respond to them. These are the core building blocks of this unit-test framework.