Unified FFT Intel® FPGA IPs User Guide

ID 683366
Date 9/30/2023
Public

2.3. Compiling the Software Model for the Unified FFT IPs

When you turn on Generate a software model, Intel Quartus Prime generates a software model of the IP in C++ language.

The software models are in the following directories depending on the IP:

  • intel_FPGA_unified_fft_10/sim/cmodel
  • intel_FPGA_unified_vfft_10/sim/cmodel
  • intel_FPGA_unified_pfft_10/sim/cmodel
  • intel_FPGA_unified_bitrev_10/sim/cmodel
  • intel_FPGA_unified_vbitrev_10/sim/cmodel

You need a gcc version from 7.2 to 9.2 on Linux and Microsoft Visual Studio 2017 or 2019 on Windows to compile the C++ model. Later versions and other compilers may require minor modifications to the static or generated C++ source code to work correctly.

The cmodel directory contains the following files:

  • csl.h/cpp files containing utility functions and implementation details for the generated models.
  • instance_name.h or .cpp) files containing the simulation model of the IP and instance_name_atb.cpp containing the testbench of the IP.
  • atb_app.cpp file containing the main() function.
  • CMakeFiles.txt/CMakeLists.txt file containing CMake build scripts for building the ATB executable and model files.
  1. Generate the project or makefiles by running the CMake build scripts using CMake 3.13 or greater. For example, to generate Visual Studio 2017 projects, from the cmodel/build subdirectory, run:
    cmake -G "Visual Studio 15 2017 Win64" -DWRITE_STM_FILES=1
    Or to generate a makefile for the release build with symbols on Linux, run:
    cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWRITE_STM_FILES=1

    Defining WRITE_STM_FILES=1 is necessary for the test executable (atb_app).

    You may need to set the CC and CXX variables to the location of gcc and g++ executables on Linux for proper operation of CMake. For example, export CC=/path/to/gcc/7.2.0/1/linux64/bin/gcc export CXX=/path/to/gcc/7.2.0/1/linux64/bin/g++.

    Refer to the CMake documentation for more options.
  2. 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 the build scripts require them.
    You require the libraries if the internal bit widths in the software model are larger than 64-bits or when modeling certain floating-point configurations. The internal bit widths may be different to the bit widths that you choose. Build instructions and prebuilt binaries are on the mpfr or mpir websites.
  3. On Windows, open the generated solution file and run the compilation. On Linux, run make.
    Alternatively, run CMake again with the -build option to compile on both Windows and Linux, e.g:cmake –build . –config Release
  4. Run the atb_app executable in the cmodel directory as the working directory so that the generated stimulus file paths are correct. If simulation is successful, the executable produces the following output to stdout:
    Opening stimulus files... 
    Simulating... 
    Simulation has completed. 
  5. Refer to the testbench to see how you can integrate the generated models into an existing system.
    The basic application programming interface (API) of the C++ model is:
     // Create an instance of the C model class
    unified_fft_c_model_t inst0;
     // Reset the model
     inst0.reset();
     // Note: this is a C Model of the RTL pipeline, so needs to be flushed to 
        get all the output just like RTL 
     while(there_is_input_or_expecting_output) { 
       // Write input
       inst0.write(io_chanIn_cunroll_x_t0);
       // Execute for all chanIn/Out structures
       inst0.execute(io_chanIn_cunroll_x_t0);
       // Execute for all chanIn/Out structures
       inst0.execute(io_chanOut_cunroll_x_t0);
       // Read output
       inst0.read(io_chanOut_cunroll_x_t0); 
     }