Qsys Intro
Qsys Intro
4
Creating a System With Qsys
6
QII51020 Subscribe Send Feedback
®
Qsys is a system integration tool included as part of the Quartus II software. Qsys captures system-level
hardware designs at a high level of abstraction and automates the task of defining and integrating customized
HDL components. These components include IP cores, verification IP, and other design modules. Qsys
®
facilitates design reuse by packaging and integrating your custom components with Altera and third-party
IP components. Qsys automatically creates interconnect logic from the high-level connectivity you specify,
thereby eliminating the error-prone and time-consuming task of writing HDL to specify system-level
connections.
Qsys is more powerful if you design your custom components using standard interfaces. By using standard
interfaces, your components inter-operate with the components in the Qsys Library. In addition, you can
take advantage of bus functional models (BFMs), monitors, and other verification IP to verify your design.
® ® ™ ™ ™
Qsys supports Avalon , AMBA AXI3 (version 1.0), AMBA AXI4 (version 2.0), and AMBA APB 3
(version 1.0) interface specifications. Qsys does not support AXI4-Lite.
Qsys provides the following advantages when designing a system:
• Automates the process of customizing and integrating components
• Supports up to 64-bit addressing
• Supports modular system design
• Supports visualization of systems
• Supports optimization of interconnect and pipelining within the system
• Fully integrated with the Quartus II software
Related Information
• Avalon Interface Specifications
• AMBA Protocol Specifications
• Creating Qsys Components
• Qsys Interconnect
© 2013 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, HARDCOPY, MAX, MEGACORE, NIOS, QUARTUS and STRATIX words
and logos are trademarks of Altera Corporation and registered in the U.S. Patent and Trademark Office and in other countries. All other
words and logos identified as trademarks or service marks are the property of their respective holders as described at ISO
www.altera.com/common/legal.html. Altera warrants performance of its semiconductor products to current specifications in accordance with 9001:2008
Altera's standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes Registered
no responsibility or liability arising out of the application or use of any information, product, or service described herein except as expressly
agreed to in writing by Altera. Altera customers are advised to obtain the latest version of device specifications before relying on any published
information and before placing orders for products or services.
www.altera.com
101 Innovation Drive, San Jose, CA 95134
QII51020
6-2 Understanding the Qsys Design Flow 2013.11.4
Send Feedback
QII51020
2013.11.4 Creating a Qsys System 6-3
Create Component
Using Component Editor, or
1 by Manually Creating the
_hw.tcl File
2
Simulation at Unit-Level,
Possibly Using BFMs
Does
Simulation Give Yes
Expected Results?
No
3
Debug Design
Yes 8
Generate Qsys Constrain, Compile
5
System in Quartus II Generating .sof
6 9
Perform System-Level Download .sof to PCB
Simulation with Altera FPGA
Does Does
Simulation Give HW Testing Give Yes
Expected Results? Expected Results? Qsys System Complete
No No
7 10 Modify Design or
Debug Design
Constraints
In an alternative design flow, you can begin by designing the Qsys system, and then define and instantiate
custom Qsys components, clarifying system requirements earlier in the design process.
Related Information
Creating Qsys Components
Send Feedback
QII51020
6-4 Adding and Connecting System Contents 2013.11.4
Related Information
Creating Qsys Components
Component Interface Tcl Reference
Adding Components
To add a component to your system, select the component in the Library, and then click Add.
When you select a component type and click Add, the new instance is added to your system, and a parameter
editor opens that allows you to customize the new instance. The new instance appears in the System Contents
tab, as well as the Hierarchy tab
You can type some or all of the component’s name in the Library search box to help locate a particular
component type. For example, you can type memory to locate memory-mapped components, or axi to
locate AXI interconnect components.
Connecting Components
When you add connections to a Qsys system, you can connect the interfaces of the modules in the System
Contents tab. The individual signals in each interface are connected by the Qsys interconnect when the
HDL for the system generates. You connect interfaces of compatible types and opposite directions. For
example, you can connect a memory-mapped master interface to a slave interface, and an interrupt sender
interface to an interrupt receiver interface.
Possible connections between interfaces in the system show as gray lines and open circles. When you make
a connection, Qsys draws the connection line in black, and fills the connection circle. To make a connection,
click the open circle at the intersection of the two interface names. Clicking a filled-in circle removes the
connection.
When you are done adding connections in your system, you can deselect Allow Connection Editing in the
right-click menu, which puts the Connections column into read-only mode and hides the possible
connections. Figure 6-2 illustrates the Connections column.
Send Feedback
QII51020
2013.11.4 Filtering Components 6-5
Related Information
Connecting Components
Filtering Components
You can use the Filters dialog box to filter the display of your system in the System Contents tab. You can
filter the display of your system by interface type, instance name, or by using custom tags. For example, you
can view only instances that include memory-mapped interfaces, instances that are connected to a particular
Nios II processor, or temporarily hide clock and reset interfaces to simplify the display.
Related Information
Filters Dialog Box
Managing Views
The View menu allows you to select and open any view (tab). Qsys views allow you to review your design
from different perspectives. Some views allow you to focus on a particular part of the system, while other
views show the same data in another way. Making selections in the system-level views updates other views,
and shows the other views in the context of the system-level selection.
For example, selecting cpu_0 in the Hierarchy tab updates the Parameters tab to show the parameters for
cpu_0.
Note: When you double-click a message in the Messages tab, Qsys selects the associated element in the
relevant view to facilitate debugging.
When you create a new Qsys system, the Library, Hierarchy, and System Contents tabs appear by default.
You can arrange your system workspace by dragging and dropping, and then grouping tabs in an order
appropriate to your design process. All tabs are dockable and you can close, hide, or minimize tabs that you
are not using. Minimized tabs appear minimized in the docking area below the menu bar. Tool tips on tab
corners display possible workspace arrangements, for example, disconnecting or restoring a tab to the Qsys
workspace.
Send Feedback
QII51020
6-6 Using the Hierarchy Tab 2013.11.4
When you save the Qsys system, the current view arrangement is saved, and when you open the Qsys system,
the last saved view arrangement is restored. You can use the Reset View Layout command on the View
menu to restore the Qsys workspace to its default configuration.
Note: Qsys contains some views which are not documented and appear on the View menu as "Beta". The
purpose in presenting these views is to allow designers to explore their usefulness in Qsys system
development.
Send Feedback
QII51020
2013.11.4 Using the Parameters Tab 6-7
You can use the Hierarchy tab to browse, connect, and parameterize IP in your system. The Hierarchy tab
allows you to drive changes in other views and interact with your system in more detail. As shown in Figure
6-3, the Hierarchy tab expands each interface that appears on the System Contents tab and allows you to
view the subcomponents, associated elements, and signals for each interface. Use the Hierarchy tab to focus
on a particular area of your system; coordinating selections in the Hierarchy tab with open views in your
workspace. Reviewing your system using the Hierarchy tab in conjunction with relevant views is also useful
during the debugging phase because you can contain and focus your debugging efforts to a single element
in your system.
The Hierarchy tab provides the following information and functionality:
• The connections between signals.
• The names of signals included in exported interfaces.
• Right-click menu to connect, edit, add, remove, or duplicate elements in the hierarchy.
• The internal connections of Qsys subsystems that are included as components. In contrast, the System
Contents tab displays only the exported interfaces of Qsys subsystems included as components.
Send Feedback
QII51020
6-8 Using the Presets Tab 2013.11.4
Figure 6-4: Avalon-MM Write Master Timing Waveforms Available on the Parameters Tab
Related Information
• PCI Express Subsystem Example on page 6-32
Related Information
• Presets Editor (Qsys)
You can search for text to filter the Presets list. For example, if you select the DDR3 SDRAM Controller
with UniPHY component, and then type 1g micron 256, the Presets list shows only those presets that
apply to the 1g micron 256filter request. Presets whose parameter values match the current parameter settings
are shown in bold.
Send Feedback
QII51020
2013.11.4 Using the Block Symbol Tab 6-9
Selecting a preset does not prevent you from changing any parameter to meet the requirements of your
design. Clicking Update allows you to update parameter values for a custom preset. The Update Preset
dialog box displays the default value, which you can edit, and the current value, which is static.
You can also create your own preset by clicking New. When you create a preset, you specify a name,
description and the list of parameters whose values are set by the preset. You can remove a preset from the
Quartus II project directory by clicking Delete.
Related Information
Presets Editor
Send Feedback
QII51020
6-10 Using the Project Settings Tab 2013.11.4
Device Specifies the target device for the selected device family.
Clock crossing adapter Specifies the default implementation for automatically inserted clock crossing
type adapters. The following choices are available:
• Handshake–This adapter uses a simple hand-shaking protocol to propagate
transfer control signals and responses across the clock boundary. This
methodology uses fewer hardware resources than the FIFO type because each
transfer is safely propagated to the target domain before the next transfer can
begin. The Handshake adapter is appropriate for systems with low throughput
requirements.
• FIFO–This adapter uses dual-clock FIFOs for synchronization. The latency of
the FIFO-based adapter is a couple of clock cycles more than the handshaking
clock crossing component. However, the FIFO-based adapter can sustain higher
throughput because it supports multiple transactions at any given time. The
FIFO-based clock crossers require more resources. The FIFO adapter is
appropriate for memory-mapped transfers requiring high throughput across
clock domains.
• Auto–If you select Auto, Qsys specifies the FIFO adapter for bursting links,
and the Handshake adapter for all other links.
Limit interconnect Specifies the maximum number of pipeline stages that Qsys may insert in each
pipeline stages to command and response path to increase the fMAX at the expense of additional
latency. You can specify between 0–4 pipeline stages, where 0 means that the
interconnect has a combinational data path. Choosing 3 or 4 pipeline stages may
significantly increase the logic utilization of the system. This setting is specific for
each Qsys system or subsystem, meaning that each subsystem can have a different
setting. Note that the additional latency is for both the command and response
directions.
Note: You can manually adjust this setting in the Memory-Mapped
Interconnect tab accessed by clicking Show System With Qsys
Interconnect command on the System menu.
Generation Id A unique integer value that is set to a timestamp just before Qsys system generation
that Qsys uses to check for software compatibility.
Note: Qsys generates a warning message if the selected device family and target device do not match the
Quartus II software project settings. Also, when you open Qsys from within the Quartus II software,
the device type in your Qsys project is replaced with the selected device in your open Quartus II
software project.
Related Information
Manually Controlling Pipelining in the Qsys Interconnect on page 6-20
Send Feedback
QII51020
2013.11.4 Using the Instance Parameters Tab 6-11
Related Information
Working with Instance Parameters in Qsys
Use Tcl commands in the procedure to query the parameters of a Qsys system, or to set the values of the
parameters of the subcomponents instantiated in the system.
Send Feedback
QII51020
6-12 Creating an Instance Script 2013.11.4
send_message <message level> <message text> Send a message to the user of the
component, using one of the
message levels Error, Warning,
Info, or Debug. Enclose text with
multiple words in quotation
marks.
set_instance_parameter_ <instance name> <parameter name> Set a parameter value for a child
value <parameter value> instance.
You can use standard Tcl commands to manipulate parameters in the script, such as the set command to
create variables, or the expr command for mathematical manipulation of the parameter values.
Example 6-1 shows an instance script of a system that uses a parameter called pio_width to set the width
parameter of a parallel I/O (PIO) component. Note that the script combines the get_parameter_value
and set_instance_parameter_value commands using brackets.
proc compose {} {
# Get the pio_width parameter value from this Qsys system and
# pass the value to the width parameter of the pio_0 instance
Send Feedback
QII51020
2013.11.4 Using the Interconnect Requirements Tab 6-13
[get_parameter_value pio_width]
}
Related Information
Component Interface Tcl Reference
Setting Value
Limit interconnect pipeline stages to—Specifies the You can specify between 0–4 pipeline stages, where 0
maximum number of pipeline stages that Qsys may means that the interconnect has a combinational data
insert in each command and response path to increase path. Choosing 3 or 4 pipeline stages may significantly
the fMAX at the expense of additional latency. increase the logic utilization of the system. This setting
is specific for each Qsys system or subsystem, meaning
that each subsystem can have a different setting. Note
that the additional latency is added once on the
command path, and once on the response path.
Send Feedback
QII51020
6-14 Configuring Interconnect Requirements for an Interface 2013.11.4
Setting Value
Clock crossing adapter type—Specifies the default • Handshake–This adapter uses a simple hand-
implementation for automatically inserted clock shaking protocol to propagate transfer control
crossing adapters. signals and responses across the clock boundary.
This methodology uses fewer hardware resources
because each transfer is safely propagated to the
target domain before the next transfer can begin.
The Handshake adapter is appropriate for systems
with low throughput requirements.
• FIFO–This adapter uses dual-clock FIFOs for
synchronization. The latency of the FIFO-based
adapter is a couple of clock cycles more than the
handshaking clock crossing component. However,
the FIFO-based adapter can sustain higher
throughput because it supports multiple transac-
tions at any given time. The FIFO-based clock
crossers require more resources. The FIFO adapter
is appropriate for memory-mapped transfers
requiring high throughput across clock domains.
• Auto–If you select Auto, Qsys specifies the FIFO
adapter for bursting links, and the Handshake
adapter for all other links.
Send Feedback
QII51020
2013.11.4 Adding Systems to the Library 6-15
You can include any Qsys system as a component in another Qsys system. In a team-based design flow, you
can have one or more systems in your design developed simultaneously by other team members, decreasing
time-to-market for the complete design.
Figure 6-5 shows the top-level of a Qsys hierarchical design that implements a PCI Express™ to Ethernet
bridge. This example combines separate PCI Express and Ethernet subsystems with Altera’s DDR3 SDRAM
Controller with UniPHY IP core.
Figure 6-5: Top-Level for a PCI Express to Ethernet Bridge
Qsys System
PCIe to Ethernet Bridge
DDR3
PCI Express PCIe
SDRAM
DDR3 Subsystem
SDRAM Mem
Controller Mstr CSR
Mem CSR
Mstr
Ethernet Ethernet
Subsystem
Send Feedback
QII51020
6-16 Creating a Component Based on a System 2013.11.4
Send Feedback
QII51020
2013.11.4 Creating Secure Systems (TrustZones) 6-17
Related Information
• Creating a System with Qsys
Table 6-4: Secure and Non-Secure Access Between Master, Slave, and Memory Components
TrustZone-aware slave/ OK OK OK
memory
Non-TrustZone-aware OK OK OK
slave (non-secure)
Non-TrustZone-aware OK OK OK
memory (non-secure
region)
If a master issues transactions that fall into the per-access or not allowed cells, as described in the table above,
your design must contain a default slave. A transaction that violates security is rerouted to the default slave
and subsequently terminated with an error. You can connect any slave as the default slave, which allows it
to respond to the master with errors. You can share the default slave between multiple masters. You have
one default slave for each interconnect domain, which is a group of connected memory-mapped masters
Send Feedback
QII51020
6-18 Managing Secure Settings in Qsys 2013.11.4
and slaves that share the same interconnect. Use the altera_axi_default_slave component as the
default slave because this component has the required TrustZone features.
Note: For more information about interconnect domains, refer to Qsys Interconnect.
In Qsys, you can achieve an optimized secure system by partitioning your design. For example, for masters
and slaves under the same hierarchy, it is possible for a non-secure master to initiate continuous transactions
resulting in unsuccessful transfer to a secure slave. In the case of memory aliasing, you must carefully designate
secure or non-secure address maps to maintain reliable data.
Related Information
• Qsys Interconnect
Send Feedback
QII51020
2013.11.4 Viewing the Qsys Interconnect 6-19
this occurs, you can add a default slave to the design. All undefined memory region accesses are then routed
to the default slave, which then terminates the transaction with an error response.
You can connect any memory-mapped slave as a default slave. Altera recommends that you have only one
default slave for each domain in your design. Accessing undefined memory regions can occur in the following
cases:
• When there are gaps within the accessible memory map region that are within the addressable range of
slaves, but are not mapped.
• Accesses by a master to a region that does not belong to any slaves that is mapped to the master.
• When a non-secured transaction is accessing a secured slave. This applies to only slaves that are secured
at compilation time.
• When a read-only slave is accessed with a write command, or a write-only slave is accessed with a read
command.
To designate a slave as the default slave, for the selected component, turn on Default Slave on the Systems
Content tab.
Note: If you do not specify the default slave, Qsys automatically assigns the slave at the lowest address
within the memory map for the master that issues the request as the default slave.
Send Feedback
QII51020
6-20 Manually Controlling Pipelining in the Qsys Interconnect 2013.11.4
Click Highlight Path to better identify edges and paths between modules. Turn on Show Pipeline Locations
to add greyed-out registers on edges where pipelining is allowed in the interconnect.
Note: You must have more than one module selected in order to highlight a path.
1. In the Project Settings tab, first try increasing the value of the Limit interconnect pipeline stages to
option until it no longer gives significant improvements in frequency, or until it causes unacceptable
effects on other parts of the system.
2. In the Quartus II software, compile your design and run timing analysis.
3. Identify the critical path through the interconnect and determine the approximate mid-point. The
following is an example of a timing report where the critical path is located in the interconnect.
Send Feedback
QII51020
2013.11.4 Integrating Your Qsys Design with the Quartus II Software 6-21
Related Information
• Managing Files in a Project
• Searching for Component Files to Add to the Library on page 6-39
• Generating a Qsys System on page 6-23
Send Feedback
QII51020
6-22 Integrating with the .qip File 2013.11.4
When a Qsys design file includes an IP component which is outside of the project directory, the directory
of the .qsys file, or the /ip subdirectoy, you must add these dependency paths to the Qsys IP Search Path
before compilation.
Note: The following are design guidelines and warnings when integrating your Qsys designs with the
Quartus II software:
• When you integrate your Qsys designs with the Quartus II software using the .qsys file, you must manually
run any IP customization scripts at the appropriate stages of the Quartus II compilation process. There
is no automation support for running scripts between the Quartus II software compilation stages. The
Implementing and Parameterizing Memory IP reference describes running placement scripts for embedded
memory IP interfaces.
• Do not edit the files generated under the /ip/<qsys file name> directory, as they are overwritten during
subsequent runs of Analysis & Synthesis.
Related Information
• Implementing and Parameterizing Memory IP
Send Feedback
QII51020
2013.11.4 Generating a Qsys System 6-23
For this system, use the following commands in your .sdc file for the TimeQuest Timing Analyzer:
Related Information
• The Quartus II TimeQuest Timing Analyzer
Send Feedback
QII51020
6-24 Generating Output Files 2013.11.4
For synthesis, you can select the top-level module language as Verilog HDL or VHDL, which applies to the
system’s top-level definition.
Qsys places the generated output files in a subdirectory of your project directory, along with an HTML report
file. To change the default behavior, on the Generation tab, specify a new directory under Output Directory.
Figure 6-8: Qsys Generated Files Directory Structure
<qsys_design>
synthesis
submodules
simulation
submodules
testbench
simulation
submodules
Each time you generate your system, Qsys overwrites these files, therefore, you should not edit Qsys-generated
output files. If you have constraints, such as board-level timing constraints, Altera recommends that you
create a separate Synopsys Design Constraints File (.sdc) and include that file in your Quartus II project. If
you need to change top-level I/O pin names or instance name, Altera recommends you create a top-level
HDL file that instantiates the Qsys system, so that the Qsys-generated output is instantiated in your design
without any changes to the Qsys output files.
Note: Qsys generates the files in listed in Table 6-5 to the <qsys design>/simulation folder.
<Qsys system> The top-level Qsys system directory, in the Quartus II project
directory
<Qsys system>.bsf A Block Symbol File (.bsf) representation of the top-level Qsys
system for use in Quartus II Block Diagram Files (.bdf).
<Qsys system>.html A report for the system, which provides a system overview
including the following information:
• External connections for the system
• A memory map showing the address of each slave with respect
to each master to which it is connected
• Parameter assignments for each component
Send Feedback
QII51020
2013.11.4 Generating Output Files 6-25
<Qsys system>.sopcinfo Describes the components and connections in your system. This
file is a complete system description and is used by downstream
tools such as the Nios II tool chain. It also describes the
parameterization of each component in the system; consequently,
you can parse its contents to get requirements when developing
software drivers for Qsys components.
This file and the system.h file generated for the Nios II tool chain
include address map information for each slave relative to each
master that accesses the slave. Different masters may have a
different address map to access a particular slave component.
<Qsys system>/synthesis This directory includes the Qsys-generated output files that the
Quartus II software uses to synthesize your design.
<Qsys system>/synthesis/ An HDL file for the top-level Qsys system that instantiates each
submodule in the system for synthesis.
<Qsys system>.v
or
<Qsys system>/synthesis
<Qsys system>.vhd
<Qsys system>/synthesis/ This file this file includes all the info you need to synthesize the
IP components in your system.
<Qsys system>.qip
<Qsys system>/synthesis/submodules Contains Verilog HDL or VHDL submodule files for synthesis.
<Qsys system>/simulation This directory includes the Qsys-generated output files to simulate
your Qsys design or testbench system.
<Qsys system>/simulation/ This file contains information reqiured for NativeLink simulation
of IP components in your system. You must add the .sip file to
<Qsys system>.sip
your Quartus II project.
Send Feedback
QII51020
6-26 Generating Output Files 2013.11.4
<Qsys system>/simulation/ An HDL file for the top-level Qsys system that instantiates each
submodule in the system for simulation.
<Qsys system>.v
or
<Qsys system>/simulation/
<Qsys system>.vhd
<Qsys system>/simulation/submodules Contains Verilog HDL or VHDL submodule files for simulation.
<Qsys system>/simulation/mentor Contains a ModelSim® script msim_setup.tcl to set up and run
a simulation.
<Qsys system>/simulation/synopsys/vcs Contains a shell script vcs_setup.sh to set up and run a VCS®
simulation.
<Qsys system>/simulation/cadence Contains a shell script ncsim_setup.sh and other setup files to
set up and run an NCSIM simulation.
<Qsys system>/testbench/ The top-level testbench file, which connects BFMs to the top-level
interfaces of <qsys_design> .qsys.
<Qsys sysyem>_tb.v
or
<Qsys system>/testbench/
<Qsys sysyem>_tb.vhd
<Qsys system>/testbench/<module name> Allows HPS System Debug tools to view the register maps of
_<master interface name>.svd peripherals connected to the HPS within a Qsys design.
Similarly, during synthesis the .svd files for slave interfaces visible
to System Console masters are stored in the .sof file in the debug
section. System Console reads this section, which Qsys can query
for register map information. When a slave is open, Qsys can
access the registers by name.
Send Feedback
QII51020
2013.11.4 CMSIS Support for Qsys Systems With An HPS Component 6-27
Related Information
• Component Interface Tcl Reference
• CMSIS - Cortex Microcontroller Software
Send Feedback
QII51020
6-28 Simulating a Qsys System 2013.11.4
Table 6-6: Summary of Settings Simulation and Synthesis in the Generate Dialog Box
Simple, BFMs for clocks and resets Creates a testbench Qsys system
with BFM components driving
only clock and reset interfaces.
Includes any simulation partner
modules specified by IP cores in
the system.
Send Feedback
QII51020
2013.11.4 Generate and Modify the Testbench System 6-29
Create block symbol files (.bsf) On You can optionally create a (.bsf)
file to use in schematic Block
Off
Diagram File (.bdf) designs.
Output Directory < directory name > Allows you to browse and locate
an alternate directory than the
project directory for each
generation target.
Related Information
• Avalon Verification IP Suite User Guide
• Mentor Verification IP (VIP) Altera Edition (AE)
• Generating a System for Synthesis or Simulation
• Generation Dialog Box (Qsys)
Send Feedback
QII51020
6-30 Generate the Testbench System and a Simulation model at the Same Time (Verilog HDL only) 2013.11.4
Generate the Testbench System and a Simulation model at the Same Time (Verilog HDL
only)
You can use the following design flow to create a testbench system and a simulation model of your Verilog
HDL design.
1. Create a Qsys system.
2. Generate a testbench system and the simulation model for the testbench system in the Qsys Generate
dialog box.
3. Create a custom test program for the BFMs.
4. Compile and load the Qsys design and testbench in your simulator, and then run the simulation.
Figure 6-9 demonstrates the use of monitors with an Avalon-MM monitor between the previously connected
pcie_compiler bar1_0_Prefetchable Avalon-MM master interface and the
dma_0 control_port_slave Avalon-MM slave interface.
Figure 6-9: Inserting an Avalon-MM Monitor between Avalon-MM Master and Slave Interfaces
Similarly, you can insert an Avalon-ST monitor between Avalon-ST source and sink interfaces.
Simulation Scripts
Qsys generates simulation scripts to script the simulation environment set up for Mentor Graphics Modelsim®
and Questasim®, Synopsys VCS® and VCS MX®, Cadence Incisive Enterprise Simulator® (NCSIM), and
the Aldec Riviera-PRO® Simulator.
You can use the scripts to compile the required device libraries and system design files in the correct order
and elaborate or load the top-level design for simulation.
Send Feedback
QII51020
2013.11.4 Simulating Software Running on a Nios II Processor 6-31
The simulation scripts provide the following variables that allow flexibility in your simulation environment:
• TOP_LEVEL_NAME—If the Qsys testbench system is not the top-level instance in your simulation
environment because you instantiate the Qsys testbench within your own top-level simulation file, set
the TOP_LEVEL_NAME variable to the top-level hierarchy name.
• QSYS_SIMDIR—If the simulation files generated by Qsys are not in the simulation working directory,
use the QSYS_SIMDIR variable to specify the directory location of the Qsys simulation files.
• QUARTUS_INSTALL_DIR—Points to the device family library.
Example 6-2 shows a simple top-level simulation HDL file for a testbench system
pattern_generator_tb, which was generated for a Qsys system called pattern_generator. The
top.sv file defines the top-level module that instantiates the pattern_generator_tb simulation model
as well as a custom SystemVerilog test program with BFM transactions, called test_program.
module top();
pattern_generator_tb tb();
test_program pgm();
endmodule
Note: The VHDL version of the Altera Tristate Conduit BFM is not supported in Synopsys VCS, NCSim,
and Riviera-PRO in the Quartus II software version 13.1. These simulators do not support the VHDL
protected type, which is used to implement the BFM. For a workaround, use a simulator that supports
the VHDL protected type.
Related Information
• ModelSim-Altera software, Mentor Graphics ModelSim support
• Synopsys VCS and VCS MX support
• Cadence Incisive Enterprise Simulator (IES) support
• Aldec Active-HDL and Rivera-PRO support
Send Feedback
QII51020
6-32 System Examples 2013.11.4
8. To run the simulation in ModelSim, type run -all in the ModelSim transcript window.
9. If prompted, set ModelSim configuration settings and select the correct Qsys Testbench Simulation
Package Descriptor (.spd) file, < qsys_system > _tb.spd. The .spd file is generated with the testbench
simulation model for Nios II designs and specifies all the files required for the Nios II software simulation.
Related Information
• Getting Started with the Graphical User Interface (Nios II)
• Getting Started from the Command-Line (Nios II)
System Examples
The following system examples demonstrate various design features and flows that you can replicate in your
design.
Send Feedback
QII51020
2013.11.4 PCI Express Subsystem Example 6-33
CSR S M CSR
M
PCIe Link
Rd S CSR Cn
(exported
S Tx Data to PCIe root port)
Wr M
S M
M S
Send Feedback
QII51020
6-34 Ethernet Subsystem Example 2013.11.4
Related Information
Qsys Interconnect
Send Feedback
QII51020
2013.11.4 Ethernet Subsystem Example 6-35
Ethernet Subsystem
Qsys inserts
arbitration
logic M M M
Scatter Gather
RX Avalon-ST Calibration
DMA Snk Src CSR Cn
CSR S S
M
Avalon-MM Pipeline
Bridge (Qsys)
S
CSR
Send Feedback
QII51020
6-36 PCI Express to Ethernet Bridge Example 2013.11.4
Send Feedback
QII51020
2013.11.4 PCI Express to Ethernet Bridge Example 6-37
Qsys System
Qsys inserts PCI Express
arbitration and Subsystem
DDR3 Clock crossing 125 MHz
SDRAM logic PCIe link Cn
(125 MHz-200MHz)
400 MHz
Calibration Cn
Ethernet
Subsystem
Ethernet Cn
125 MHz
Figure 6-15: Qsys Representation of the Complete PCI Express to Ethernet Bridge
Send Feedback
QII51020
6-38 Pipeline Bridges 2013.11.4
Pipeline Bridges
The PCI Express to Ethernet bridge example system uses several pipeline bridges. You must configure bridges
to accommodate the address range of all of connected components, including the components in the
originating subsystem and the components in the next higher level of the system hierarchy.
The pipeline bridge inserts a pipeline stage between the connected components. You should register signals
at the subsystem interface level for the following reasons:
• Registering interface signals decreases the amount of combinational logic that must be completed in one
cycle, making it easier to meet timing constraints.
• Registering interface signals raises the potential frequency, or fMAX, of your design at the expense of an
additional cycle of latency, which might adversely affect system throughput.
• The Quartus II incremental compilation feature can achieve better fMAX results if the subsystem boundary
is registered.
Note: Connections between AXI and Avalon interfaces are made without requiring the use of explicitly
instantiated bridges; the interconnect provides the necessary bridging logic.
Related Information
• Optimizing System Performance for Qsys
• Qsys System Design Components
To satisfy the design requirements for this example, you define an instance parameter in my_system.qsys
that is set by the higher-level system, and then define an instance script to specify how the values of the
parameters of the My_IP components instantiated in my_system.qsys are affected by the value set on the
instance parameter.
Send Feedback
QII51020
2013.11.4 Searching for Component Files to Add to the Library 6-39
To do this, in Qsys, open the my_system.qsys Qsys system that instantiates the two instances of the My_IP
components. On the Instance Parameters tab, create a parameter called system_id. For this example,
you can set this parameter to be of type Integer and choose 0 as the default value.
Next, you provide a Tcl Instance Script that defines how the value of the system_id parameter should
affect the parameters of comp0 and comp1 subcomponents in my_system.qsys.
In Example 6-4 Qsys gets the value of the parameter system_id from the top-level system and saves it as
top_id, and then increments the value by 1 and 2. The script then uses the new calculated values to set the
MY_SYSTEM_ID parameter in the My_IP component for the instances comp0 and comp1. The script
uses informational messages to print the status of the parameter settings when the my_system.qsys system
is added to the higher-level system.
You can click Preview Instance to modify the parameter value interactively and see the effect of the scripts
in the message panel which can be useful for debugging the script. In this example, if you change the parameter
value in the Preview screen, the component generates messages to report the top-level ID parameter value
and the parameter values used for the two instances of the component.
Related Information
Working with Instance Parameters in Qsys
Send Feedback
QII51020
6-40 Adding Components to the Library 2013.11.4
Qsys systems can also appear in the library, and you can use these systems in other designs if they have
exported interfaces.
Altera and third-party developers provide ready-to-use components, which are installed automatically with
the Quartus II software and are available in the Qsys Library. The Qsys Library includes the following
components:
®
• Microprocessors, such as the Nios II processor
• DSP IP cores, such as the Reed Solomon II core
• Interface protocols, such as the IP Compiler for PCI Express
• Memory controllers, such as the RLDRAM II Controller with UniPHY
• Avalon® Streaming (Avalon-ST) components, such as the Avalon-ST Multiplexer IP core
• Qsys Interconnect components
• Verification IP (VIP) Bus Functional Models (BFMs)
You can set the IP Search Path option to specify the installed locations for custom and third-party components
that you want to appear in the component library. Qsys searches for component files each time you open
the tool, and locates and displays the list of available components in the component library.
Qsys searches the directories listed in the IP Search Path for the following component file types:
• Hardware Component Description File (_hw.tcl)—Each _hw.tcl file defines a single component.
• IP Index File (.ipx)—Each .ipx file indexes a collection of available components, or a reference to other
directories to search. In general, .ipx files facilitate faster startup for Qsys and other tools because fewer
directories are searched and analyzed.
Qsys searches some directories recursively and other directories only to a specific depth. When a directory
is recursively searched, the search stops at any directory containing an _hw.tcl or .ipx file; subdirectories
are not searched. In the following list of search locations, a recursive descent is annotated by **. A single *
signifies any file.
Note: If you add a component to you search path, you must refresh your system by clicking File > Refresh
to update the Qsys library.
Send Feedback
QII51020
2013.11.4 Copy Components to a Directory Searched by Default 6-41
<install_dir>
quartus
ip
altera .
altera_components.ipx .
1 <components>
user_components
2 component1
component1_hw.tcl
component1.v
3 component2
component2_hw.tcl
component2.v
In Figure 6-16, the circled numbers identify a typical directory structure for the Quartus II software. For
the directory structure above, Qsys performs the component discovery algorithm described below to locate
.ipx and_hw.tcl files.
1. Qsys recursively searches the <install_dir> /ip/ directory by default. The recursive search stops when
Qsys finds an .ipx file.
2. As part of the recursive search, Qsys also looks in the user_components directory. Qsys finds the
component1 directory, which contains component1_hw.tcl. When Qsys finds the component1_hw.tcl
component, the recursive search ends, and no components in subdirectories of component1 are found.
3. Qsys then searches the component2 directory, because this directory path also appears as an IP Search
Path, and discovers component2_hw.tcl. When Qsys finds component2_hw.tcl, the recursive search
ends.
Send Feedback
QII51020
6-42 Reference Components in an IP Index File (.ipx) 2013.11.4
Note: If you save your _hw.tcl file in the <install_dir> /ip/ directory, Qsys finds your _hw.tcl file and does
not search subdirectories adjacent to the _hw.tcl file.
You can verify that components are available with the ip-catalog command. You can use the ip-make-
ipx command to create an .ipx file for a directory tree, which can reduce the startup time for Qsys.
<library>
<path path="…<user directory>" />
<path path="…<user directory>" />
…
<component … file="…<user directory>" />
…
</library>
A <path> element contains a path attribute, which specifies the path to a directory, or the path to another
.ipx file, and can use wildcards in its definition. An asterisk matches any file name. If you use an asterisk as
a directory name, it matches any number of subdirectories.
When searching the specified path, the following three types of files are identified:
• .ipx—Additional index files.
• _hw.tcl—Qsys component definitions.
• _sw.tcl—Nios II board support package (BSP) software component definitions.
A <component> element contains several attributes to define a component. If you provide the required
details for each component in an .ipx file, the startup time for Qsys is less than if Qsys must discover the
files in a directory. Example 6-6 shows two <component> elements. Note that the paths for file names are
specified relative to the .ipx file.
<library>
<component
Send Feedback
QII51020
2013.11.4 ip-catalog 6-43
version="0.9"
file="./components/qsys_converters/color/rgb2cmyk_hw.tcl"
/>
</library>
ip-catalog
The ip-catalog command displays the catalog of available components relative to the current project
directory in either plain text or XML format.
Usage
ip-catalog [--project-dir=<directory>][--name=<value>][--verbose]
[--xml][--help]
Options
• --project-dir= <directory>—Optional. Components are found in locations relative to the
project, if any. By default, the current directory, ‘.’ is used. To exclude a project directory, leave the value
empty.
• --name= <value>—Optional. This argument provides a pattern to filter the names of the components
found. To show all components, use a * or ‘ ‘. By default, all components are shown. The argument is not
case sensitive.
• --verbose—Optional. If set, reports the progress of the command.
• --xml—Optional. If set, generates the output in XML format, instead of a line and colon-delimited
format.
• --help—Shows help for the ip-catalog command.
ip-make-ipx
The ip-make-ipx command creates an .ipx file and is a convenient way to include a collection of
components from an arbitrary directory in the Qsys search path. You can also edit the .ipx file to disable
visibility of one or more components in the Qsys Library.
Usage
ip-make-ipx [--source-directory=<directory>] [--output=<file>]
[--relative-vars=<value>] [--thorough-descent] [--message-before=<value>]
[--message-after=<value>] [--help]
Options
Send Feedback
QII51020
6-44 Extending the Default Search Path 2013.11.4
Related Information
Intellectual Property & Reference Designs
Send Feedback
QII51020
2013.11.4 Running the Qsys Editor from the Command-Line 6-45
For command-line help listing all options for these executables, type the following command:
<Quartus II installation directory>\quartus\sopc_builder\bin\<executable name> --help
qsys-script --script=my_script.tcl \
--system-file=fancy.qsys my_script.tcl contains:
package require -exact qsys 13.1
# get all instance names in the system and print one by one
set instances [ get_instances ]
foreach instance $instances {
send_message Info "$instance"
}
Related Information
• Working with Instance Parameters in Qsys
• Altera Wiki Qsys Scripts
qsys-edit --jvm-max-heap-size=2g
Send Feedback
QII51020
6-46 Generating Qsys Systems with the qsys-generate Utility 2013.11.4
Send Feedback
QII51020
2013.11.4 Qsys Scripting Command Reference 6-47
The following is a list of options that you can use with the qsys-script utility:
• --system-file=<file>—Optional. Specifies the path to a .qsys system file. This system is loaded
before running scripting commands.
• --script=<file>—Optional. A file containing Tcl scripting commands for creating or manipulating
Qsys systems. If you specify both --cmd and --script, the --cmd commands are run before the
script specified by --script.
• --cmd=<value>—Optional. A string that contains Tcl scripting commands to create or manipulate
a Qsys system. If you specify both --cmd and --script, the --cmd commands are run before the
script specified by --script.
• --package-version=<value>—Optional. Specifies which system scripting Tcl API version to
use and determines the functionality and behavior of the Tcl commands. The Quartus II software supports
the Tcl API scripting commands. If you do not specify the version on the command-line, your Tcl script
must request the system scripting API directly with the package require -exact qsys <
version > command.
• --help—Optional. Displays help for the qsys-script tool.
• --search-path=<value>—Optional. If omitted, a standard default path is used. If provided, a
comma-separated list of paths is searched. To include the standard path in your replacement, use "$",
for example, /< directory path >/dir,$. Multiple directory references are separated with a
comma.
• --jvm-max-heap-size=<value>—Optional. The maximum memory size that is used by the
qsys-script tool. You specify this value as <size><unit> where unit can be m or M for multiples
of megabytes or g or G for multiples of gigabytes.
Send Feedback
QII51020
6-48 Qsys Scripting Command Reference 2013.11.4
Send Feedback
QII51020
2013.11.4 Qsys Scripting Command Reference 6-49
Send Feedback
QII51020
6-50 Qsys Scripting Command Reference 2013.11.4
Send Feedback
QII51020
2013.11.4 Qsys Scripting Command Reference 6-51
Send Feedback
QII51020
6-52 add_connection <start> [<end>] 2013.11.4
Returns None
Returns None
Send Feedback
QII51020
2013.11.4 add_interface <name> <type> <direction> 6-53
Returns None
auto_assign_base_addresses <instance>
This command assigns base addresses to memory-mapped interfaces on an instance in the system. Instance
interfaces that are locked with lock_avalon_base_address command keep their addresses during address
auto-assignment.
auto_assign_base_addresses
Returns None
auto_assign_irqs <instance>
This command assigns interrupt numbers to all connected interrupt senders on an instance in the system.
auto_assign_irqs
Returns None
Send Feedback
QII51020
6-54 auto_connect <element> 2013.11.4
auto_connect <element>
This command creates connections from an instance or instance interface to matching interfaces in other
instances in the system. For example, Avalon-MM slaves are connected to Avalon-MM masters.
auto_connect
Returns None
create_system [<name>]
This command replaces the current system in the system script with a new system with the specified name.
create_system
Returns None
Send Feedback
QII51020
2013.11.4 get_composed_connection_parameters <instance> <childConnection> 6-55
get_composed_connections <instance>
This command returns a list of all connections in a subsystem, for an instance that contains a subsystem.
get_composed_connections
Send Feedback
QII51020
6-56 get_composed_instance_assignments <instance> <childInstance> 2013.11.4
get_composed_instance_assignment
Send Feedback
QII51020
2013.11.4 get_composed_instance_parameters <instance> <childInstance> 6-57
get_composed_instance_parameter_value
get_composed_instances <instance>
This command returns a list of child instances in the subsystem, for an instance that contains a subsystem.
get_composed_instances
Send Feedback
QII51020
6-58 get_connection_parameter_value <connection> <parameter> 2013.11.4
get_connection_parameter_property
get_connection_parameters <connection>
This command returns a list of parameters found on a connection. The list of connection parameters is the
same for all connections of the same type.
get_connection_parameters
get_connection_properties
This command returns a list of properties found on a connection. The list of connection properties is the
same for all connections, regardless of type.
get_connection_properties
Usage get_connection_properties
Send Feedback
QII51020
2013.11.4 get_connection_property <connection> <property> 6-59
get_connection_properties
Arguments None
Example get_connection_properties
get_connections [<element>]
This command returns a list of connections in the system if no element is specified. If a child instance is
specified, for example cpu, all connections to any interface on the instance are returned. If an interface on
a child instance is specified, for example cpu.instruction_master, only connections to that interface
are returned.
get_connections
Example get_connections
get_connections cpu
get_connections cpu.instruction_master
Send Feedback
QII51020
6-60 get_instance_assignments <instance> 2013.11.4
get_instance_assignment
get_instance_assignments <instance>
This command returns a list of assignment keys for any assignments defined for the instance.
get_instance_assignments
Send Feedback
QII51020
2013.11.4 get_instance_interface_parameter_property <instance> <interface> <parameter> <property> 6-61
get_instance_interface_assignments
Usage get_instance_interface_parameter_property
<instance> <interface> <parameter> <property>
Returns various The value of the parameter
property.
Send Feedback
QII51020
6-62 get_instance_interface_parameters <instance> <interface> 2013.11.4
get_composed_connection_parameter_value
Send Feedback
QII51020
2013.11.4 get_instance_interface_properties 6-63
get_instance_interface_ports
get_instance_interface_properties
This command returns a list of properties that you can be query for an interface in a child instance.
get_instance_interface_properties
Usage get_instance_interface_properties
Arguments None
Example get_instance_interface_properties
get_instance_interfaces <instance>
This command returns a list of interfaces in a child instance.
Send Feedback
QII51020
6-64 get_instance_parameter_property <instance> <parameter> <property> 2013.11.4
get_instance_interfaces
get_instance_parameters <instance>
This command returns a list of parameters in a child instance.
Send Feedback
QII51020
2013.11.4 get_instance_port_property <instance> <port> <property> 6-65
get_instance_parameters
get_instance_properties
This command returns a list of properties for a child instance.
get_instance_properties
Usage get_instance_properties
Arguments None
Example get_instance_properties
Send Feedback
QII51020
6-66 get_instances 2013.11.4
get_instance_property
get_instances
This command returns a list of the instance names for all child instances in the system.
get_instances
Usage get_instances
Arguments None
Example get_instances
get_interface_ports <interface>
This command returns the names of all of the ports that have been added to an interface.
get_interface_ports
Send Feedback
QII51020
2013.11.4 get_interface_properties 6-67
get_interface_ports
get_interface_properties
This command returns the names of all the available interface properties. The list of interface properties is
the same for all interface types.
get_interface_properties
Usage get_interface_properties
Arguments None
Example get_interface_properties
get_interfaces
This command returns a list of top-level interfaces in the system.
get_interfaces
Usage get_interfaces
Arguments None
Example get_interfaces
Send Feedback
QII51020
6-68 get_module_properties 2013.11.4
get_module_properties
This command returns the properties that you can manage for the top-level module.
get_module_properties
Usage get_module_properties
Arguments None
Example get_module_properties
get_module_property <property>
This command returns the value of a top-level system property.
get_module_property
get_parameter_properties
This command returns a list of properties that you can query on parameters. These properties can be queried
on any parameter, such as parameters on instances, interfaces, instance interfaces, and connections.
get_parameter_properties
Usage get_parameter_properties
Arguments None
Example get_parameter_properties
get_port_properties
This command returns a list of properties that you can query on ports.
get_port_properties
Usage get_port_properties
Arguments None
Example get_port_properties
Send Feedback
QII51020
2013.11.4 get_project_properties 6-69
get_project_properties
This command returns a list of properties that you can query for the Quartus II project.
get_project_properties
Usage get_project_properties
Arguments None
Example get_project_properties
get_project_property <property>
This command returns the value of a Quartus II project property.
get_project_property
load_system <file>
This command loads a Qsys system from a file, and uses the system as the current system for scripting
commands.
load_system
Returns None
lock_avalon_base_address <instance.interface>
This command prevents the memory-mapped base address from being changed for connections to an
interface on an instance when the auto_assign_base_addresses or
auto_assign_system_base_addresses commands are run.
lock_avalon_base_address
Returns None
Send Feedback
QII51020
6-70 preview_insert_avalon_streaming_adapters 2013.11.4
lock_avalon_base_address
preview_insert_avalon_streaming_adapters
This command runs the adapter insertion for Avalon-ST connections, which adapt connections with
mismatched configuration, such as mismatched data widths.
preview_insert_avalon_streaming_adapters
Usage preview_insert_avalon_streaming_adapters
Returns None
Arguments None
Example preview_insert_avalon_streaming_adapters
remove_connection <connection>
This command removes a connection from the system.
remove_connection
Returns None
remove_instance <instance>
This command removes a child instance from the system.
remove_instance
Returns None
remove_interface <interface>
This command removes an exported top-level interface from the system.
Send Feedback
QII51020
2013.11.4 save_system [<file>] 6-71
remove_interface
Returns None
save_system [<file>]
This command saves the current in-memory system to the named file. If the file is not specified, the system
saves to the same file that was opened with the load_system command.
save_system
Returns None
Example save_system
save_system example.qsys
Return None
Send Feedback
QII51020
6-72 set_connection_parameter_value <connection> <parameter> <value> 2013.11.4
send_message
Send Feedback
QII51020
2013.11.4 set_instance_property <instance> <property> <value> 6-73
set_instance_parameter_value
Send Feedback
QII51020
6-74 set_project_property <property> <value> 2013.11.4
set_module_property
Return None
Return None
Return None
unlock_avalon_base_address <instance.interface>
This command allows the memory-mapped base address to be changed for connections to an interface on
an instance when the auto_assign_base_addresses or
auto_assign_system_base_addresses commands are run.
unlock_avalon_base_address
Send Feedback
QII51020
2013.11.4 upgrade_sopc_system <filename> 6-75
unlock_avalon_base_address
Return None
upgrade_sopc_system <filename>
This command loads the specified .sopc file, which then upgrades the file as a Qsys-compatible system. Some
child instances and interconnect are replaced so that the system functions in Qsys. You must save the new
Qsys-compatible system with the save_system command.
upgrade_sopc_system
Return None
validate_connection <connection>
This command validates the specified connection, and returns the during validation messages.
validate_connection
validate_instance <instance>
This command validates the specified child instance, and returns the validation messages.
validate_instance
Send Feedback
QII51020
6-76 validate_instance_interface <instance> <interface> 2013.11.4
validate_instance
validate_system
This command validates the system, and returns the validation messages.
validate_system
Usage validate_system
Arguments None
Example validate_system
Send Feedback
QII51020
2013.11.4 Document Revision History 6-77
November 2011 11.1.0 • Added Synopsys VCS and VCS MX Simulation Shell Script.
• Added Cadence Incisive Enterprise (NCSIM) Simulation Shell
Script.
• Added Using Instance Parameters and Example Hierarchical
System Using Parameters.
May 2011 11.0.0 • Added simulation support in Verilog HDL and VHDL.
• Added testbench generation support.
• Updated simulation and file generation sections.
Related Information
Quartus II Handbook Archive
Send Feedback