16
TechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme 6. European SystemC Users Group Meeting Modelling Cycle-Accurate Hardware with Matlab/Simulink using SystemC Frank Czerner, TechnoTeam Bildverarbeitung GmbH Ilmenau Jens Zellmann, Institute of Microelectronic and Mechatronic Systems gGmbH Ilmenau

6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

  • Upload
    buidang

  • View
    212

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

6. European SystemCUsers Group Meeting

Modelling Cycle-Accurate Hardwarewith Matlab/Simulink

using SystemC

Frank Czerner, TechnoTeam Bildverarbeitung GmbH Ilmenau

Jens Zellmann, Institute of Microelectronic and Mechatronic SystemsgGmbH Ilmenau

Page 2: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

Modelling Cycle-Accurate Hardwarewith Matlab/Simulink

using SystemC

• Overwiew• How to integrate SystemC Models in Simulink ?• How to generate multible persistent Objects of a

SystemC Model ?• Required extensions of the SystemC-Kernel• Examples• Conclusions and Recommendations

Page 3: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

• Where we are using SystemC ?– modelling and verification of cycle-accurate hardware

components within codesigns– new methodology for building machine vision

applications

• Why using Matlab/Simulink?– transfering this approach to a commonly used tool with

a lot of libraries– addressing other signal processing applications (i.e.

signal preprocessign in smart sensors)– basic support for hardware integration through

third-party Tools

Overview

Page 4: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

Overview

• Where we are using SystemC ?– modelling and verification of cycle-accurate hardware

components within codesigns– new methodology for building machine vision

applications

• Why using Matlab/Simulink?– transfering this approach to a commonly used tool with

a lot of libraries– addressing other signal processing applications (i.e.

signal preprocessign in smart sensors)– basic support for hardware integration through

third-party Tools

Page 5: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

How to integrate SystemC Models in Simulink ?

• S-Functions provide a powerful mechanism for extendingSimulink• With S-Functions it is possible to add customized blocks toSimulink models

MEX-file M-file

Ada, Fortran C/C++

Page 6: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

• using the fixed-step, discrete timesolver

• simulation is controlled by durationtime and step size

• output is calculated from input andfrom states at each time step

How to integrate SystemC Models in Simulink ?

Start of Simulation

mdlInitializeSizes

mdlInitializeSampleTimes

mdlTerminate

mdlOutputs

Simulation Loopy = f (t , x , u)

• the mdlOutput function iscalled at each simulation step

Initialization

Page 7: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

How to integrate SystemC Models in Simulink ?

• simulation of SystemC models is usually „stand alone“

• initialization and simulation loop is normally processed inone function

Page 8: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

How to integrate SystemC Models in Simulink ?

Integration in Simulink needs:

• a stepwise simulation cycle bycycle, which can be executed inmdlOutputs Function

using the SystemC functions sc_initialize() and sc_cycle()

• initialization of the SystemCkernel must be seperated fromsimulation

Page 9: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

• a wrapper is needed to connect Simulink ports to a SystemC-Block• converting Simulink data types to SystemC signals and vice versa• initializing of the SystemC-Kernel• converting events (function call from Simulink to sc_cycle() )• provide a DLL interface to the Simulink S-Function

Functions:

• InitModule

• SimStep

• DestroyModule

How to integrate SystemC Models in Simulink ?

SC Model

Wrapper

Page 10: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

How to generate multible persistent Objects of a SystemC Model ?

• one object of the SystemC module is createddynamically

• a pointer to this object is stored in a vector

• the pointer can be retrieved in any callbackmethod to access the object

Page 11: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

• using a module base class

• derive all modules from thisbase class

• wrapper works with baseclass objects

Conditions to build operator libraries

sc-module

+mth_process1()+mth_process2()

-sc_in-sc_out

BaseModule

Boxoperator MaxFilter...

UserOp

Page 12: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

Problem:

Solution:

Required extensions of the SystemC-Kernel

Generating of indepentent SystemC-Blocks in one Simulinkmodel fails due to the global context pointer of SystemC(static sc_simcontext* sc_curr_simcontext)

• one context pointer for each SystemC-Block

• every wrapper creates its SystemC objects (signals, tracefile, ...), stores the corresponding context pointer and sets theglobal context = NULL

• every wrapper sets the global context to its own before anyaction (sc_cycle() )

generate new module

generate next module

create objects

store current simcontext

set global simcontext = 0

Page 13: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

Problem:

Solution:

Required extensions of the SystemC-Kernel

Generating of indepentent SystemC-Blocks in one Simulinkmodel fails due to the global context pointer of SystemC(static sc_simcontext* sc_curr_simcontext)

• one context pointer for each SystemC-Block

• every wrapper creates its SystemC objects (signals, tracefile, ...), stores the corresponding context pointer and sets theglobal context = NULL

• every wrapper sets the global context to its own before anyaction (sc_cycle() )

simulation stepfirst module

simulation step next module

set current simcontext

call sc_sycle() for the currentsimcontext

Page 14: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

Example 1 - Multible Instances of a Counter Model

Page 15: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

Example 2 - Object Pixel Detection

Model of a dataflow for detecting object pixels andlabeling of them through coincidence approach

Page 16: 6. European SystemC Users Group Meeting - uni · PDF fileTechnoTeam Bildverarbeitung GmbH Ilmenau, Institut für Mikroelektronik- und Mechatronik Systeme Modelling Cycle-Accurate Hardware

TechnoTeam Bildverarbeitung GmbH Ilmenau,Institut für Mikroelektronik- und Mechatronik Systeme

Conclusions and Recommendations

• models are reusable in the design environment for machine visiondescribed before to build applications from tested operators

• one required functionality for hardware/software codesign in futureprojects is realized

• possibility of extending FPGA-Libraries from some vendors(XILINX, ALTERA)

Future Work

• modelling heterogenous systems

• hardware/software partitioning (possibly automated)

• code generation