Automatic code generation from MATLAB & Simulink - · PDF fileAutomatic code generation from...
Transcript of Automatic code generation from MATLAB & Simulink - · PDF fileAutomatic code generation from...
© 2
009 T
he M
ath
Work
s, In
c.
Automatic code generation from
MATLAB & Simulink
Stephan van Beek
Senior Application Engineer
The MathWorks
2
who usesMATLAB?
3
and what about
Simulink?
4
The Digital System Design Challenge
How can we rule out bad algorithms faster?
How can implement our algorithms faster?
How can we ensure that our implementation matches our algorithm?
How can we collaborate with our hardware and software engineers? ASIC
C / C++
FPGA / ASIC MCU / DSP
HDL
MATLAB, Simulink, Stateflow
Algorithm and System Design
© 2
009 T
he M
ath
Work
s, In
c.
Introduction to Model-Based
Design
6
Problems with Traditional Development
Text-based
Prevents rapid
iteration
Prototypes
Incomplete and
expensive
Manual coding
Introduces human
error
Traditional testing
Errors found
too late in the
process
MS Word
LaTeX
Visio
MS PowerPoint
MATLAB Code
C/C++ Code
High-Level
Languages
VHDL
Verilog
C/C++
Simulation
Test Bench
Hardware Test
Environment
Requirements
and Specs
Design with
prototypes
Manual
Implementation
Test and
Verification
7
Adopting Model-Based Design
Model Elaboration
Continuous Verification
Executable models
- Unambiguous
- Only “one truth”
Design with Simulation
- Reduces “real”
prototypes
- Systematic “what-if”
analysis
Automatic code
generation
- Minimizes coding
errors
Test with Design
- Detects errors
earlier
Requirements
and Specs
Design with
prototypes
Manual
Implementation
Test and
Verification
Rapid design iterations
Automatic code
generation
Design with
Simulation
8
Model-Based Design Flow at its core
MATLAB, Simulink, Stateflow
Algorithm and System Design
C, C++
FPGA / ASIC MCU / DSP
VHDL, Verilog
System Design
and Simulation
Implement Digital Electronics
Embedded Software
Integration
© 2
009 T
he M
ath
Work
s, In
c.
Introduction to
MATLAB & Simulink
10
MATLAB at a glance
The leading environment
for technical computing
– Interactive development environment
– Technical computing language
– Data analysis and visualization
– Algorithm development
11
Simulink at a glanceThe leading environment for system-level modeling and simulation
– Block-diagram environment
– Model, simulate and analyze dynamic systems
– Build verification test-benches
– Fully integrated with MATLAB
Discrete filter in Simulink Discrete filter in C
12
Why Simulink? Model, simulate and analyze
Dynamic systems
o Multi-domain
o Multiple Rates
o Discrete and continuous
o Non-linear
Architecture exploration
o Rapidly model what-if scenarios
o Share a design idea
o Concept to implementation
13
To model and simulate complicated systems for design and verification
– Communications
– Video and image
– Audio
– Embedded
– Mixed-signal
Algorithm development– Filter design
For data analysis and visualizationE.g. data processing including
– Statistics
– Curve fitting
Why using MATLAB and Simulink?
© 2
009 T
he M
ath
Work
s, In
c.
Edge Detection Demo
15
Challenge:
=Stop sign
Bill: System Engineer
16
Wikipedia:
Sobel Algorithm for Edge Detection
DEMO
17
Challenge cont’d:
Bill: System Engineer
FPGA
John: FPGA Engineer
1%?
1 week?
DEMO
18
Summary: Sobel Edge Detection Demo
Model Elaboration
Continuous Verification
Executable models- Unambiguous
- Only “one truth”
Design with Simulation- Reduces “real” prototypes
- Systematic “what-if”
analysis
Automatic code
generation- Minimizes coding
errors
Test with Design- Detects errors
earlier
Requirements
and Specs
Design with
prototypes
Manual
Implementation
Test and
Verification
Automatic code
generation
Design with
Simulation
© 2
009 T
he M
ath
Work
s, In
c.
Automatic Code Generation Tools
from The MathWorks
20
Top-Down Design Flow - Partitioning
MATLAB, Simulink, Stateflow
Algorithm and System Design
C, C++
FPGA / ASIC MCU / DSP
VHDL, Verilog
System Design
and Simulation
Implement Digital Electronics
Embedded Software
Integration
Concept Design
Implementation
21
Hardware Implementation Flow
MATLAB, Simulink, Stateflow
Algorithm and System Design
FPGA / ASIC
Generic RTL
VHDL, Verilog
Mentor Graphics ModelSim
Cadence Incisive
Synopsys Discovery
EDA Simulator
Link
Legacy
/
External
CodeXilinx ISE
Altera
Quartus II
Synplify
Pro
PrecisionRTL
DesignCompiler
Leonardo
Filter Design HDL
Coder
Simulink HDL Coder
HDL Simulation
Synthesis
P & R
22
Green Hills MULTI
TI Code Composer Studio
Analog Devices Visual
DSP++
Altium TASKING
Targeting Embedded Microprocessors and DSPs
MATLAB, Simulink, Stateflow
Algorithm and System Design
C, C++
Embedded IDE
Link
Real Time Workshop
Embedded Coder
Real Time Workshop
Integrated Design
Environment
TI C6000
Infeneon C166
Freescale
MPC5xx
STMicroelectronics
ST10
TI C2000
Target Support
Package
Specific
Peripheral
S/W
Drivers
23
Automatic Code Generation Summary
ASIC
C / C++
FPGA / ASIC MCU / DSP
HDL
Ge
ne
rate
Ve
rify
Co-simulation
Converge on the best algorithm faster
Implement your algorithm faster
Ensure that your implementation matches your system model
Collaborate with your hardware / softwareengineers
Automatic code
generation
MATLAB, Simulink, Stateflow
Algorithm and System Design