Generating Optimizing and Verifying HDL Code With Matlab and Simulink PDF
Generating Optimizing and Verifying HDL Code With Matlab and Simulink PDF
Puneet Kumar
Application Engineering Team
Q&A
2
Algorithm Development Process
Requirements
Test
Gain insight into problem
Implementation
Desktop Embedded
Design
.dll C, C
C++
Test
.exe VHDL / Verilog
Elaborate
.c,
C, .cpp
C++ Structured Text
3
The Algorithm Design Challenge
– Reuse designs on a
variety of hardware?
FPGA
MCU ASIC
DSP FPGA ASIC
4
Solution: C and HDL Code Generation
Generate
Generate
Deploy generated code on
hardware
C VHDL/Verilog
FPGA
MCU ASIC
DSP FPGA ASIC
5
Code Generation Products for VHDL/Verilog
HDL Coder™
HDL Coder Automatically generate VHDL or Verilog
from MATLAB code and Simulink Model
MATLAB® Coder™
MATLAB Coder Automatically generate C and C++ from
MATLAB code
Fixed-Point Designer™
Fixed-Point Designer provides fixed-point data types and
arithmetic
6
Best Practice 1:
Algorithm and System Design
with Fixed-Point Quantization Analysis
7
Best Practice 1:
Algorithm and System Design
with Fixed-Point Quantization Analysis
Best Practice 2:
Automatic
HDL Code Generation
8
Best Practice 1:
Algorithm and System Design
with Fixed-Point Quantization Analysis
Best Practice 2:
Best Practice 3:
Automatic
HDL Cosimulation
HDL Code Generation
9
Best Practice 1:
Algorithm and System Design
with Fixed-Point Quantization Analysis
Best Practice 2:
Best Practice 3:
Automatic
HDL Cosimulation
HDL Code Generation
Best Practice 4:
FPGA Hardware-in-the-Loop
10
Audio Equalizer
(A Brief Example)
11
Semtech Speeds Development of
Digital Receiver FPGAs and ASICs
Challenge
Accelerate the development of optimized digital
receiver chains for wireless RF devices The Semtech SX1231 wireless transceiver.
Solution
Use MathWorks tools for Model-Based Design to
generate production VHDL code for rapid FPGA “Writing VHDL is tedious, and the
and ASIC implementation handwritten code still needs to be
verified. With Simulink and Simulink
Results
HDL Coder, once we have simulated
Prototypes created 50% faster
Verification time reduced from weeks to days the model we can generate VHDL
Optimized, better-performing design delivered directly and prototype an FPGA. It
saves a lot of time, and the generated
code contains some optimizations we
hadn’t thought of.”
Frantz Prianon
Semtech
12
HDL Coder
Generate VHDL and Verilog Code for FPGA and ASIC designs
Algorithm-to-HDL traceability
13
Model-Based Design flow using MATLAB/Simulink
from Algorithm to FPGA Implementation
DESIGN
HDL Verifier
FPGA in the Loop
14
Algorithm to HDL Workflows
1. Simulink to HDL
(with MATLAB and Stateflow)
2. MATLAB to HDL 1
2
3. Hybrid workflow
VHDL &
VHDL & Verilog
Verilog
15
Using HDL Coder: 5-Step Workflow
Prepare your MATLAB algorithm for code generation
Prepare • Use supported language features
• Make implementation choices
Communications Blocks
– Psuedo-random Sequence Generators,
Modulators / Demodulators, Interleavers /
Deinterleavers, Viterbi Decoders
17
Agenda
Integrated Workflow for FPGA/ASIC Development
Q&A
18
From Algorithm to Synthesizable RTL
MATLAB® and Simulink®
Algorithm and System Design
Model Refinement for Hardware
Automatic HDL
HDL Co-Simulation
Code Generation
Behavioral Simulation
Back Annotation
FPGA Hardware
FPGA-in-the-Loop
19
Best Practice 1
Use modeling and simulation to optimize at the system level
Optimize on fixed-point
word-length to reduce
area and power
Full bi-directional
traceability!!
Requirements
21
Speed optimization
Use pipelining to improve speed
22
Area optimization
Use sharing and streaming to reduce area
Automatically generated
validation models
Use sharing
and streaming
to reduce area
Multipliers 10
Adders/Subtractors 36
Registers 292 Resource utilization reports
provide early feedback on
RAMs 2 resource utilization
Multiplexers 116
23
Agenda
Integrated Workflow for FPGA/ASIC Development
Q&A
24
Which tests do you
perform today?
25
Verification Landscape:
26
Verification Challenges:
Stimuli-Driven Test Bench in HDL Simulators
28
Audio Equalizer
• Bank of 10 filters
• Controllable by up to +/-6dB
• 5 pre-programmed user settings for
• Rock, Pop, Jazz, Classical, Vocal
• Fits into available FPGA space
• No dead-locks or unreachable states
• Sounds good
29
Automatically Measuring Test Coverage
Audio Equalizer
Automatically
collect and report
test coverage
Missed 100%
coverage coverage
30
Test Generation for 100% Coverage
Audio Equalizer
Automatically generate
tests to reach coverage
objectives
31
Integrate with HDL Code Coverage
Audio Equalizer
32
Best Practice 3
Re-use System Level Test Bench for HDL Verification
33
HDL cosimulation to verify HDL
Re-use System Level Test Bench for HDL Verification
HDL Cosimulation
Integrate with
Flexible test bench creation: Also works with
Modelsim/Questa
closed loop, multi domain handwritten code
and Incisive
34
Best Practice 4
Enable regression testing with FPGA-in-the-loop simulation
35
FPGA-in-the-loop
Enable regression testing with FPGA-in-the-loop simulation
Re-use test benches for Integrate with Altera / Xilinx
regression testing FPGA Development Boards
36
Automation FPGA-in-the-loop Verification
Supported FPGA boards
Automatic creation of
FPGA-in-the-loop
verification models
37
Additional Methods for Verification
HDL Verification Techniques
38
Stimuli-based test benches for
standalone verification
MATLAB or Simulink Test bench
MATLAB or Simulink
Stimulus Design Reference Can be used in
Targeted to Hardware Results any HDL
Simulator
Automatically
generate self-
checking test
Stimulus Actual
benches
HDL Design
Results
39
MATLAB Based Verification
Input Output
stimuli response
Input Output
stimuli response
40
FPGA turnkey workflow
FPGA on target prototyping
41
Summary
Best Practice 1:
Algorithm and System Design
with Fixed-Point Quantization Analysis
Best Practice 2:
Best Practice 3:
Automatic
HDL Cosimulation
HDL Code Generation
Implement Design
Best Practice 4:
FPGA Hardware-in-the-Loop
42
FLIR Accelerates Development of
Thermal Imaging FPGA
Challenge
Accelerate the implementation of advanced thermal imaging
filters and algorithms on FPGA hardware
Solution
Use MATLAB to develop, simulate, and evaluate algorithms,
and use HDL Coder to implement the best algorithms on
FPGAs
Results “With MATLAB and HDL Coder we are much
Time from concept to field-testable prototype more responsive to marketplace needs. We
reduced by 60% now embrace change, because we can take
Enhancements completed in hours, not weeks a new idea to a real-time-capable hardware
Code reuse increased from zero to 30% prototype in just a few weeks.
There is more joy in engineering, so we’ve
increased job satisfaction as well as
customer satisfaction.”
43
Public Trainings in the next Few Months
Course Dates Location
Q&A
45
Thank You!
46