DSP Builder for Intel® FPGAs (Advanced Blockset): Handbook

ID 683337
Date 3/23/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

3.4. Verifying your DSP Builder Design with C++ Software Models

DSP Builder supports C++ software models for designs that support bit-accurate simulation.

The software model includes a testbench, which is an executable program to check the output of the software models matches the output of Simulink simulation. The generated CMake script creates projects and makefiles (depending on parameters) that you can use to compile the software model and testbench. The testbench and the CMake script allow you to verify the model functionality. Also, you can use the testbench as a starting point for integration of generated models into a larger, system-level, simulation.

Procedure

  1. In the design’s Control block turn on Generate software model.
    The default language is cpp03 (C++ 2003 standard conformant) and Generate an ATB (automatic testbench) and CMake build script is turned on (by default).
  2. Turn on Bit Accurate Simulation on the SynthesisInfo blocks in all subsystems.
    You must enable bit-accurate simulation for all subsystems otherwise DSP Builder generates incomplete software models.
  3. Compile the design.
    DSP Builder creates a directory, cmodel, which contains the following files:
    • A csl.* header file containing utility functions and implementation details for the generated models.

      A [model/subsystem name]_CModel(.h/.cpp) pair for each subsystem and the device level system.

      A [model/subsystem name]_atb.cpp file containing the device level test bench for the model.

      A CMakeFiles.txt/CMakeLists.txt file containing CMake build scripts for building the ATB executable and model files.

  4. Generate the project or makefiles using CMakeLists.txt.
    For example, to generate Visual Studio 2017 projects, run:
    cmake -G "Visual Studio 15 2017 Win64
    Or to generate a makefile for the release build with symbols on Linux:
    cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo
    Refer to the CMake documentation for more options.
    The minimum supported compilers are gcc6.3 and MSVC14.0. Other compilers may work but are not supported.
  5. Set the MPIR_INC_PATH, MPIR_LIB_PATH, MPFR_INC_PATH, MPFR_LIB_PATH options to the include and library directories of builds of the mpfr or mpir libraries if they are required by the build scripts.

    You must set these options otherwise the generation may fail. Your design requires these libraries if the bit widths in the software model are larger than 64-bits or when modeling certain floating-point configurations. These bit-widths may appear on internal signals, not just the inputs and outputs whose widths you specify.

    Build instructions and prebuilt binaries are on the mpfr or mpir websites: https://www.mpfr.org/ and http://mpir.org/

    The following example commands specifying both mpir and mpfr paths:

    • Windows:
    cmake -G "Visual Studio 15 2017 Win64" -DMPIR_INC_PATH="C:\path\to\mpir\3.0.0\win64-vc14\include" -DMPIR_LIB_PATH="C:\path\to\mpir\3.0.0\win64-vc14\lib\release" -DMPFR_INC_PATH="C:\path\to\mpfr\4.0.1\win64-vc14\include" -DMPFR_LIB_PATH="C:\path\to\mpfr\4.0.1\win64-vc14\lib\release"
    • Linux:
    export CC=/path/to/gcc/6.3.0/1/linux64/bin/gcc
    export CXX=/path/to/gcc/6.3.0/1/linux64/bin/g++
    cmake -G "Unix Makefiles" -DMPIR_INC_PATH="path/to/mpir/3.0.0/linux64-gc63/include" -
    DMPIR_LIB_PATH="path/to/mpir/3.0.0/linux64-gc63/lib/release" -
    DMPFR_INC_PATH="path/to/mpfr/4.0.1/linux64-gc63/include" -
    DMPFR_LIB_PATH="path/to/mpfr/4.0.1/linux64-gc63/lib/release"
  6. On Windows, open the generated solution file and run the compilation. On Linux, run make.
    After compilation, DSP Builder creates an executable of the same name as the generated testbench, <design name>_CModel_atb.exe.
  7. Run the .exe with the cmodel directory as the working directory so that the generated stimulus file paths are correct.
    If simulation was successful, the executable produces the following output to stdout:
    Opening stimulus files...
    Simulating...
    Success! Stimulation matches output stimulus results.
  8. Refer to the testbench to see how you can integrate the generated models into an existing system.
    Subsystems contain structs representing their inputs and outputs. These structs have a generated constructor that reads values from a stimulus file for the testbench.
    struct IO_xIn
    {
    	int64_t v; int64_t c; int64_t x; int64_t y;
    
    	IO_xIn()
    	: v(0)
    	, c(0)
    	, x(0)
    	, y(0)
    	{
    	}
    
    	IO_xIn(csl::StimulusFile& stm)
    	{
    		stm.Get<1>(v); stm.Get<8>(c); stm.Get<27>(x); stm.Get<27>(y);
    	}
    };
    
    When integrating the model, replace the stimulus file constructor by manually setting the input or output values on the struct before using them to drive the model using read(), write(), or execute() functions.