top of page

Site Title

MATLAB Runtime integration

It is really good idea to  import all MATLAB capabilities to the verification environment.

MATLAB supplies a very strong capabilities in mathematical area and more.

MATLAB could supply a great help in areas like: 
Image processing and algorithm in wireless communication, Filters, bits correction (like: LDPC, BCH.), Scrambling , vector and matrix manipulation are only  part of the great capabilities that MATLAB supplies.   
More than that, the most of the algorithm engineers are familiar with MATLAB, and many times they develop the design by MATLAB to perform feasibility studies.

Import MATLAB projects to  the verification environment could save us 90% percent of the verification environment writing process.

it is because the MATLAB project could contain:

  • Generation.

  • Data to drive

  • Test point.

  • information on how to  configure design.

  • Golden model is also inside.

So, we need just build the peripheral, which call MATLAB with test parameters, while MATLAB will generate  data, performs simulation and supplies information on how to  configure design, a vector of complex or any other information to drive the design, and expected result on each test point.

in the most of the time each test point have the same behavioral, they include clock data and valid. So code that  for-each clock, compare between MATLAB results against design result, could be created automatically for each test  point.

That's what SPV of SimPlus provides.

DPF - Digital process framework 



DPF -  is a C++ software framework, built from two parts.

  1. C++ library upon SPV, for testing simulated HDL designs against a bit accurate (or clock accurate) software model.  These kinds of models are often used in DSP applications, (hence the name), usually using MATLAB.  DPF provides a structure for creating test benches with a high degree of automation, and the necessary interface infrastructure to communicate with MATLAB based reference models during Runtime.

  2. C++ library that enable dealing in a freestanding with mat lab Data Structure, mat lab function (m files) and *.mat files.

   DPF - MATLAB interface classes

These classes wrap Mat-lab entities such as structures, cells, numeric arrays and matrix's, that old numbers, complex, strings (double, float, integer unsigned [8,16,32,64]and provide a simple, intuitive way to read and write the data contained therein. Passing this data structure to HDL or from HDL to MATLAB is very simple with DPF. 

MATLAB  wrapper classes - DPF,  allow the user create MATLAB entities at Runtime, and use them for MATLAB input or output.
User could create structure, complex or any object and pass it to  MATLAB as an input.
User could create empty object to be as  output to MATLAB function. MATLAB will build the output  object, by the output data which could be structure, vector, MATRIX or any supported MATLAB type. 

DPF works in two modes:

Compiled MATLAB code (with mcc)

Launch MATLAB instance (eng_Open).


   in this interface we call in the beginning to MATLAB from the environment, the environment get a pointer to the eng_Open, and by a special code in DPF, the environment could pass command to MATLAB. Command could be calling m files, while the input output created in the environment. in Runtime there is option to open the  MATLAB GUI, and search open or debug the MATLAB.

With MCC (MATLAB C Compiler):

working with MCC compiler of MATLAB, is more attractive for big projects, especially for big simulation, it enable call MATLAB thousands time in simulation with very good efficiency, minimum memory, and good performance.


Steps (and examples):

    • You could pass information from your own C/C++/HDL to MATLAB structure, and call again, now you have a feedback between HDL and MATLAB model. 

    • call function, now you have the output parameter that hold the results of the simulation. results could be complex vector, numbers or any, In the most of the time it's big structure with all the simulation results.  you could access to  any place in the structure, and use the information as a free 'C/C++' structure.

    • use DPF classes to declare your parameter objects (MATLAB think they are mxArray), for input you should set data to DPF objects, for output just set your C++ object.

    • in header file choose the function that you want to call, each parameter there is mxArray of MATLAB.​

    You want to call function in your project.

  • In your project make include to  the H file, and link to the .DLL(.SO for LINUX).

  •   Compile your project (could be even > 100 m files) to 1 .DLL(.so)file and one H file


