Professional Documents
Culture Documents
Innovative Integration
2390-A Ward Ave
Simi Valley, California 93065
email: techsprt@innovative-dsp.com
Website: www.innovative-dsp.com
#XXXXXX
Rev 2.0
Table of Contents
MATLAB/Simulink X5 BSP Manual......................................................................................................................................2
Introduction................................................................................................................................................9
Key Features.......................................................................................................................................................................9
Hardware Design Using System Generator........................................................................................................................... 10
Design Flows Using System Generator........................................................................................................................... 10
Algorithm Exploration................................................................................................................................................10
Implementing Part of a Larger Design....................................................................................................................... 10
Implementing a Complete Design.............................................................................................................................. 11
System Level Modeling in System Generator................................................................................................................. 11
System Generator Blockset........................................................................................................................................ 11
Xilinx Blockset........................................................................................................................................................... 12
Innovative Integration Blockset................................................................................................................................. 13
Bit-True and Cycle-True Modeling............................................................................................................................13
Timing and Clocking.................................................................................................................................................. 14
Automatic Code Generation.............................................................................................................................................15
Compiling and Simulating Using System Generator Block.......................................................................................15
Compilation Type and the Generate Button............................................................................................................... 16
Compilation Results................................................................................................................................................... 17
HDL Testbench.......................................................................................................................................................... 17
Compiling MATLAB into an FPGA................................................................................................................................18
Importing a System Generator Design into a Bigger System................................................................................................ 19
NGC Netlist Compilation.................................................................................................................................................19
Design Rules...............................................................................................................................................................20
Synthesis ....................................................................................................................................................................20
Simulation...................................................................................................................................................................21
Step-by-Step Example................................................................................................................................................ 22
Generating the NGC files for the System Generator Designs.................................................................................... 23
Synthesizing the Top Level Design............................................................................................................................23
Using FPGA Hardware in the Loop...................................................................................................................................... 24
Compiling a Model for Hardware Co-Simulation........................................................................................................... 24
Choosing a Compilation Target..................................................................................................................................24
Invoking the Code Generator..................................................................................................................................... 24
Hardware Co-Simulation Blocks..................................................................................................................................... 25
Hardware Co-Simulation Clocking..................................................................................................................................26
Single-Step Clock....................................................................................................................................................... 26
Free-Running Clock................................................................................................................................................... 26
Selecting the Clock Mode.......................................................................................................................................... 26
Board-specific I/O Ports...................................................................................................................................................27
Installation Instructions.......................................................................................................................... 29
Design Flow...............................................................................................................................................30
Start a New Design Using System Generator........................................................................................................................30
Solutions for Timing Problems..............................................................................................................................................31
Integrate the Design into FPGA.............................................................................................................................................33
Advanced Skills........................................................................................................................................ 36
System Generator™ for DSP is the industry’s leading high-level tool for designing high performance DSP systems using
FPGAs. The tool provides abstractions that enable designers to develop high performance signal processing algorithms with
the industry’s most advanced FPGAs, providing system modeling and automatic code generation from Simulink and
MATLAB (The MathWorks, Inc.)
Innovative Integration products, including the Velocia DSP and PMC cards, support FPGA development and debug through
board support packages (BSP) that integrate the hardware with the System Generator with MATLAB. The BSP packages
provide direct access to the hardware from the MATLAB environment for real-time, hardware-in-the-loop testing and debug.
Key Features
• DSP Modeling. Build and debug high performance DSP systems in Simulink using Xilinx Blockset and Innovative
Board Support Package (BSP). Xilinx blockset contains functions for signal processing such as FIR Filters and
FFTs, error correction (i.e. Viterbi decoder, Reed-Solomon encoder/decoder), arithmetic, memories (e.g. FIFO,
RAM,) and digital logic. The Innovative blockset contains functions for accessing various features on the board
such as DDR memory, ADC, DAC, SBSRAM, RocketIO, PMC J4 interface.
• Automatic code generation of VHDL or Verilog from Simulink. Implement behavioral (RTL) generation and
target specific IP cores from the Xilinx blockset. There is also a limited but useful ability to generate RTL functions
written in MATLAB.
• Hardware co-simulation. Create an “FPGA-in-the-Loop” simulation target: a code generation option that allows
you to validate working hardware and accelerate simulations in Simulink and MATLAB.
• Hardware/software co-design of embedded systems. Build and debug DSP co-processors for the Xilinx
MicroBlaze™ 32-bit RISC processor. System Generator provides a shared memory abstraction of the HW/SW
interface, automatically generating the DSP co-processor, the bus interface logic, software drivers, and software
documentation for using the co-processor.
System Generator is a system level modeling tool that facilitates FPGA hardware design. It extends Simulink in many ways
to provide a modeling environment that is well suited to hardware design. The tool provides high level abstractions that are
automatically compiled into an FPGA at the push of a button. The tool also provides access to underlying FPGA resources
through low level abstractions, allowing the construction of highly efficient FPGA designs.
Algorithm Exploration
System Generator is particularly useful for algorithm exploration, design prototyping, and model analysis. When these are
the goals, the tool is used to flesh out an algorithm in order to get a feel for the design problems that are likely to be faced,
and perhaps to estimate the cost and performance of an implementation in hardware. Work is preparatory, and there is little
need to translate the design into hardware.
In this setting, a designer assembles key portions of the design without worrying about fine points or detailed
implementation. Simulink blocks and MATLAB .m code provide stimuli for simulations, and for analyzing results.
Resource estimation gives a rough idea of the cost of the design in hardware. Experiments using hardware generation can
suggest the hardware speeds that are possible.
Once a promising approach has been identified, the design can be fleshed out. System Generator allows refinements to be
done in steps, so some portions of the design can be made ready for implementation in hardware, while others remain high
level and abstract. System Generator's facilities for incremental netlisting and hardware co-simulation are particularly useful
when portions of a design are being refined.
A typical approach to this flow is to create an HDL wrapper that represents the entire design, and to use the System
Generator portion as a component. The non-System Generator portions of the design can also be components in the wrapper,
or can be instantiated directly in the wrapper.
• A clock wrapper that encloses the design. This clock wrapper produces the clock and clock enable signals that the
design needs.
• A HDL testbench that encloses the clock wrapper. The testbench allows results from Simulink simulations to be
compared against RTL simulations in a tool such as ModelSim.
• Project files and scripts that allow various synthesis tools (XST and Synplify) to operate on System Generator
HDL.
• Files that allow the System Generator HDL to be used as a project in Project Navigator
System Generator allows designs to be composed from a variety of ingredients. Data flow models, traditional hardware
design languages (VHDL, Verilog, and EDIF,) and functions derived from the MATLAB programming language, can be
used side-by-side, simulated together, and synthesized into working hardware. System Generator simulation results are bit
and cycle-accurate. This means results seen in simulation exactly match the results that are seen in hardware. System
Generator simulations are considerably faster than those from traditional HDL simulators, and results are easier to analyze.
System Generator blocks are bit-true and cycle-true. Bit-true blocks produce values in Simulink that match corresponding
values produced in hardware; cycle-true blocks produce corresponding values at corresponding times. This is in essence a
“what you see is what you get” system that accurately represents the system performance in time and bits.
Xilinx Blockset
The Xilinx Blockset is a family of libraries that contain basic System Generator blocks. Some blocks are low level,
providing access to device-specific hardware. Others are high level, implementing signal processing and advanced
communications algorithms. For convenience, blocks with broad applicability (e.g., the Gateway I/O blocks) are members of
several libraries. Every block is contained in the Index library as follows
Library Description
A simple System Generator model illustrates the behavior of discrete time systems. Consider the model shown
below. It contains a gateway that is driven by a Simulink source (Sine Wave,) and a second gateway that drives a
Simulink sink (Scope.)
The Gateway In block is configured with a sample period of one second. The Gateway Out block converts the
Xilinx fixed-point signal back to a double (so it can analyzed in the Simulink scope,) but does not alter sample rates.
The scope output below shows the unaltered and sampled versions of the sine wave.
Before a System Generator design can be simulated or translated into hardware, the design must include a System Generator
block. When creating a new design, it is a good idea to add a System Generator block immediately because it defines how
the system will be compiled. The System Generator block is a member of the Xilinx Blockset's Basic Elements and Tools
libraries. As with all Xilinx blocks, the System Generator block can also be found in the Index library.
A design must contain at least one System Generator block, but can contain several System Generator blocks on different
levels (one per level.) A System Generator block that is underneath another in the hierarchy is a slave; one that is not a slave
is a master. The scope of a System Generator block consists of the level of hierarchy into which it is embedded and all
subsystems below that level. Certain parameters (e.g. Simulink System Period) can be specified only in a master.
Once a System Generator block is added, it is possible to specify how code generation and simulation should be handled.
The block's dialog box is shown below:
• Bitstream - produces an FPGA configuration bitstream that is ready to run in a hardware FPGA platform
• EDK Export Tool - for exporting to the Xilinx Embedded Development Kit
HDL Netlist is the type used most often. In this case, the result is a collection of HDL and EDIF files, and a few auxiliary
files that simplify downstream processing. The collection is ready to be processed by a synthesis tool (e.g., XST,) and then
fed to the Xilinx physical design tools (i.e. ngdbuild, map, par, and bitgen) to produce a configuration bitstream for a Xilinx
FPGA.
NGC Netlist is similar to HDL Netlist but the resulting files are NGC files instead of HDL files.
When targeting the compile for hardware co-simulation, System Generator produces an FPGA configuration bitstream that is
ready to run in a hardware FPGA platform. The particular platform depends on the variety chosen. For example, when the
variety is Hardware Co-simulation->UWB, the bitstream is suitable for the UWB PMC board. System Generator also
produces a hardware co-simulation block to which the bitstream is associated. This block is able to participate in Simulink
Compilation Results
The low level files System Generator produces when HDL Netlist is selected on the System Generator block and Generate is
pushed consist of HDL, NGC, and EDIF that implement the design. In addition, System Generator produces auxiliary files
that simplify downstream processing, e.g., bringing the design into Project Navigator, simulating using ModelSim, and
synthesizing using various synthesis tools. All files are written to the target directory specified on the System Generator
block. If no testbench is requested, the key files produced by System Generator are the following:
.edn and .ngc files Besides writing HDL, System Generator runs CORE Generator (coregen) to implement
portions of the design. Coregen writes EDIF files whose names typically look something like
multiplier_virtex2_6_0_83438798287b830b.edn. Other required files may be supplied as
.ngc files
globals This file consists of key/value pairs that describe the design. The file is organized as a Perl
hash table so that the keys and values can be made available to Perl scripts using Perl evals.
<design>_cw.xcf (or This contains timing and port location constraints. These are used by the Xilinx synthesis
.ncf) tool XST and the Xilinx implementation tools. If the synthesis tool is set to something other
than XST, then the suffix is changed to .ncf.
<design>_cw.ise This allows the HDL and EDIF to be brought into the Xilinx project management tool Project
Navigator.
hdlFiles This contains the full list of HDL files written by System Generator. The files are listed in
the usual HDL dependency order.
synplify_<design>.prj, These files allow the design to be compiled by the synthesis tool you specified
or
xst_<design>.prj
HDL Testbench
Ordinarily, System Generator designs are bit and cycle-accurate, so Simulink simulation results exactly match those seen in
hardware. There are, however, times when it is useful to compare Simulink simulation results against those obtained from an
HDL simulator. In particular, this makes sense when the design contains black boxes. The Create Testbench checkbox in the
System Generator block makes this possible.
2. Various .dat files that contain test vectors for use in an HDL testbench simulation
3. Scripts vcom.do and vsim.do that can be used in ModelSim to compile and simulate the testbench, comparing
Simulink test vectors against those produced in HDL
System Generator generates the .dat files by saving the values that pass through gateways. In the HDL simulation, input
values from the .dat files are stimuli, and output values are expected results. The testbench is simply a wrapper that feeds the
stimuli to the HDL for the design, then compares HDL results against expected ones.
In order to construct an MCode block, an M-function must be written. The M-file must be in the directory of the model file
that is to use the M-file or in a directory in the MATLAB path. Additional examples can be found at the System Generator
User Guide.
A System Generator design is often incorporated as a part of a larger HDL design. This section shows how to embed two
System Generator designs into a larger design, and how VHDL created by System Generator can be incorporated into a
simulation model of the overall system.
The most convenient way to incorporate a System Generator design into an HDL design is to encapsulate the entire design
into a single binary module in the NGC binary netlist format used by the Xilinx ISE tool suite. In this case, the System
Generator design is viewed as a black box by the logic synthesis tool.
The design flow to import a System Generator design into a larger system is shown in Figure 6.
When System Generator is configured to include clock wrapper logic, the design is compiled into <design>_cw.ngc in the
target directory, where <design> is derived from the name of the portion of the System Generator model being compiled.
Alternatively, the design is saved as <design>.ngc when the clock wrapper is not included.
The NGC netlist contains both the logic and constraint information for your design. This means that all HDL, cores, and
constraint files normally created by System Generator are encapsulated within a single file. We will show how multiple
NGC files can be used as modules in a larger design.
Design Rules
When a System Generator model is to be included into a larger design, there are two design rules that must be followed.
First, no Gateway or System Generator block should specify an IOB/CLK location constraint. Otherwise, the NGDBuild tool
will issue the following warning:
WARNING:NgdBuild:483 - Attribute "LOC" on "clk" is on the wrong type of object. Please see the Constraints Guide for
more information on this attribute.
Second, I/O buffers must not be inserted in the NGC netlist during synthesis. Instead, I/O buffers should be instantiated in
the top level HDL code. Second, I/O buffers must not be inserted in the NGC netlist during synthesis. Instead, I/O buffers
should be instantiated in the top level HDL code.
Synthesis
Figure 8 shows the synthesis flow for an entire design when the NGC Netlist compilation target is used.
The System Generator NGC module can be directly instantiated inside the top level VHDL entity as follows:
component foo_cw is
port ( . . .
);
end component;
To make this process easier, System Generator creates an HDL component instantiation template when the design is
compiled using the NGC target. When VHDL is selected as the hardware description language, the template is saved in the
target directory as <design>_cw.vho (or <design>.vho when the clock wrapper is excluded.) The file is saved using a .veo
extension when Verilog is selected as the hardware description language. You may use the component template to instantiate
the component in your top level entity.
The box_type attribute should be used when synthesizing your VHDL with XST and the syn_black_box attribute should be
used with Synplify.
Simulation
When you compile a System Generator model into an NGC target, the VHDL files created by System Generator are
necessary only for HDL simulation. They should not be included into the Project Navigator project for synthesis. This
increases the performance of Project Navigator and synthesis of the top level.
If you wish to run the entire design through an HDL simulator, you need to specify a custom ModelSim .do file in Project
Navigator, since the VHDL files are not included in the project. In addition to the VHDL files, you will need to place the
memory initialization (.mif) and coefficient (.coe) files in the same directory as the VHDL files
The files used in this example are provided in <path_to_sysgen>\examples\import. The default path to sysgen would be
$MATLAB\toolbox\xilinx\sysgen. The following files are provided:
• Open the first design, spram.mdl, in MATLAB. This is a multirate design due to the down sampling block placed
after the output of the Single Port RAM. You should verify the constraints for this design have been applied
properly by looking at the PAR report
• Double click on the System Generator block, select the NGC Netlist target and press the Generate button. By
pressing the Generate button, the NGC file for this design is created in the
<path_to_sysgen>\examples\import\ngc_netlist1 directory
• Repeat steps 1 and 2 for the mac_fir.mdl model. The NGC file for this design is created in the
<path_to_sysgen>\examples\import\ngc_netlist2 directory
• Copy all the .ngc files from the ngc_netlist1 and ngc_netlist2 directories to the top_level project directory so that
NGDBUILD can fill the Black Box in the top_level.vhd file. The .ngc files created are named spram_cw.ngc and
mac_fir_cw.ngc
There are a few important things to keep in mind during each phase of the process.
• IOB constraints should not be specified on Gateways in the System Generator model; neither should the System
Generator block specify a clock pin location
• Use the NGC Netlist compilation target in the System Generator block. The NGC netlist file that System Generator
produces contains both the logic and constraint information for your design
• Use a black box and assign the appropriate black box attribute
• The ce port is not connected to registers within your design. It is provide so that the VHDL file can be imported as a
Black Box within System Generator
System Generator provides hardware co-simulation, making it possible to incorporate a design running in an FPGA directly
into a Simulink simulation. “Hardware Co-simulation” compilation targets automatically create a bitstream and associate it
to a block. When the design is simulated in Simulink, results for the compiled portion are calculated in hardware. This
allows the compiled portion to be tested in actual hardware, and can speed up simulation dramatically.
The code generator produces a FPGA configuration bitstream for your design that is suitable for hardware co-simulation.
System Generator not only generates the HDL and netlist files for your model during the compilation process, but it also runs
the downstream tools necessary to produce an FPGA configuration file.
The configuration bitstream contains the hardware associated with your model, and also contains additional interfacing logic
that allows System Generator to communicate with your design using a physical interface between the platform and the PC.
This logic includes a memory map interface over which System Generator can read and write values to the input and output
ports on your design. It also includes any platform-specific circuitry (e.g., DCMs, external component wiring) that is
required for the target FPGA platform to function correctly.
The hardware co-simulation block assumes the external interface of the model or subsystem from which it is derived. The
port names on the hardware co-simulation block match the ports names on the original subsystem. The port types and rates
also match the original design.
Single-Step Clock
In single-step clock mode, the hardware is kept in lock step with the software simulation. This is achieved by providing a
single clock pulse (or some number of clock pulses if the FPGA is over-clocked with respect to the input/output rates) to the
hardware for each simulation cycle. In this mode, the hardware co-simulation block is bit-true and cycle-true to the original
model.
Because the hardware co-simulation block is in effect producing the clock signal for the FPGA hardware only when Simulink
awakens it, the overhead associated with the rest of the Simulink model's simulation, and the communication overhead (e.g.
bus latency) between Simulink and the FPGA platform can significantly limit the performance achieved by the hardware. As
a general rule of thumb, as long as the amount of computation inside the FPGA is significant with respect to the
communication overhead (e.g. the amount of logic is large, or the hardware is significantly over-clocked,) the hardware will
provide significant simulation speed-up.
Free-Running Clock
In free-running clock mode, the hardware runs asynchronously relative to the software simulation. Unlike the single-step
clock mode, where Simulink effectively generates the FPGA clock, in free-running mode, the hardware clock runs
continuously inside the FPGA itself.
In this mode, simulation is not bit and cycle true to the original model, because Simulink is only sampling the internal state of
the hardware at the times when Simulink awakes the hardware co-simulation block. The FPGA port I/O is no longer
synchronized with events in Simulink. When an event occurs on a Simulink port, the value is either read from or written to
the corresponding port in hardware at that time. However, since an unknown number of clock cycles have elapsed in
hardware between port events, the current state of the hardware cannot be reconciled to the original System Generator model.
For many streaming applications, this is in fact highly desirable, as it allows the FPGA to work at full speed, synchronizing
only periodically to Simulink.
In free-running mode, you must build explicit synchronization mechanisms into the System Generator model. A simple
example is a status register, exposed as an output port on the hardware co-simulation block, which is set in hardware when a
condition is met. The rest of the System Generator model can poll the status register to determine the state of the hardware.
You can interface to these types of components by including board-specific I/O ports in your System Generator models. A
board-specific port is a port that is wired to an FPGA pad when the model is compiled for hardware co-simulation. Note that
this type of port differs from standard co-simulation ports that are controlled by a corresponding port on a hardware co-
simulation block.
A board-specific I/O port is implemented using special non-memory mapped gateway blocks that tell System Generator to
wire the signals to the appropriate FPGA pins when the model is compiled into hardware. To connect a System Generator
signal to a board-specific port, connect the appropriate wire to the special gateway (in the same way as is done for a
traditional gateway.)
Non-memory mapped gateways that are common to a specific device are often packaged together in a Simulink subsystem or
library. The Innovative Integration BSP, for example, provides a library of external device interface subsystems, including
analog to digital converters, digital to analog converters, RocketIOs, and external memory. The interface subsystems are
constructed using Gateways that specify board-specific port connections. These subsystems are treated like other System
Generator subsystems during simulation (i.e., they perform double precision to Xilinx fixed-type conversions.) When
System Generator compiles the design into hardware it connects the signals that are associated with the Gateways to the
appropriate external devices they signify in hardware.
Before installing Innovative Integration Board Support Package, MATLAB/Simulink, Xilinx ISE, and System Generator
need to be pre-installed and updated to the latest version. The software requirements for different products varies and are
listed in the beginning of corresponding chapters.
1. Open MATLAB.
4. Restart MATLAB.
Please be sure that the files under <X5 root>\<product_name>\MATLAB are not “read-only” before starting the design.
1. Under MATLAB/Simulink environment, designers can build the project using Xilinx System Generator blockset.
Simulate the project with the sources and sinks in Simulink and verify the functions.
2. Attach the logic to the hardware blocks using Innovative Integration library.
3. Compile the design and run hardware co-simulation with devices on the board.
4. Integrate the design into the logic, locating in <X5 root>\<product_name>\Logic\Rev#, as described in the next
section.
Step 3 may be skipped if the logic is well simulated or having serious timing problem compiling with Jtag component.
II blocksets
High timing score issue may still occur in the compilation. There are several solutions described as follows,
2. Locate the timing problems using Xilinx “Timing Analyzer.” Use Timing Improvement Wizard to locate the error
and eliminate the timing issues. Many problems are solved by simple pipelining of the logic using registers to
reduce the number of logic levels and improve speed. Or avoid the combinatorial logic in the design. If there is any
static path in the design, you can put a TIG constraint in the ucf file.
3. Rearrange the area constraints using Xilinx “Floorplanner.” The information from Timing Analyzer may give you
an idea to improve the constraint.
(a)
(b)
(c)
Figure 20. In the example, the gray areas need to be modified.
Please refer to Xilinx System Generator v10.1.2 User Guide, “Importing a System Generator Design into a Bigger
System” for more details.
Figure 22. X5 400M library and the non-memory gateways under the mask
FrameWork Logic
MATLAB
/Simulink
For hardware co-simulation, you will generate a bitstream that you can run the design in FPGA and interact with Simulink.
Double-click on the System Generator token, choose the compilation target, and generate a bitstream for hardware co-
simulation. You can choose XFLOW options files to have more controls in the compilation. The files provided by II are in
<Xilinx_root>\DSP_Tools\sysgen\plugins\compilation\Hardware Co-Simulation\X5_400M\balanced_jtag.opt.
In MATLAB command window, you need to give ts a value for compilation. If the system is running at 200 MHz, so please
type “ts=1/200e6;”.
If the project is compiled without any timing problem, a hardware co-simulation block and a bit file are generated in the
target folder. We can create signal sources from Simulink toolbox and send them to FPGA through jtag cable.
Open the hwcosim block and set the clock in free running mode. If you are running the example, please check if the
bitstream path is correct. Now you can click the play button and run co-simulation with the hardwares on the board.
Because the machine generated jtag interface may cause timing problems in the compilation, users can choose to skip
hardware co-simulation and implement the design in the FrameWork Logic. You can follow the descriptions in Chapter 3
“Integrate the Design into FPGA” and generate a standalone bitstream for FPGA.
In the UWB Simulink project, right click on the “System Configuration” block. Disable the link to the library and look under
the mask, as shown in the figures below. If you are interested in adjusting the value of adc0_gain on the fly, break the
connection between the subsystem “adc0_gain” and Mux4. Add a “Gateway In” and setup the bit width and period. This
new gateway will be synthesized as a port in the hardware co-simulation. If you are interested in monitoring a static signal, it
can be done by adding a “Gateway Out” on the signal. Restricted by the speed of the Jtag cable, you need to use either
SRAM or shared memory to watch the fast-changing signal in the Simulink.
1. Connect the project with II blocks and remove all memory map gateways used by MATLAB/Simulink. Then add
the new yellow gateways that you want to be new IO ports of component “<project_name>_cw” in FrameWork
Logic. Select “NGC Netlist” in the System Generator token and generate the “<project_name>_cw.ngc.”
Software Prerequisites
You must have the following software installed before installing II DSP LIB.
● Xilinx ISE Foundation v10.1.02 (Service Pack 2) or later, along with the full version of the ISE Simulator.
Overview
This library provides reference designs for projects. They are built using black box in System Generator and may be good
examples showing that how to write a VHDL code and how to import IP cores from Xilinx Core Generator. The library
folder is in C:\Innovative\Sysgen\II_DSP_LIB.
reset In Reset
ii_flow_ctrl
This component moves data between FIFOs. It has two modes, which are bleed mode and drip mode. It can empty the last
point by watching src_empty flag in the slower drip mode. Port “src_rdcnt” and “dest_wrcnt” data width is auto-detected and
assigned. The “Destination FIFO Almost Full Threshold” can be changed for different size FIFO to make the decision when
to stop reading.
reset In Reset
Joiner joins the data from two parallel data channels. This component is used to reassemble data streams from parallel
processing paths and make it a consecutive data stream for the next stage.
Joiner paces the data flow using “dest_rdy” from the destination and “dest_fifo_af” to the source. Unless there is a
decimation algorithm in the design, size of data stream for each channel needs to be the same in splitter and joiner.
reset In Reset
reset In Reset
ii_shifter
This component shifts the 32 bits data toward MSB or LSB using ports “direction” and “num_shift.” Port “direction” is a
Boolean doing left shift when it is high. Port “num_shift” is a 5 bits unsigned input for how many bits to be shifted.
reset In Reset
ii_divider
This component is doing division by simply subtracting divisor from dividend every clock cycle. The widths of dividend,
divisor, quotient, and remainder are 32 bits.
reset In Reset
dividend[31:0] In Dividend
divisor[31:0] In Divisor
ii_burst256
This component bursts 256 points when source FIFO has 256 points available for read. Width of “src_rdcnt” is auto-detected
and assigned.
reset In Reset
Xilinx document ug175.pdf says: “Example below is a FIFO with a 1:4 aspect ratio (write width = 2, read width = 8). In this
figure, four consecutive write operations are performed before a read operation can be performed. The first write operation is
10, followed by 11, 00, and finally 01. The memory is filling up from the right to the left (LSB to MSB). When a read
operation is performed, the received data is 01_00_11_10.”
On p.69 of ug 175.pdf, it says: “Example shows a FIFO with an aspect ratio of 4:1 (write width of 8, read width of 2). In this
example, a single write operation is performed, after which four read operations are executed. The write operation is
11_00_01_11. When a read operation is performed, the data is received left to right (MSB to LSB). As shown, the first read
results in data of 11, followed by 00, 01, and then 11.”
reset In Reset
Software Prerequisites
You must have the following software installed before installing the Board Support Package.
● Xilinx ISE Foundation v10.1.02 (Service Pack 2) or later, along with the full version of the ISE Simulator.
Note: Please find a compatible version of MATLAB and System Generator in the link.
http://www.xilinx.com/ise/optional_prod/system_generator.htm
Note: The Microsoft Windows environment variable $XILINX must be set and point to your ISE software installation
directory. ISE software service packs may be downloaded from the Software Updates Center.
Overview
The block diagram below shows hardware structure inside FPGA. The blue components are infrastructures for
communication with onboard devices, such as DDR, QDR, ADC, DAC. The white block is MATLAB/Simulink component
allowing us to do graphical design and hardware co-simulation. The green blocks are II blocks to talk to the infrastructures.
Your design can be built and simulated using Xilinx System Generator. Then you can put the project on the datapath and use
the interface component as required. The whole design can be compiled to a bitstream, downloaded to FPGA, and simulated
with hardware. After the design is verified in hardware co-simulation, jtag gateways can be removed and the project can be
synthesized as a stand alone logic in the hardware.
Offset/ ADC0
DDR2 32
gain FIFO
Queue 0 32i32o
Alert Offset/
32
gain
128 32
DDR Trigger
Queue 0
Offset/ ADC1
Packetizer
gain FIFO
32i32o
ADC0 Offset/
gain
32
ADC1
64 PCIE Offset/ DAC0
PCIE INTF User Design gain FIFO
DAC0 32i16o
Offset/
16
gain
DAC1
Trigger
MATLAB/ 32
Simulink DDR QDR Offset/ DAC1
64 Queue 1 SRAM gain FIFO
32i16o
Offset/
128 16
gain
deframer DDR2
Queue 1 QDR Digital IO DAC
SRAM /Serial RapidIO SPI
Figure 45. X5 400M block diagram
The configuration panel in “ADC0 INTF” block provides the controls to trigger, enable frame mode, and calibrations without
host software. When “Use External Trigger” is checked, trigger from SYNC port is used as ADC/DAC trigger. When
“Trigger Type” is set to “Level,” ADC samples data when trigger is high. When “Trigger Type” is set to “Positive Edge,”
ADC samples data after the first positive edge of trigger.
There is an embedded flow control for ADC interface. For example, you can use destination FIFO “not empty” flag as
dest_rdy for adc0_intf; or you can watch the destination FIFO “write count” and send a ready flag when the count is less than
a threshold.
DAC INTF
This component is passing data for triggering at sample clock and error correction. Settings, such as software trigger, are
from Simulink when “en_config = 1” in System Configuration block. Test signal is enabled when “test = 1” for both DAC
channels. Port “test mode = 0” enables a ramp, and “test mode = 1” enables a sine wave generator.
Ports "phase_inc0" and "phase_inc1" are the phase increment for the dual tone sine wave generator.
The configuration panel provides the controls for calibration and enable frame mode without host software. When “Use
External Trigger” is checked, trigger from SYNC port is used as ADC/DAC trigger. When “Trigger Type” is set to “Level,”
ADC samples data when trigger is high. When “Trigger Type” is set to “Positive Edge,” ADC samples data after the first
positive edge of trigger. Data can be sent with a valid signal by watching the level of ready flag.
wr In Write strobe
DDR INTF
In X5-400M, two 256 MByte queues of virtual FIFO have been implemented. Each queue is independently managed and is
essentially a large data FIFO for each ADC and DAC data flow. For the 128 bits “din” and “dout” ports, the first 16 bits data
should be aligned to the MSB, and the last data is aligned to LSB as follows. The queues can be used for any purpose. In the
FrameWork Logic, the queues are used to buffer the incoming data from ADCs and outgoing data to the DACs.
wr In Write strobe
rd In Read strobe
ii_interleaver
This component interleaves incoming 32 bits data from two input channels as follows.
reset In Reset
din[31:0] In Data in
wr In Write strobe
ii_deinterleaver
This component deinterleaves incoming 128 bits data to two output channels as follows.
reset In Reset
din[127:0] In Data in
reset In Reset
wr In Write strobe
There are three addresses. Ports “wr addr” and “rd addr” are for MATLAB/Simulink read/write in slow mode; another
“address” is in the ii_sram_intf.vhd for fast read/write in real-time. SRAM uses “wr addr” and “rd addr” when
“fast_mode='0'” and “address” when “fast_mode='1'.” Due to the limited bandwidth of Xilinx JTAG pod, MATLAB can
only read/write using slower jtag clock and “wr addr” and “rd addr.” If real-time read/write is required, “wr” and “rd” is
connected to the data valid of the incoming data, and the address increases with system clock. So fast data logging and
playback can be accomplished.
SRAM interface provides address and data control with specific support for MATLAB use. Port “wr addr” and “rd addr” and
“end_addr” provide the flexibility to read/write a specific chunk of data in SRAM. Port “fast_mode” allows SRAM to be
accessed with FPGA system clock. Port “rollover” provides the function to wrap the address back to 0 when “end_addr” is
reached, thus providing a circular buffer.
wr In Write strobe
rd In Read strobe
where “ref_clk” is the clock source from on board crystal or external clock; and interpolation can be 1, 2, 4 to match the input
data rate plllock (dac_clk), which is basically the same as ref_clk, and output sample rate (Fdac) of DAC5687. There are
some examples in the following table. More complicated operations can be done by changing the register values through the
SPI interface. Please download the datasheet for advanced applications.
(http://focus.ti.com/docs/prod/folders/print/dac5687.html )
wr In Write strobe
Digital IO
This component is a simple digital IO port that has an input register and output register. It may be used as a simple digital
control port or easily customized. Port “dio_en” controls a mux to use data from the software or MATLAB/Simulink project.
The 16 bit “rx_data” is connected to a register, which is written when “rd” is low. “tx_data” writes the output register when
“wr” is high. The source VHDL is available in <X5 root>\400M\Logic\Rev#\source\ii_dio.vhd.
System Configuration
This component provides communication with the host computer and allows controls from ctl_reg44~47 and read data back
through status44~47. Port “en_config” enables the settings, such as test, test mode, gain/offset, and DAC SPI interface, from
Simulink environment. If “en_config = 0,” all the settings are from the host software. This port provides the possibility to
work without supports from software in logic development.
Using “clk_sel,” users can use the onboard crystal or external clock as ADC/DAC sample clock. Port “clk_locked” shows
DCM is locked and DDR, QDR are ready to be used. Port “sys_reset” provides system reset to Simulink components. When
“adc_run” or “dac_run” is low, “sys_reset” is high. You can generate a reset for every run from software. Port “init_reset”
provides a one time reset after the FPGA is loaded. Port “ext_sync” makes it possible to use external trigger in the
MATLAB project.
On the panel, ADC sample clock can be sent to SYNC port for debug purpose, or use SYNC port as an external trigger input.
fir_loopback This example shows data loopbacked from ADC to DAC through a FIR lowpass filter.
user_design This example shows explains where and how to place an user's application.
On X5 400M board, users need to run “dac_pll.m” to generate PLL setting for DAC SPI interface. Please type “[spi_addr,
spi_data, spi_wr]=dac_pll(125,1);” in MATLAB Command Window to generate a configuration. Please read Component
Description\DAC SPI INTF for more details. Users can edit vectors in “dac_pll.m” and send them through SPI interface for
different applications.
After loading the generated bit file through Xilinx Jtag pod, the FPGA is free running at system clock. You need to restart
the computer or re-enumerate the board in Windows “Device Manager” to enable PCI Express connection. After rebooting
the machine, please run hardware cosimulation with “Skip device configuration” checked as figure shown below. So it won't
load the logic again and kill the PCI Express connection.
To use the settings from Simulink environment, please make sure that “en_config = '1'.” To give controls back to the host
software, please set “en_config = '0'.”
Data from the host is removed header and sent to MATLAB component through PCIE_RX_INTF, buffered in DDR queue 1,
and deinterleaved as two 32 bits data for DAC 0 and DAC 1.
The project is actually a component in FrameWork Logic, and the board support package interface blocks are wrappers for
the input/output ports. So most of the components are necessary to be instantiated in the compilation. For example, you need
to keep “System_Configuration,” “ADC0/1_INTF,” “DAC0/1_INTF,” “DDR_Queue_0/1,” “ii_packetizer,”
“PCIE_TX/RX_INTF,” “SRAM0/1_INTF,” “DIO_INTF,” “DAC_SPI_INTF.” You can remove “ii_interleaver,”
“ii_deinterleaver,” “ii_flow_ctrl,” “ii_reorder,” “V5_FIFO.” The rest yellow gateways will become jtag ports exchanging
data between MATLAB/Simulink and FPGA in hardware co-simulation.
After building a project, you need to double-click on the System Generator token, choose the compilation target, and generate
a bitstream for hardware co-simulation. You can choose XFLOW options files to have more controls in the compilation.
If the project is compiled without any timing problem, a hardware co-simulation block and a bit file are generated in the
target folder. We can create signal sources from Simulink toolbox and send them to FPGA through jtag cable.
Open the hwcosim block and set the clock in free running mode. If you are running the example, please check if the
bitstream path is correct. Now you can click the play button and run co-simulation with the hardwares on the board.
The filter is designed using MATLAB FDATool like the following picture. The passband of the frequency response is 3
MHz and the stopband is 8 MHz. The coefficients are passed to “FIR Compiler v3_2” by filling
“xlfda_numerator('FDATool')” as coefficient vector. The output of “FIR Compiler v3_2” is 32 bits, and the slice block helps
to determine the location of MSB to get the best precision. It shows the possibility to use the powerful tool in FPGA design
for now and the future.
The experiment is done to check the data quality through the parallel processing structure. In hardware co-simulation, set
“en_config = '1'” and load the bitstream to the FPGA. Restart the PC or re-enumerate the board in Windows “Device
Manager.” Open SNAP and enable test counter. Snap the data to Binview. The incrementing ramp should be consecutive.
Four 32 bits control registers provide extra controls from the host software. Four 32 bits status registers receive data from the
project for any purpose. The control registers are hooked up to status registers in the default example. We can write the
control register 44 in example software Wave “Debug page” and see the correct value read back through status register 44 in
the following picture.
Software Prerequisites
You must have the following software installed before installing the Board Support Package.
● Xilinx ISE Foundation v10.1.02 (Service Pack 2) or later, along with the full version of the ISE Simulator.
Note: Please find a compatible version of MATLAB and System Generator in the link.
http://www.xilinx.com/ise/optional_prod/system_generator.htm
Note: The Microsoft Windows environment variable $XILINX must be set and point to your ISE software installation
directory. ISE software service packs may be downloaded from the Software Updates Center.
Overview
The block diagram below shows hardware structure inside FPGA. The blue components are infrastructures for
communication with onboard devices. The white block is MATLAB/Simulink component allowing users to do graphical
design and simulations. The green blocks are II blocks talking to the infrastructures. Your design can be put on the datapath
and utilize the powerful tools from Xilinx and Mathworks for DSP algorithm simulation and hardware cosimulation, as
shown in the purple block. The whole design can be done in several steps and realized in the hardware. Please refer to
Chapter 3 and 4 for more details.
DDR2 ADC0
VFIFO 32
Offset/ FIFO
Alert gain 16i16o
16
128 16
DDR
VFIFO ADC1
32
Offset/ FIFO
packetizer ADC0 gain 16i16o
16
ADC1 Trigger
64 PCIE
PCIE INTF
User Design
ADC2
ADC2 32
Offset/ FIFO
gain 16i16o
16
ADC3
MATLAB/
Simulink ADC3
SRAM
INTF
32
Offset/ FIFO
gain 16i16o
16
QDR Digital IO
X5-210M SRAM /Serial RapidIO
Figure 77. X5 210M block diagram
The configuration panel in “ADC0 INTF” block provides the controls to trigger, enable frame mode, and calibrations without
host software. When “Use External Trigger” is checked, trigger from SYNC port is used as ADC trigger.
There is an embedded flow control for ADC interface. For example, you can use destination FIFO “not empty” flag as
dest_rdy for adc0_intf; or you can watch the destination FIFO “write count” and send a ready flag when the count is less than
a threshold.
DDR INTF
In X5-210M, one 512 MByte queue of virtual FIFO has been implemented. For the 128 bits “din” and “dout” ports, the first
16 bits data should be aligned to the MSB, and the last data is aligned to LSB. The queue can be used for any purpose. In
the FrameWork Logic, the queue is used to buffered the interleaved data from ADC channels.
wr In Write strobe
rd In Read strobe
ii_interleaver_210m
This component stacks incoming data and make it interleaved data format at the input of VFIFO, suitable for host software.
reset In Reset
din[15:0] In Data in
wt In Write strobe
ii_reorder
This component is used to re-order the data for little-endian system. It is usually used in front of packetizer to rearrange the
data for little-endian system.
ii_packetizer
This component packetizes the incoming data with a header, including packet ID and packet size. The packetizer will collect
enough data according to the packet size from one channel, packetize the data with header, and move to the next enabled
channel. Currently, channel 0 is reserved to alert component. If we look under the mask, the packetizer is instantiated as a
Xilinx System Generator black box. The corresponding files are located in <Xilinx
root>\DSP_Tools\sysgen\plugins\compilation\Hardware Co-Simulation\X5_210M_Rev#\ii_packetizer_config.m and
C:\Innovative\Sysgen\II_DSP_LIB\vhdl\X5\ii_packetizer.vhd. More sophisticated packet system can be made by changing
reset In Reset
wr In Write strobe
rd In Read strobe
There are three addresses. Ports “wr addr” and “rd addr” are for MATLAB/Simulink read/write in slow mode; another
“address” is in the ii_sram_intf.vhd for fast read/write in real-time. SRAM uses “wr addr” and “rd addr” when
“fast_mode='0'” and “address” when “fast_mode='1'.” Due to the limited bandwidth of Xilinx JTAG pod, MATLAB can
only read/write using slower jtag clock and “wr addr” and “rd addr.” If real-time read/write is required, “wr” and “rd” is
connected to the data valid of the incoming data, and the address increases with system clock. So fast data logging and
playback can be accomplished.
SRAM interface provides address and data control with specific support for MATLAB use. Port “wr addr” and “rd addr” and
“end_addr” provide the flexibility to read/write a specific chunk of data in SRAM. Port “fast_mode” allows SRAM to be
accessed with FPGA system clock. Port “rollover” provides the function to wrap the address back to 0 when “end_addr” is
reached, thus providing a circular buffer.
wr In Write strobe
rd In Read strobe
//---------------------------------------------------------------------------
// X5_210MInputDevice::ConfigureHardware()
//---------------------------------------------------------------------------
void X5_210MInputDevice::ConfigureHardware()
{
inherited::ConfigureHardware();
ConfigReg.Port(0x63, 0x00);
}
}
wt In Write strobe
Digital IO
This component is a simple digital IO port that has an input register and output register. It may be used as a simple digital
control port or easily customized. Port “dio_en” controls a mux to use data from the software or MATLAB/Simulink project.
The 16 bit “rx_data” is connected to a register, which is written when “rd” is low. “tx_data” writes the output register when
“wr” is high. The source VHDL is available in <X5 root>\210M\Logic\Rev#\source\ii_dio.vhd.
System Configuration
This component provides communication with the host computer and allows controls from ctl_reg44~47 and read data back
through status44~47. Port “en_config” enables the settings, such as test, test mode, gain/offset, and ADC SPI interface, from
Simulink environment. If “en_config = 0,” all the settings are from the host software. This port provides the possibility to
work without supports from software in logic development.
Using “clk_sel,” users can use the onboard crystal or external clock as ADC/DAC sample clock. Port “clk_locked” shows
DCM is locked and DDR, QDR are ready to be used. Port “sys_reset” provides system reset to Simulink components. When
“adc_run,” “sys_reset” is high. You can generate a reset for every run from software. Port “init_reset” provides a one time
reset after the FPGA is loaded. Port “ext_sync” makes it possible to use external trigger in the MATLAB project.
On the panel, ADC sample clock can be sent to SYNC port for debug purpose, or use SYNC port as an external trigger input.
user_design This example shows explains where and how to place an user's application.
In MATLAB command window, you need to assign a value to “ts” for compilation. Currently the system is running at 200
MHz, so please type “ts=1/200e6;”.
To run the hardware co-simulation example, you can open the file “x5_210m_default_cosim.mdl” and push the play button.
After loading the generated bit file through Xilinx Jtag pod, the FPGA is free running at system clock. You need to restart
the computer or re-enumerate the board in Windows “Device Manager” to enable PCI Express connection. After rebooting
the machine, please run hardware cosimulation with “Skip device configuration” checked as figure shown below. So it won't
load the logic again and kill the PCI Express connection.
To use the settings from Simulink environment, please make sure that “en_config = '1'.” To give controls back to the host
software, please set “en_config = '0'.”
The project is actually a component in FrameWork Logic, and the board support package interface blocks are wrappers for
the input/output ports. So most of the components are necessary to be instantiated in the compilation. For example, you need
to keep “System_Configuration,” “ADC0/1/2/3_INTF,” “DDR_VFIFO,” “ii_packetizer,” “PCIE_TX/RX_INTF,”
“SRAM0/1_INTF,” “DIO_INTF,” and “spi_adc” of Rev C board. You can remove “ii_interleaver_210m,” “ii_flow_ctrl,”
“ii_reorder,” “V5_FIFO.” The rest yellow gateways will become jtag ports exchanging data between MATLAB/Simulink
and FPGA in hardware co-simulation.
After building a project, you need to double-click on the System Generator token, choose the compilation target, and generate
a bitstream for hardware co-simulation. You can choose XFLOW options files to have more controls in the compilation.
The files provided by II are in <Xilinx root>\DSP_Tools\sysgen\plugins\compilation\Hardware Co-
Simulation\X5_210M\balanced_jtag.opt.
In MATLAB command window, you need to assign a value to “ts” for compilation. Currently the system is running at 200
MHz, so please type “ts=1/200e6;”.
If the project is compiled without any timing problem, a hardware co-simulation block and a bit file are generated in the
target folder. We can create signal sources from Simulink toolbox and send them to FPGA through jtag cable.
Open the hwcosim block and set the clock in free running mode. If you are running the example, please check if the
bitstream path is correct. Now you can click the play button and run co-simulation with the hardwares on the board.
The filter is designed using MATLAB FDATool in the following picture. The passband of the frequency response is 3 MHz
and the stopband is 8 MHz. The coefficients are passed to “FIR Compiler v3_2” by filling “xlfda_numerator('FDATool')” as
coefficient vector. The output of “FIR Compiler v3_2” is 32 bits, and the slice block helps to determine the location of MSB
to get the best precision. It shows the possibility to use the powerful tool in FPGA design for now and the future.
A simple experiment can be done using this example. We connect a function generator on ADC0 and snap the data in the
host. The generated sine wave starts from 1 MHz and the frequency is increased steadily to 8 MHz. In Binview, the
amplitude should be gradually attenuated by the filter.
Four 32 bits control registers provide extra controls from the host software. Four 32 bits status registers receive data from the
project for any purpose. The control registers are hooked up to status registers in the default example. We can write the
control register 44 in example software Snap “Debug page” and see the correct value read back through status register 44 in
the following picture.
1. Why can't I compile the examples in MATLAB or load the projects into Xilinx ISE when I first installed the
BSP?
After BSP installation, please right-click the installation folder and uncheck the “read-only” option. In the hardware
co-simulation example, please double-click on the cosim block and check the path of bitstream.
2. When I run the hardware cosim example, Simulink showed the error: “Could not open the programming
cable.”
Please check if cable is correctly attached to the connector. Is the light on Jtag pod green? Is the red line on the Jtag
cord align to the square mark on the connector.
Please double-click the cosim block and see if the right cable is selected, as shown in the picture.
3. When I run the hardware cosim example, the result is different from what I expect.
Please double-click the cosim block and see if the block is in free-running mode, as shown in the picture.
The similar problem is discussed in “Chapter 3 Design Flow.” First, you can use “Floorplanner” and see if there is
any signal traveled a long distance to its destination. You can buffer the signal by adding registers in Simulink.
Second, you can use “Timing Analyzer” to locate the timing errors. You can either improve the problems according
to the instructions in “Timing Analyzer” or rearrange the corresponding components in the floor plan.
Please check if you are using Microsoft Remote Desktop. If not, please contact tech support in II.
The following table shows the revision history for the Board Support Package.