Active-HDL Interfaces Simulink® Interface Course 13 Overview The MathWorks' MATLAB®/Simulink® simulation environment provides a powerfull high level mathematical modeling environment for DSP systems that can be.

Download Report

Transcript Active-HDL Interfaces Simulink® Interface Course 13 Overview The MathWorks' MATLAB®/Simulink® simulation environment provides a powerfull high level mathematical modeling environment for DSP systems that can be.

Active-HDL Interfaces
Simulink® Interface
Course 13
Overview
The MathWorks' MATLAB®/Simulink® simulation environment provides a
powerfull high level mathematical modeling environment for DSP systems that can
be widely used for algorithm development and verification.
Active-HDL provides an interface to MATLAB and Simulink simulation
environment, which allows co-simulation of functional blocks described by using
mathematical formulas and behavioral models described by using hardware
description languages.
The Simulink Interface provides users with the following benefits:
– Intuitive interface that fills the gap between HDL simulation and high level mathematical modeling
environment for DSP systems
– Displaying simulation results in both the Simulink environment and the Active-HDL waveform window
– Automatic value conversion between Active-HDL and Simulink
– Advanced testbenches employing complex mathematical formulas used to stimulate unit under test
– Integration with Xilinx System Generator™
All materials updated on: September 30, 2004
13.1 Using Co-Simulation Wizard for Simulink
The interface delivered with the Active-HDL installation program allows you to select a Verilog
module, EDIF cell or VHDL entity/architecture pair that will be used as a black-box during the
verification process performed within Simulink.
Before the first use of the Simulink Interface, you need to specify environment settings for
Active-HDL and set the path to the interface files delivered with the Active-HDL installation.
Since Active-HDL will be initialized during the co-simulation by Simulink, you need to modify
the $PATH variable to point to the /Bin subdirectory of the Active-HDL installation.
You need to also specify the search path (also referred to as the MATLAB Path) to the
directory where the Simulink Interface files are stored. MATLAB will use this path to find
files required during co-simulation.
All materials updated on: September 30, 2004
13.1a Using Co-Simulation Wizard for Simulink
1. Start MATLAB.
2. Choose the Set Path command
from the File menu.
This command allows to specify
the search path (also referred to
as the MATLAB Path) to the
directory where the Simulink
Interface files are stored.
MATLAB will use this path to find
files
required
during
cosimulation.
3. Click the Add Folder button and
browse
for
$ALDEC\Matlab
subdirectory.
Then, click OK.
All materials updated on: September 30, 2004
13.2 Using Co-Simulation Wizard for Simulink
- units for co-simulation
To start the co-simulation process in MATLAB environment, first you need to create
configuration files (MATLAB M-Files) for Simulink and then select units to be cosimulated.
This step can be done by using the Co-Simulation
Wizard for Simulink.
To run the Co-Simulation Wizard for Simulink
in Active-HDL:
1. Open the Active-HDL design that contains units
to be co-simulated and compile sources.
2. Expand a source file (e.g. abs.vhd) that contains
a design unit that will be used as a black-box.
3. Right-click this unit (e.g. m_abs(beh)) and
choose the Co-Simulation Wizard for
Simulink option or choose the Co-Simulation
Wizard for Simulink option from the Tools
menu
All materials updated on: September 30, 2004
13.3 Using Co-Simulation Wizard for Simulink
- interface signals
The Co-Simulation Wizard for Simulink dialog box opens.
The first Wizard's window displays all interface signals of the
unit.
All materials updated on: September 30, 2004
13.4 Using Co-Simulation Wizard for Simulink
- interface signals
1. Entity/Module
Allows you to select an entity or module to be co-simulated. You can select an
entity/architecture pair or module that you want to co-simulate (black-box) from the
pop-up menu in the Design Browser window or you can choose the Co-Simulation
Wizard for Simulink option from the Tools menu.
2. Architecture
Allows you to select an architecture associated to the entity specified in the Entity list
box.
3. Dedicated ports
This column lets you specify the ‘special’ interface signals – clock and clock enable
inputs.
4. Clock Enable
Specifies the active level of the Clock Enable signal.
All materials updated on: September 30, 2004
13.5 Using Co-Simulation Wizard for Simulink
- interface signals customization
All materials updated on: September 30, 2004
13.6 Using Co-Simulation Wizard for Simulink
- interface signals customization
1. Ports
Lists all ports of the simulated unit.
If you have specified the clock (CLK) and clock enable (CE) signals in the first window, these ports are not
displayed in the Ports column.
2. Cast
Specifies the numerical representation of a signal's value.
Available types are:Boolean for scalars, SIGN (2's Complement) and UNSIGN for vectors.
3. Number of Bits
Specifies the width of the selected signal.
4. Fractional Part
Specifies how many bits are available to the right side of the binary point (i.e. the size of the fraction). The
binary point position must fit between zero and the number of bits specified in the Number of Bits
column.
5. Quantization
Specifies the type of quantization method (available values are: truncate, round ).
6. Overflow
Specifies handling method of arithmetical overflow (available values are: saturate, wrap, error).
7. Type
Displays the type of the signal.
Supported VHDL types are: BIT, BIT_VECTOR, STD_ULOGIC, STD_ULOGIC_VECTOR, STD_LOGIC,
STD_LOGIC_VECTOR.
8. Output File
Specifies the name of the configuration file generated by Wizard. Folder containng this file should be
either added to MATLAB Search Path or set as the current directory during co-simulation.
9. Add signals to waveform
If this option is checked then interface signals selected in the last wizard window will be added to the
waveform editor during simulation.
All materials updated on: September 30, 2004
13.7 Using Simulink Co-Simulation Wizard
- ALDEC Blockset library
The Co-Simulation Wizard for Simulink creates the
configuration files (MATLAB M-Files) dedicated for ALDEC
Active-HDL Co-Sim Toolbox library, common for all Active-HDL
designs.
This library can be found in MATLAB's Simulink Library
Browser
NOTE:
Output Directory. By default output files generated by Wizard are created in $WSP/Matlab folder .
All materials updated on: September 30, 2004
13.8 Simulation with MATLAB
Active-HDL Design Output Directory selection inside MATLAB
.
1. Start MATLAB.
2. Choose the Set Path option form the File
menu.
This option allows you to specify the path to
the directory(ies) containing file(s) that you
have specified in the Output File field of the
Co-Simulation Wizard for Simulink
window.
2. Click the Add Folder button and browse for
folder containing Output File. Then, click
OK.
3. Choose the Save option and close the Set
Path window by pressing the Close button.
All materials updated on: September 30, 2004
13.9 Simulation with MATLAB
- using simulation black boxes
The ALDEC Active-HDL Co-Sim Toolbox is available inside the
Simulink library browser.
1. Start Simulink.
2. Choose the Simulink icon
from
MATLAB's main toolbar to open the
Simulink Library Browser window.
3. In the left pane of the Simulink Library
Browser window, the ALDEC Active-HDL
Co-Sim Toolbox is displayed.
The Active-HDL Co-Sim, HDL Block, and
System Generator Compatible HDL
Block blocks are visible in the Toolbox.
All materials updated on: September 30, 2004
13.10 Simulation with MATLAB
- using simulation black boxes
User can use:
1. Active-HDL Co-Sim
2. HDL Block,
3. System Generator Compatible HDL Block
from the ALDEC Active-HDL Co-Sim Toolobox and other MATLAB simulation
libraries to create his own simulation Model.
Before user starts co-simulation, he needs to add the Active-HDL Co-Sim block
to the model window.
This block is required to successfully initialize the simulation process and it can be
used to define parameters of the co-simulation session.
The black-boxes generated by the Co-Simulation Wizard for Simulink can be
simulated after their parameters are setup.
All materials updated on: September 30, 2004
13.11 Simulation with MATLAB
- using simulation black boxes
To replace HDL Block with a unit generated by the Wizard,
double-click the symbol and specify its parameters
In the Black-Box Name field specify the name of configuration file
specified in the Output File field of Co-Simulation Wizard
for Simulink.
All materials updated on: September 30, 2004
13.12 Simulation with MATLAB
- MATLAB simulation Model
Active-HDL co-simulation
block
Active-HDL simulation
Black-box block
Simulink blocks
All materials updated on: September 30, 2004
13.13 Co-Simulation between
Active-HDL and MATLAB
1. All Aldec black boxes library are simulated with Active-HDL
simulator.
2. Run simulation from MATLAB in automatic way create inside
Active-HDL all required processes to run co-simulation with used
simulation black-boxes.
3. User can review results in MATLAB as also inside Active-HDL
waveform.
NOTE:
Waveform is created in automated way when “Add signals to Waveform” option
inside the Co-Simulation Wizard for Simulink has been selected
All materials updated on: September 30, 2004
13.14 Co-Simulation between
Active-HDL and MATLAB
After press Start Simulation button from the Simulink toolbar,
co-simulation process will be started.
Aldec Black-box simulated with
Active-HDL simulator inside of the new,
automatically created design.
All materials updated on: September 30, 2004
13.15 Simulation with MATLAB
- view simulation results
User can review simulation results inside MATLAB as also inside
the Active-HDL waveform
All materials updated on: September 30, 2004
13.16 Example of use – Active-HDL design
Open MATLAB_Example workspace.
This workspace contain Modulator design.
The design contains the following resource files:
1. abs.vhd
VHDL equivalent model of the Simulink Abs block.
2. mult.vhd, mult1.vhd
VHDL equivalent model of the Simulink Product block.
3. sign.vhd
VHDL equivalent model of the Simulink Sign block.
4. Modulation.mdl
Simulink models
All materials updated on: September 30, 2004
13.17 Design Example
– Co-Simulation Wizard for Simulink
1. Compile all files inside design
2. Use Co-Simulation Wizard for Simulink and create simulation
black-box symbols and MATLAB library
NOTE:
Next slide describes all required parameters which need to be set inside the Co-Simulation Wizard for
Simulink.
All materials updated on: September 30, 2004
13.18 Design Example
- Co-Simulation Wizard for Simulink
Please specify all required parameters for listed below modules with using CoSimulation Wizard for Simulink:
Black-Box Sample Period = 1/20
Active-HDL CoSim block Sample Period = 1/20
For SIGN block set:
Port In1: Cast = sign, Number of Bits = 31, Fractional Part = 24, Quantization = truncate, Overflow = saturate
Port Out1: Cast = sign, Number of Bits = 2, Fractional Part = 0
For MULT block set:
Port Sin_wav1: Cast = unsign, Number of Bits = 16, Fractional Part = 9, Quantization = truncate, Overflow = saturate
Port Sin_wav2: Cast = sign, Number of Bits = 16, Fractional Part = 15, Quantization = truncate, Overflow = saturate
Port Out1: Cast = sign, Number of Bits = 31, Fractional Part = 24
For MULT1 block set:
Port I_abs: Cast = unsign, Number of Bits = 31, Fractional Part = 24, Quantization = truncate, Overflow = saturate
Port I_sig: Cast = sign, Number of Bits = 2, Fractional Part = 0, Quantization = truncate, Overflow = saturate
Port Out1: Cast = sign, Number of Bits = 31, Fractional Part = 24
For ABS block set:
Port In1: Cast = sign, Number of Bits = 31, Fractional Part = 24, Quantization = truncate, Overflow = saturate
Port Out1: Cast = unsign, Number of Bits = 31, Fractional Part = 24
NOTE:
Please use in all symbols “Add signals to Waveform” option.
This item finishes the task with Co-Simulation Wizard for Simulink.
All required parameters and MATLAB design have been completed.
All materials updated on: September 30, 2004
13.19 Design Example
- MATLAB simulation model
1. Start MATLAB.
2. Set Path’ to the Simulink Interface files and to the Output File’s folder.
3. Start Simulink from the MATLAB toolbar.
4. Choose Open and open Modulator.mdl file stored inside the Active-HDL
example design Matlab_example.
Then you will have the MATLAB Simulation model as displayed in this slide.
All materials updated on: September 30, 2004
13.20 Design Example
- MATLAB simulation model
Please, add Active-HDL Co-Sim and HDL Block symbol to the Matlab Simulation Model.
Then select m_abs_beh.m inside the Configuration dialog- this will assign Active-HDL black box to the
HDL block
All materials updated on: September 30, 2004
13.21 Design Example
- MATLAB simulation model
Specify the sample period of both blocks in the dialog appearing after double-click.
For both, please set 1/20.
All materials updated on: September 30, 2004
13.22 Design Example
- create co-simulation model
Inside Modulator.mdl please replace the Simulink blocks with the corresponding black-boxes
coming from the ALDEC blockset.
Active-HDL Co-Sim block.
m_abs_beh Black-box symbol
from the Aldec library
All materials updated on: September 30, 2004
13.23 Design Example
- simulation
Please run simulation using Start Simulation button from the Simulink toolbar.
Simulation can be stopped using Stop Simulation button from the Simulink toolbar.
All materials updated on: September 30, 2004
13.24 Design Example
- waveform settings
Active-HDL waveform can display signal values in analog shape.
Please use inside the waveform signal properties to define display parameters for
m_abs symbol ports.
Please set paramaters:
•
Signal In1: Radix - decimal, Notation - Signed 2`s Complement, Display Analog, Height - 128
•
Signal Out1: Radix - decimal, Notation - Unsigned, Display - Analog, Height
- 128
All materials updated on: September 30, 2004