Design Article
FPGA design and verification using Simulink
Justin Delva, Ben Chan, and Shay Seng, Xilinx
1/14/2008 12:00 AM EST
You can use this same environment to test your HDL code running in real hardware without any modifications. The hardware co-simulation system uses pre-supported FPGA platforms such as the Xilinx ML506 board for performing either a Simulink-controlled stepped clock hardware run or a real-time data-burst run.
Systematic Design and Verification of a CABAC Module
The H.264/AVC video encoder is the product of years of collaborative efforts that resulted in a standard with good video quality at substantially lower bit rates than previous standards. A reference C source code called the H.264/AVC Joint Model (JM) is available to developers. You can use this source code as a starting point for the functionality implemented in HDL.
Context-adaptive binary arithmetic coding (CABAC) is part of the H.264 video standard. The functionality of the CABAC module is manually translated in HDL using standard communication primitives. The primitives mostly used in this verification are FIFO interfaces. The original JM source code is also used for generating test vector files for the module.
We have also built a test environment that uses the JM model to generate the input stimuli for the CABAC HDL module and verify the results of the output of the HDL with the results produced by the JM reference model. This is a significant improvement over traditional HDL ad-hoc test benches.
Module verification is a three-step process comprising:
- Functional HDL simulation. MATLAB verification with input and output test vectors feeds the ModelSim simulation and compares results, respectively.
- Functional hardware verification. An intermediate step for working out any bugs not caught during functional HDL simulations. This stage uses a System Generator for DSP-controlled single-step clocking. The input and output test vectors are extracted in files from the original execution of the JM source model. Special care is taken to build file interfaces in System Generator for DSP.
- Real-time hardware verification. Using the input test vectors of the functional HDL simulation, the design is tested in hardware at the targeted input rate and clocking frequency. The output of the hardware is captured into MATLAB and compared with the output test vectors.
Functional HDL Simulation
In this step, we integrate the ModelSim simulation with the System Generator for DSP simulation, as shown in Figure 1.

(Click to enlarge)
Figure 1. Black box of CABAC HDL and ModelSim co-simulation
To simulate the HDL in System Generator for DSP, a black box of the top VHDL entity is created by inserting converters at the boundaries, also shown in Figure 1. These converters translate the ModelSim unknown "X" states to zeros in the Simulink simulation. The test bench setup of the total simulation is shown in Figure 2.

(Click to enlarge)
Figure 2. Test bench setup for HDL simulation of the CABAC design
In Figure 2, the "Slice_input subsystem" block and "MB_input subsystem" block use special interface code to read from files containing stimuli created by the JM source code. The "Output_compare" subsystem is a special block that compares the results of the simulation with the original test vector results from the JM source code. This simulation is done on a single-step basis.