We have a  modem project that do the following:

  • generate packet  (bits)

  • translate bits to symbols (depend on table and bps (Bit per symbol)

  • make scrambling

  • Passes through channel (with special SNR)

  • DE-scrambling

  • LDCP (error correction)

  • BCH(error correction)

  • More ....

the project that do all these and more functionality exists in MATLAB project, with Dozens of files that exists  in directory and sub directory like:


















Using MCC compiler to compile all the project and get:

  • 1 H file that include the header of each function in the MATLAB project.

  • 1 DLL that contain the binary of all the MATLAB project.

    • The DLL (SO file) depended on MATLAB run-time library.​


Do the same as MATLAB project, or part of it.

Verification environment:

We want to use MATLAB MCC results to do the following:

  • Generated valid packet or frame, depend  on  configuration from verification environment.

    • Used to drive design.

  • Make simulation across all station (Test Point) in design.

  • Supply all Test points results (Symbol, scrambling, channel....). 

    • Used in Monitor and checker.​

  • we want to call MATLAB thousands of times.  so we want that in the beginning ​we call MATLAB to prepare all the data structure that used many times in simulation like:

    • encapsulation table​

    • scrambling configuration

    • All valid packet structures. 

    • more..

    • The target of this request is to save time, memory and simulation time.

    • DPF of SPV look direct to MATLAB engine, so any object allocated in the beginning of simulation, still in alive along all the simulation.​

This requirements explain the left side in slide bellow (One time), we prepare what ever we can in time 0, and use this information at any call. so for any call MATLAB do only small simulation, because he have all the infra structure.

More than that the information could be used to configure the software and the HDL in the beginning. config the scrambler initialization, the encapsulation table and other.

A little code:

Call once:












This function supplied by H file, with 3 outputs, while the other parameters are input configuration.

We declare 4 instance of class MlStructArray: 

mlFrameTestCaseListOut,               mlScramblingParamSetsListOut,  

 mlLutsStructOut,                             mlVlSnr

The output parameter pass as they born to the MAT function, MATLAB will build the output structure with all the information, the input should be initial by environment.

The first input mlFrameTestCaseListOut - it is a big structure that hold the data structure to all the valid packet. we need it at any call when we will ask (for example) simulation with packet no 9, the simulation could create immediattely a packet no '9' with new random data and make on it simulation.

Call multiple times:

That's it.

After call RunModem we got a complex vector (theComplex) with normalize from -1: 1  to 11 bit, which is the HDL interface size for each symbol. this is the expected results after 1 test point that translate bits  to symbol. in object mlInterResultsStrctOut  which is structure, we could  found the frame bits list, these bit will use for the driver side.

We have another Test point, which is the symbole after scrambling, this information is also in struct mlInterResultsStrctOut  .

So we have:

  •      data to drive

  •      Data to check at 2 Test point.

In the most  of the time there are many test point, so we build automatic code that get information about 3 elements.

  • Matlab field name is struct.

  • Signal data out.

  • Signal data valid.

the monnitor code became to be very simple.

Another aspect in many verification environment is how we configure design by MATLAB information. This is also simple with DPF of SPV.

Small example in this code.





This register configuration could be done by SW that run against the processor or with SPV solution Pre-Silicon Software validation









  CppComplex&    RunModem(unsigned frameInd)

    mlTestCaseInd[0] = frameInd;

    //Call matlab to make simulation, and return all Test Point

        3,mlFrameVecOut, mlInterResultsStrctOut,

        mlFrameTestCaseListOut, mlTestCaseInd

    isSuccess = true;

    return theComplex;



 void  Monitor::ChecktestPoint()

   For each TP in TestPoint begin

     if TP.Valid() begin

       Check that TP.HdlData= TP.MatData;




 void Config::SymConf(unsigned BaseAddr,unsigned Ind){


     MlStructArray& config= m_MatInf->m_MlCfg; 

     ComplexList alpha =  


     ComplexList beta  =


     int size =   alpha.Size(); 

     for(int ind = 0; ind < size ; ind=ind+1){ 

          m_ApbInst->Write((RegAB.Addr + BaseAddr + ind*4)

                    ,beta.IList[ind]*2 + alpha.IList[ind]);




Run MATLAB simulation

bottom of page