SOPC Builder User Guide PDF
SOPC Builder User Guide PDF
Subscribe
2010 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, HARDCOPY, MAX, MEGACORE, NIOS, QUARTUS and STRATIX are Reg. U.S. Pat. & Tm. Off. and/or trademarks of Altera Corporation in the U.S. and other countries. All other trademarks and service marks are the property of their respective holders as described at www.altera.com/common/legal.html. Altera warrants performance of its semiconductor products to current specifications in accordance with Alteras standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes 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.
Contents
December 2010
Altera Corporation
ii
Contents
Contents
iii
Default Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Validation Phase Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Elaboration Phase Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Generation Phase Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Edit Phase Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Overriding Default Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Validation Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Elaboration Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Generation Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 Editor Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711 Hardware Tcl Command Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712 Module Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721 Display Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729 Interfaces and Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732 Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738 Deprecated Commands and Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740
December 2010
Altera Corporation
iv
Contents
Example Design with SDR SDRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 912 DDR SDRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914 DDR2 SDRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914 Off-Chip SRAM and Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 915 Component-Level Design for SRAM and Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 915 SOPC Builder System-Level Design for SRAM and Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . 917 Simulation for SRAM and Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917 Quartus II Project-Level Design for SRAM and Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918 Board-Level Design for SRAM and Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918 Example Design with SRAM and Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 920
Contents
Resource Usage and Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Instantiating the Timing Adapter in SOPC Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Data Format Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Resource Usage and Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Instantiating the Data Format Adapter in SOPC Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Channel Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Resource Usage and Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Instantiating the Channel Adapter in SOPC Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Error Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Instantiating the Error Adapter in SOPC Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Installation and Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1210 Hardware Simulation Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1210 Software Programming Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1210
Additional Information
Document Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Info1 How to Contact Altera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Info1 Typographic Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Info1
December 2010
Altera Corporation
vi
Contents
SOPC Builder is a powerful system development tool. SOPC Builder enables you to define and generate a complete system-on-a-programmable-chip (SOPC) in much less time than using traditional, manual integration methods. SOPC Builder is included as part of the Quartus II software. For a quick introduction on how to use SOPC Builder, follow these general steps:
Install the Quartus II software, which includes SOPC Builder. This is available at www.altera.com. Take advantage of the one-hour online course, Using SOPC Builder. Download and run the checksum sample design described in Chapter 9, SOPC Builder Memory Subsystem Development Walkthrough.
You may have used SOPC Builder to create systems based on the Nios II processor. However, SOPC Builder is more than a Nios II system builder; it is a general-purpose tool for creating systems that may or may not contain a processor and may include a soft processor other than the Nios II processor. SOPC Builder automates the task of integrating hardware components. Using traditional design methods, you must manually write HDL modules to wire together the pieces of the system. Using SOPC Builder, you specify the system components in a GUI and SOPC Builder generates the interconnect logic automatically. SOPC Builder generates HDL files that define all components of the system, and a top-level HDL file that connects all the components together. SOPC Builder generates either Verilog HDL or VHDL equally. In addition to its role as a system generation tool, SOPC Builder provides features to ease writing software and to accelerate system simulation. This chapter includes the following sections:
Architecture of SOPC Builder Systems on page 11 Functions of SOPC Builder on page 15 Operating System Support on page 18 Talkback Support on page 18
December 2010
Altera Corporation
12
13
Example System
Figure 11 shows an FPGA design that includes an SOPC Builder system and custom logic modules. You can integrate custom logic inside or outside the SOPC Builder system. In this example, the custom component inside the SOPC Builder system communicates with other modules through an Avalon-MM master interface. The custom logic outside of the SOPC Builder system is connected to the SOPC Builder system through a PIO interface. The SOPC Builder system includes two SOPC Builder components with Avalon-ST source and sink interfaces. The system interconnect fabric connects all of the SOPC Builder components using the Avalon-MM or Avalon-ST system interconnect as appropriate.
Figure 11. Example of an FPGA with a SOPC Builder System Generated by SOPC Builder
Printed Circuit Board
SNK
Custom Logic
SRC
Bus Bridge
DDR2 Memory
Co-Processor
DDR2 2 Memory
M S
SRC
Avalon-MM Master Port Avalon-MM Slave Port Avalon-ST Source Port Avalon-ST Sink Port
SNK
December 2010
Altera Corporation
14
A component can be a logical device that is entirely contained within the SOPC Builder system, such as the processor component shown in Figure 11. Alternately, a component can act as an interface to an off-chip device, such as the DDR2 interface component in Figure 11. In addition to the Avalon interface, a component can have other signals that connect to logic outside the SOPC Builder system. Non-Avalon signals can provide a special-purpose interface to the SOPC Builder system, such as the PIO in Figure 11. These non-Avalon signals are described in Conduit Interface chapter in the Avalon Interface Specifications.
Available Components
Altera and third-party developers provide ready-to-use SOPC Builder components, including:
Microprocessors, such as the Nios II processor Microcontroller peripherals, such as a Scatter-Gather DMA Controller and timer Serial communication interfaces, such as a UART and a serial peripheral interface (SPI) General purpose I/O Communications peripherals, such as a 10/100/1000 Ethernet MAC Interfaces to off-chip devices
Custom Components
You can import HDL modules and entities that you write using Verilog HDL or VHDL into SOPC builder as custom components. You use the following design flow to integrate custom logic into an SOPC Builder system: 1. Determine the interfaces used to interact with your custom component. 2. Create the component logic using either Verilog HDL or VHDL. 3. Use the SOPC Builder component editor to create an SOPC Builder component with your HDL files. 4. Instantiate your component in the system. Once you have created an SOPC Builder component, you can use the component in other SOPC Builder systems, and share the component with other design teams. f For instructions on developing a custom SOPC Builder component, the details about the file structure of a component, or the component editor, refer to Chapter 4, SOPC Builder Components. f For details on the Avalon-MM interface refer to Chapter 2, System Interconnect Fabric for Memory-Mapped Interfaces. For details on the Avalon-ST interface, refer to Chapter 3, System Interconnect Fabric for Streaming Interfaces.
15
Third-Party Components
You can also use SOPC-ready components that were developed by third-parties. Altera awards the SOPC Builder Ready certification to IP functions that are ready to integrate with the Nios II embedded processor or the system interconnect fabric via SOPC Builder. These cores support the Avalon-MM interface or the Avalon Streaming (Avalon-ST) interface and may include constraints, software drivers, simulation models, and reference designs when applicable. To find SOPC Builder Ready third-party components that you can purchase and use in SOPC Builder systems, complete the following steps: 1. On the Tools menu in SOPC Builder, click Download Components. 2. On the Intellectual Property Solutions web page, type SOPC Builder ready r in the box labeled Search for IP, Development Kits and Reference Designs.
An HDL file for the top-level SOPC Builder system and for each component in the system. The top-level HDL file is named <system_name>.v for Verilog HDL designs and <system_name>.vhd for VHDL designs. Synopsis Design Constraints file (.sdc) for timing analysis. A Block Symbol File (.bsf) representation of the top-level SOPC Builder system for use in Quartus II Block Diagram Files (.bdf). An example of an instance of the top-level HDL file, <SOPC_project_name_inst>.v or <SOPC_project_name_inst>.vhd, which demonstrates how to instantiate the top-level HDL file in your code. A data sheet called <system_name>.html that provides a system overview including the following information:
All external connections for the system A memory map showing the address of each Avalon-MM slave with respect to each Avalon-MM master to which it is connected All parameter assignments for each component
A functional test bench for the SOPC Builder system and ModelSim simulation project files
December 2010
Altera Corporation
16
SOPC information file (.sopcinfo) that describes all of 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 SOPC Builder components. A Quartus II IP File (.qip) that provides the Quartus II software with all required information about your SOPC Builder system. The .qip file includes references to the following information:
HDL files used in the SOPC Builder system TimeQuest Timing Analyzer Synopsys Design Constraint (.sdc) files Component definition files for archiving purposes
After you generate the SOPC Builder system, you can compile it with the Quartus II software, or you can instantiate it in a larger FPGA design.
Instantiates the SOPC Builder system Drives all clocks and resets Instantiates simulation models for off-chip devices when available
17
2. Simulate at the unit-level, possibly incorporating Avalon BFMs to verify the system. 3. Complete the SOPC Builder design by adding other components, specifying interrupts, clocks, resets, and addresses. 4. Generate the SOPC Builder system. 5. Perform system level simulation. 6. Constrain and compile the design. 7. Download the design to an Altera device. 8. Test in hardware.
Yes
Debug Design
Yes
Yes
Debug Design
December 2010
Altera Corporation
18
In the alternative top-down valid design flow, you begin by designing the SOPC Builder system and then define and instantiate custom SOPC Buildder component. This approach clarifies the system requirements earlier in the design process. Designs targeting HardCopy devices are require specific design constraints. Consequently, if you are targeting a HardCopy series device, you must verify you design for the HardCopy companion device. Follow these guidelines to verify your design for both devices: 1. In the Quartus II Device dialog box, select both the FPGA and the appropriate HardCopy companion device. 2. In Step 8 of the design flow shown in Figure 12, compile for both the FPGA and HardCopy device. 3. After Step 10 of the design flow shown in Figure 12, if FPGA passes all functional simulation and hardware verification tests, generate the HardCopy handoff archive and send this archive to the HardCopy Design Center for the backend flow and tapeout.
Talkback Support
Talkback is a Quartus II software feature that provides feedback to Altera on tool and IP feature usage. Altera uses the data to help guide future product planning efforts. Talkback sends Altera information on the Altera components you use, including: interface types, interface properties, parameter names and values, clocking, and software assignments. For components from Altera, Talkback sends the component parameter values to help understand what features of the component are being used. For non-Altera components, Talkback collects information about how interfaces such as Avalon-MM are being used. Connectivity between components is not sent. The Talkback file does not include information about system connectivity, interrupts, or the memory map seen by each master in the system. Talkback collects the same very general information about your proprietary components. The Talkback feature is enabled by default. You can disable Talkback from within the Quartus II software if you do not wish to share your usage data with Altera.
The system interconnect fabric for memory-mapped interfaces is a high-bandwidth interconnect structure for connecting components that use the Avalon Memory-Mapped (Avalon-MM) interface. The system interconnect fabric consumes less logic, provides greater flexibility, and higher throughput than a typical shared system bus. It is a cross-connect fabric and not a tristated or time domain multiplexed bus. This chapter describes the functions of system interconnect fabric for memory-mapped interfaces and the implementation of those functions.
High-Level Description
The system interconnect fabric is the collection of interconnect and logic resources that connects Avalon-MM master and slaves on components in a system. SOPC Builder generates the system interconnect fabric to match the needs of the components in a system. The system interconnect fabric implements the connection details of a system. It guarantees that signals are routed correctly between master and slaves, as long as the ports adhere to the rules of the Avalon Interface Specifications. This chapter provides information on the following topics:
Address Decoding on page 23 Datapath Multiplexing on page 24 Wait State Insertion on page 25 Pipelined Read Transfers on page 26 Dynamic Bus Sizing and Native Address Alignment on page 26 Arbitration for Multimaster Systems on page 29 Burst Adapters on page 214 Interrupts on page 215 Reset Distribution on page 216
f For details about the Avalon-MM interface, refer to the Avalon Interface Specifications. System interconnect fabric for memory-mapped interfaces supports the following items:
Any number of master and slave components. The master-to-slave relationship can be one-to-one, one-to-many, many-to-one, or many-to-many. On-chip components. Interfaces to off-chip devices. Master and slaves of different data widths. Components operating in different clock domains. Components using multiple Avalon-MM ports.
December 2010
Altera Corporation
22
Figure 21 shows a simplified diagram of the system interconnect fabric in an example memory-mapped system with multiple masters. 1 All figures in this chapter are simplified to show only the particular function being discussed. In a complete system, the system interconnect fabric might alter the address, data, and control paths beyond what is shown in any one particular figure.
Processor
Instruction M Data M
S Control
DMA Controller
Read M Write M
MUX
Tri-State Bridge
S Instruction Memory
S Data Memory
S SDRAM Controller
S Ethernet MAC/PHY Chip S Flash Memory Chip
SDRAM Chip Write Data & Control Signals Read Data Interface to Off-Chip Device S Avalon-MM Slave Port
SOPC Builder supports components with multiple Avalon-MM interfaces, such as the processor component shown in Figure 21. Because SOPC Builder can create system interconnect fabric to connect components with multiple interfaces, you can create complex interfaces that provide more functionality than a single Avalon-MM interface. For example, you can create a component with two different Avalon-MM slaves, each with an associated interrupt interface. System interconnect fabric can connect any combination of components, as long as each interface conforms to the Avalon Interface Specifications. It can, for example, connect a system comprised of only two components with unidirectional dataflow between them. Avalon-MM interfaces are suitable for random address transactions, such as to memories or embedded peripherals.
23
Generating system interconnect fabric is SOPC Builders primary purpose. In most cases, you are not required to modify the generated HDL; however, a basic understanding of how HDL works can help you optimize your system. For example, knowledge of the arbitration algorithm can help designers of multimaster systems minimize the impact of arbitration on the system throughput.
Fundamentals of Implementation
System interconnect fabric for memory-mapped interfaces implements a partial crossbar interconnect structure that provides concurrent paths between master and slaves. System interconnect fabric consists of synchronous logic and routing resources inside the FPGA. For each component interface, system interconnect fabric manages Avalon-MM transfers, interacting with signals on the connected component. Master and slave interfaces can contain different signals and the system interconnect fabric handle any adaptation necessary between them. In the path between master and slaves, the system interconnect fabric might introduce registers for timing synchronization, finite state machines for event sequencing, or nothing at all, depending on the services required by the specific interfaces. f For more information, refer to the Avalon Memory-Mapped Design Optimizations chapter in the Embedded Design Handbook.
Address Decoding on page 23 Datapath Multiplexing on page 24 Wait State Insertion on page 25 Pipelined Read Transfers on page 26 Arbitration for Multimaster Systems on page 29 Burst Adapters on page 214 Interrupts on page 215 Reset Distribution on page 216
The behavior of these functions in a specific SOPC Builder system depends on the design of the components in the system and the settings made in SOPC Builder. The remaining sections of this chapter describe how SOPC Builder implements each function.
Address Decoding
Address decoding logic in the system interconnect fabric forwards appropriate addresses to each slave. Address decoding logic simplifies component design in the following ways:
December 2010
Altera Corporation
24
The system interconnect fabric selects a slave whenever it is being addressed by a master. Slave components do not need to decode the address to determine when they are selected. Slave addresses are properly aligned to the slave interface. Changing the system memory map does not involve manually editing HDL.
Figure 22 shows a block diagram of the address-decoding logic for one master and two slaves. Separate address-decoding logic is generated for every master in a system. As Figure 22 shows, the address decoding logic handles the difference between the master address width (<M>) and the individual slave address widths (<S> and <T>). It also maps only the necessary master address bits to access words in each slaves address space.
Figure 22. Block Diagram of Address Decoding Logic
read/write address [S..0]
In SOPC Builder, the user-configurable aspects of address decoding logic are controlled by the Base setting in the list of active components on the System Contents tab, as shown in Figure 23.
Figure 23. Base Settings in SOPC Builder Control Address Decoding
Datapath Multiplexing
Datapath multiplexing logic in the system interconnect fabric drives the writedata signal from the granted master to the selected slave, and the readdata signal from the selected slave back to the requesting master.
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Wait State Insertion
25
Figure 24 shows a block diagram of the datapath multiplexing logic for one master and two slaves. SOPC Builder generates separate datapath multiplexing logic for every master in the system.
Figure 24. Block Diagram of Datapath Multiplexing Logic
readdata1
Slave Port 1
Slave Port 2
readdata2
In SOPC Builder, the generation of datapath multiplexing logic is specified using the connections panel on the System Contents tab.
System interconnect fabric can force a master to wait for several reasons in addition to the wait state needs of a slave. For example, arbitration logic in a multimaster system can force a master to wait until it is granted access to a slave.
December 2010
Altera Corporation
26
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Pipelined Read Transfers
SOPC Builder generates wait state insertion logic based on the properties of all slaves in the system.
No pipeline
Pipelined
Pipelined
Pipelined
SOPC Builder generates logic to handle pipeline latency based on the properties of the master and slaves in the system. When configuring a system in SOPC Builder, there are no settings that directly control the pipeline management logic in the system interconnect fabric.
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Dynamic Bus Sizing and Native Address Alignment
27
The following sections explain the implications of the address alignment property slave devices.
Eliminates the need to create address-alignment hardware manually. Reduces design complexity of the master component. Enables any master to access any memory device, regardless of the data width.
In the case of dynamic bus sizing, the system interconnect fabric includes a small finite state machine that reconciles the difference between master and slave data widths. The behavior is different depending on whether the master data width is wider or narrower than the slave.
Wider Master
In the case of a wider master, the dynamic bus-sizing logic accepts a single, wide transfer on the master side, and then performs multiple narrow transfers on the slave side. For a data-width ratio of <N>:1, the dynamic bus-sizing logic generates up to <N> slave transfers for each master transfer. The master waits while multiple slave-side transfers complete; the master transfer ends when all slave-side transfers end. Dynamic bus-sizing logic uses the master-side byte-enable signals to generate appropriate slave transfers. The dynamic bus-sizing logic performs as many slave-side transfers as necessary to write or read the specified byte lanes.
Narrower Master
In the case of a narrower master, one transfer on the master side generates one transfer on the slave side. In this case, multiple master word addresses map to a single offset in the slave memory space. The dynamic bus-sizing logic maps each master address to a subset of byte lanes in the appropriate slave offset. All bytes of the slave memory are accessible in the master address space.
December 2010
Altera Corporation
28
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Dynamic Bus Sizing and Native Address Alignment
Table 22 demonstrates the case of a 32-bit master accessing a 64-bit slave with dynamic bus sizing. In the table, offset refers to the offset into the slave memory space.
Table 22. 32-Bit Master View of 64-Bit Slave with Dynamic Bus Sizing 32-bit Address 000000000 (word 0) 000000004 (word 1) 000000008 (word 2) 00000000C (word 3) OFFSET[0]31..0 OFFSET[0]63..32 OFFSET[1]31..0 OFFSET[1]63..32 Data
In the case of a read transfer, the dynamic bus-sizing logic multiplexes the appropriate byte lanes of the slave data to the narrow master. In the case of a write transfer, the dynamic bus-sizing logic uses slave-side byte-enable signals to write only to the appropriate byte lanes. 1 Altera recommends that you select dynamic bus sizing whenever possible. Dynamic bus sizing offers more flexibility when the master and slave components in your system have different widths.
When connecting a wide master to a narrow slave port that uses native addressing, the following addressing formula should be used to determine what address to present to the system interconnect fabric:
<master address> = <slave base address> + (<slave word offset> * <master data width in bytes>)
For example, a 64-bit master needs to write to the second word of a 32-bit slave that uses native addressing the formula would reduce to:
<master address> = <slave base address> + (1 * 8)
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Arbitration for Multimaster Systems
29
SOPC Builder generates appropriate address-alignment logic based on the properties of the master and slaves in the system. When configuring a system in SOPC Builder, there are no settings that directly control the address alignment in the system interconnect fabric.
Eliminates having to create arbitration hardware manually. Allows multiple masters to transfer data simultaneously. Unlike traditional host-side arbitration architectures where each master must wait until it is granted access to the shared bus, multiple Avalon-MM masters can simultaneously perform transfers with independent slaves. Arbitration logic stalls a master only when multiple masters attempt to access the same slave during the same cycle. Eliminates unnecessary master-slave connections. The connection between a master and a slave exists only if it is specified in SOPC Builder. If a master never initiates transfers to a specific slave, no connection is necessary, and therefore SOPC Builder does not waste logic resources to connect the two ports. Provides configurable arbitration settings, and arbitration for each slave is specified independently. For example, you can grant one master more arbitration shares than others, allowing it to gain more access cycles to the slave. The arbitration share settings are defined for each slave independently. Simplifies master component design. The details of arbitration are encapsulated inside the system interconnect fabric. Each Avalon-MM master connects to the system interconnect fabric as if it is the only master in the system. As a result, you can reuse a component in single-master and multimaster systems without requiring design changes to the component.
December 2010
Altera Corporation
210
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Arbitration for Multimaster Systems
In traditional bus architectures, one or more bus masters and bus slaves connect to a shared bus, consisting of wires on a printed circuit board or on-chip routing. A single arbiter controls the bus (that is, the path between bus masters and bus slaves), so that multiple bus masters do not simultaneously drive the bus. Each bus master requests control of the bus from the arbiter, and the arbiter grants access to a single master at a time. Once a master has control of the bus, the master performs transfers with any bus slave. When multiple masters attempt to access the bus at the same time, the arbiter allocates the bus resources to a single master, forcing all other masters to wait. Figure 26 illustrates the bus architecture for a traditional processor system. Access to the shared system bus becomes the bottleneck for throughput: only one master has access to the bus at a time, which means that other masters are forced to wait and only one slave can transfer data at a time.
Figure 26. Bus Architecture in a Traditional Microprocessor System
Masters Master 1 System CPU Master 2 DMA Controller
Slaves
UART
PIO
Program Memory
Data Memory
Slave-Side Arbitration
The system interconnect fabric uses multimaster architecture to eliminate the bottleneck for access to a shared bus. Multiple masters can be active at the same time, simultaneously transferring data with independent slaves. For example, Figure 21 on page 22 demonstrates a system with two masters (a CPU and a DMA controller) sharing a slave (an SDRAM controller). Arbitration is performed at the SDRAM slave; the arbiter dictates which master gains access to the slave if both masters initiate a transfer with the slave in the same cycle.
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Arbitration for Multimaster Systems
211
Figure 27 focuses on the two masters and the shared slave and shows additional detail of the data, address, and control paths. The arbiter logic multiplexes all address, data, and control signals from a master to a shared slave.
Figure 27. Detailed View of Multimaster Connections
M1 Address Master 1 M1 Write Data Arbiter Request Control M2 Address M2 Write Data Request Control Address Write Data Control Slave
Master 2
Arbiter Details
SOPC Builder generates an arbiter for every slave, based on arbitration parameters specified in SOPC Builder. The arbiter logic performs the following functions for its slave:
Evaluates the address and control signals from each master and determines which master, if any, gains access to the slave next. Grants access to the chosen master and forces all other requesting masters to wait. Uses multiplexers to connect address, control, and datapaths between the multiple masters and the slave.
December 2010
Altera Corporation
212
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Arbitration for Multimaster Systems
Figure 28 shows the arbiter logic in an example multimaster system with two masters, each connected to two slaves.
Figure 28. Block Diagram of Arbiter Logic
S1 Read Data & Control
Master 1 (M1)
Slave 1 (S1)
Master 2 (M2)
Slave 2 (S2)
Arbitration Rules
This section describes the rules by which the arbiter grants access to masters when they contend.
The arbitration settings are hidden by default. To see them, on the View menu, click Show Arbitration.
Chapter 2: System Interconnect Fabric for Memory-Mapped Interfaces Arbitration for Multimaster Systems
213
Fairness-Based Shares
Arbiter logic uses a fairness-based arbitration scheme. In a fairness-based arbitration scheme, each master pair has an integer value of transfer shares with respect to a slave. One share represents permission to perform one transfer. For example, assume that two masters continuously attempt to perform back-to-back transfers to a slave. Master 1 is assigned three shares and Master 2 is assigned four shares. In this case, the arbiter grants Master 1 access for three transfers, then Master 2 for four transfers. This cycle repeats indefinitely. Figure 210 demonstrates this case, showing each masters transfer request output, wait request input (which is driven by the arbiter logic), and the current master with control of the slave.
Figure 210. Arbitration of Continuous Transfer Requests from Two Masters
clk M1_transfer_request M1_waitrequest M2_transfer_request M2_waitrequest Current_Master Master 1 Master 2 Master 1 Master 2 Master 1
If a master stops requesting transfers before it exhausts its shares, it forfeits all its remaining shares, and the arbiter grants access to another requesting master. Refer to Figure 211. After completing one transfer, Master 2 stops requesting for one clock cycle. As a result, the arbiter grants access back to Master 1, which gets a replenished supply of shares.
Figure 211. Arbitration of Two Masters with a Gap in Transfer Requests
clk M1_transfer_request M1_waitrequest M2_transfer_request M2_waitrequest Current_Master Master 1
Master 2
Master 1
Master 2
Master 1
Master 2
Round-Robin Scheduling
When multiple masters contend for access to a slave, the arbiter grants shares in round-robin order. Round-robin scheduling drives a request interface according to space available and data available credit interfaces. At every slave transfer, only requesting masters are included in the arbitration.
December 2010
Altera Corporation
214
Burst Transfers
Avalon-MM burst transfers grant a master uninterrupted access to a slave for a specified number of transfers. The master specifies the number of transfers when it initiates the burst. Once a burst begins between a master-slave pair, arbiter logic does not allow any other master to access the slave until the burst completes. For burst masters, the size of the burst determines the number of cycles that the master has access to the slave, and the selected arbitration shares have no effect.
Burst Adapters
System interconnect fabric provides burst adaptation logic to accommodate the burst capabilities of each port in the system, including ports that do not support burst transfers. Burst adaptation logic consists of a finite state machine that translates the sequencing of address and control signals between the slave side and the master side. The maximum burst length for each port is determined by the component design and is independent of other ports in the system. Therefore, a particular master might be capable of initiating a burst longer than a slaves maximum supported burst length. In this case, the burst management logic translates the master burst into smaller slave bursts, or into individual slave transfers if the slave does not support bursts. Until the master completes the burst, the arbiter logic prevents other masters from accessing the target slave. For example, if a master initiates a burst of 16 transfers to a slave with maximum burst length of 8, the burst adapter logic initiates two bursts of length 8 to the slave. If the master initiates a burst of 14, the burst adapter logic segments the burst transfer into a burst of 8 words followed by a burst of 6 words, because the slave can only handle a maximum burst length of 8. If a master initiates a burst of 16 transfers to a slave that does not support bursts, the burst management logic initiates 16 separate transfers to the slave. 1 The burst adapter inserts one idle cycle at the start of each burst. System throughput is maximized when burst sizes are as large as possible. In the case of a non-linewrap burst master connected to a slave with the linewrapBursts property set to TRUE, it is not always possible to issue the maximumsized burst to the slave. In these cases the burst adapter is not capable of adapting the master and slave pairing. An adapter is generated; however, if the master performs a burst transaction to the slave that crosses the slave burst boundary data corruption can occur. To avoid a functional failure, you should ensure the master posts bursts of length one until the master burst boundary has been reached. The master burst boundary has an alignment of <master_data_width> <master_maximum_burst_length>. Any burst transaction that begins on a master burst boundary is guaranteed to not cross the burst boundary of the slave port regardless of the slave port's maximum burst length. Typically the only Avalon-MM interfaces that support burst wrapping are burst capable SDRAM controllers. f For more information about the linewrapBursts property, refer to the Avalon MemoryMapped Slave Interfaces chapter in the Avalon Interface Specifications.
215
Interrupts
In systems where components have interrupt request (IRQ) sender interfaces, the system interconnect fabric includes interrupt controller logic. A separate interrupt controller is generated for each interrupt receiver. The interrupt controller aggregates IRQ signals from all interrupt senders, and maps them to user-specified values on the receiver inputs. f For further information, refer to the Interrupt Interfaces chapter in the Avalon Interface Specifications.
Receiver
Sender 3
irq
December 2010
Altera Corporation
216
Using priority encoded interrupts, the interrupt controller can handle up to 64 slave IRQ signals. The interrupt controller generates a 1-bit irq signal to the receiver, signifying that one or more senders have generated an IRQ. The controller also generates a 6-bit irqnumber signal, which outputs the encoded value of the highest pending IRQ. See Figure 213.
Figure 213. IRQ Mapping Using Hardware Priority
Sender 1
irq
Interrupt Controller
Sender 2
irq
Receiver
Sender 4 irq irq0 irq1 irq2 irq3 irq4 irq5 irq6 irq63 irqnumber [5..0]
Priority Encoder
Reset Distribution
SOPC Builder generates the logic used in the system interconnect fabric, which drives the reset pulse to all the logic. The system interconnect fabric distributes the reset signal conditioned for each clock domain. The duration of the reset signal is at least one clock period. The system interconnect fabric asserts the system-wide reset in the following conditions:
The global reset input to the SOPC Builder system is asserted. Any component asserts its resetrequest signal.
The global reset and reset requests are ORed together. This signal is then synchronized to each clock domain associated to an Avalon-MM port, which causes the asynchronous resets to be de-asserted synchronously.
The interconnect fabric for Avalon Streaming connects high-bandwidth, low latency components that use the Avalon Streaming (Avalon-ST) interface. This interconnect fabric creates datapaths for unidirectional traffic including multichannel streams, packets, and DSP data. This chapter describes the Avalon-ST interconnect fabric and its use in connecting components with Avalon-ST interfaces. Descriptions of specific adapters and their use in streaming systems can be found in the following sections:
High-Level Description
Avalon-ST interconnect fabric is logic generated by SOPC Builder. Using SOPC Builder, you specify how Avalon-ST source and sink ports connect. SOPC Builder then creates a high performance point-to-point interconnect between the two components. The Avalon-ST interconnect is flexible and can be used to implement on-chip interfaces for industry standard telecommunications and data communications cores, such as Ethernet IEEE 802.3 MAC and SPI 4.2. In all cases, bus widths, packets, and error conditions are custom-defined. Figure 31 illustrates the simplest system example that generates an interconnect between the source and sink. This source-sink pair includes only the data and valid signals.
Figure 31. Interconnect for a Simple Avalon Streaming Source-Sink Pair
valid data
Data Source
Data Sink
Figure 32 illustrates a more extensive interface that includes signals indicating the start and end of packets, channel numbers, error conditions, and back pressure.
Figure 32. Avalon Streaming Interface for Packet Data
ready valid channel startofpacket endofpacket empty error data
Data Source
Data Sink
December 2010
Altera Corporation
32
Chapter 3: System Interconnect Fabric for Streaming Interfaces Avalon Streaming and Avalon Memory-Mapped Interfaces
All data transfers using Avalon-ST interconnect occur synchronously to the rising edge of the associated clock interface. All outputs from the source interface, including the data, channel, and error signals, must be registered on the rising edge of the clock. Registers are not required for inputs at the sink interface. Registering signals only at the source provides for high frequency operation while eliminating back-to-back registration with no intervening logic. There is no inherent maximum performance of the interconnect. Throughput for a system depends on the components and how they are connected. f For details about the Avalon-ST interface protocol, refer to the Avalon Interface Specifications.
The data source in the Rx Interface transfers data to the data sink in the FIFO. The data source in the FIFO transfers data to the Tx Interface data sink.
33
In Figure 33, the Avalon-MM interface allows a processor to access the data source, FIFO or data sink to provide system control.
Figure 33. Use of the Avalon Memory-Mapped and Streaming Interfaces
Control Plane Avalon Memory Mapped Inteface :
Processor RAM UART Timer
Control Slave
Control Slave
Control Slave
FIFO
Data Sink
Data Source
Data Sink
Adapters
Adapters are configurable SOPC Builder components that are part of the streaming interconnect fabric. They are used to connect source and sink interfaces that are not exactly the same without affecting the semantics of the data. SOPC Builder includes the following four adapters:
You can add Avalon-ST adapters between two components with mismatched interfaces. The adapter allows you to connect a data source to a data sink of differing byte sizes. If you connect mismatched Avalon-ST sources and sinks in SOPC Builder without inserting adapters, SOPC Builder generates error messages. Inserting adapters into the system does not change the types of components that SOPC Builder allows you to connect. The Insert Avalon-ST Adapters command on the System menu attempts to correct these errors automatically, if possible, by inserting the appropriate adapter types.
December 2010
Altera Corporation
34
f For complete information about these adapters, refer to Chapter 12, Avalon Streaming Interconnect Components. The following sections provide an overview of these adapters.
128 bits
32 bits
32-bit TX Interface
32 bits
32-bit TX Interface
128 bits
32 bits
32-bit TX Interface
Timing Adapter
The timing adapter allows you to connect component interfaces that require a different number of cycles before driving or receiving data. This adapter inserts a FIFO between the source and sink to buffer data or pipeline stages to delay the back pressure signals. The timing adapter can also be used to connect interfaces that support the ready signal and those that do not.
35
Channel Adapter
The channel adapter provides adaptations between interfaces that have different support for the channel signal or channel-related parameters. For example, if the source channel is narrower than the sink channel, you can use this adapter to connect them. The high-order bits of the sink channel are connected to zero. You can also use this adapter to connect a source with a wider channel to a sink with a narrower channel. If the source provides data for a channel that the sink cannot receive, the data is not transferred.
Error Adapter
The error adapter ensures that per-bit error information provided by the source interface is correctly connected to the sink interfaces input error signal. Matching error conditions handled by the source and sink are connected. If the source has an error condition that is not supported by the sink, the signal is left unconnected; the adapter provides a simulation error message and an error indication if this error is ever asserted. If the sink has an error condition that is not supported by the source, the sinks input is tied to zero.
Multiplexer Examples
You can combine these adapters with streaming components to create datapaths whose input and output streams have different properties. The following sections provide examples of datapaths constructed using SOPC Builder in which the output stream is higher performance than the input stream:
The first example shows an output with double the throughput of each interface with a corresponding doubling of the clock frequency. The second example doubles the data width. The third example boosts the frequency of a stream by 10% by multiplexing input data from two sources.
December 2010
Altera Corporation
36
src Data Source input src 100 MHz On-Chip FIFO Memory Dual Clk sink sink src 200 MHz sink
Data Source input src Data Format 8 bits sink Adapter @100 MHz src 16 bits sink @100 MHz src Data Source input src Data Format 8 bits sink Adapter sink @100 MHz src 16 bits @100 MHz sink 16 bits @100 MHz
37
You do not need to know what the typical and maximum input channel utilizations are before attempting this. For example, if the first channel hits 50% utilization, the output stream exceeds 100% utilization.
Figure 37. Datapath to Boost the Clock Frequency
Data Source input On-Chip FIFO 30% 27.3% Memory Dual Clk channel utilization sample rate 8 bits src sink src 110 MHz @100 MHz
sink
On-Chip FIFO Memory Dual Clk 8 bits sink @100 MHz 80% channel utilization sink
sink
December 2010
Altera Corporation
38
An SOPC Builder component is a hardware design block available within SOPC Builder that can be instantiated in an SOPC Builder system. This chapter defines SOPC Builder components, with emphasis on the structure of custom components. A component includes the following:
The HDL description of the components hardware. A description of the interface to the component hardware, such as the names and types of I/O signals. A description of the parameters that determine the operation of the component. A GUI for parameterizing an instance of the component in SOPC Builder. Scripts and other information SOPC Builder requires to generate the HDL files for the component and integrate the component instance into the SOPC Builder system. Other component-related information, such as reference to software drivers, necessary for development steps downstream of SOPC Builder.
This chapter discusses the design flow for new and classic custom-defined SOPC Builder components, in the following sections:
Component Providers Component Hardware Structure on page 42 Exported Connection PointsConduit Interfaces on page 43 SOPC Builder Component Search Path on page 44 Component Structure on page 48 Classic Components in SOPC Builder on page 410
Component Providers
SOPC Builder components can be obtained from many providers, including the following:
The components automatically installed with the Quartus II software. Third-party IP developers can provide IP blocks as SOPC Builder-ready components, including software drivers and documentation. A list of third-party components can be found in SOPC Builder by clicking IP MegaStore on the Tools menu. Altera development kits, such as the Nios II Development Kit, can provide SOPC Builder components as features. You can use the SOPC Builder component editor to convert your own HDL files into custom components.
f For more information about the _hw.tcl file, refer to Chapter 6, Component Editor.
December 2010
Altera Corporation
42
Components that include their associated logic inside the SOPC Builder system Components that interface to logic outside the SOPC Builder system
System Module
43
December 2010
Altera Corporation
44
You can also export the Avalon interfaces to manually connect them to external devices or logic defined outside a system with Avalon-compatible signals. This method allows a direct connection to the Avalon interface from any device that has Avalon-compatible signals. You can also export the Avalon interface in either an HDL file using conduit interfaces, or in the _hw.tcl file without an HDL file. You export the Avalon interface signals as an HDL file with simple wire connections in the HDL description. The Avalon interface port signals are directly connected to external I/O signals in the HDL description. The conduit interface in the _hw.tcl file exports the external I/O signals to the top level of the system. In the _hw.tcl file, no HDL files are specified and only the Avalon signals and interface ports are declared in the file.
_hw.tcl files. Each _hw.tcl file defines a single component. IP Index (.ipx) files. Each file indexes a collection of available components.
In general, .ipx files facilitate faster startup for SOPC Builder and other tools because fewer files need to be read and analyzed. Some directories are searched recursively; others only to a specific depth. In the following list of search locations, a recursive descent is annotated by **. The * signifies any file. When a directory is recursively searched, the search stops at any directory containing a _hw.tcl or .ipx file; subdirectories are not searched.
In SOPC Builder, you can extend the default search path by including additional directories by clicking Options, then clicking IP Search Path and Add. These additional paths apply to all projects; that is, the paths are global to the current version of SOPC Builder. The search path is ultimately defined by the file, <$QUARTUS_INSTALLDIR>/sopc_builder/bin/root_components.ipx.
45
In Figure 42, the circled numbers identify three steps of the algorithm that SOPC follows during initialization. These steps are explained in the following paragraphs. 1. SOPC Builder recursively searches the <install_dir>/ip/ directory by default. It finds the file in the altera subdirectory, which tells it about all of the Altera components. library.ipx includes listings for all components found in its subdirectories. The recursive search stops when SOPC Builder finds this .ipx file. 2. As part of its recursive search, SOPC Builder also looks in the adjacent user_components directory. One level down SOPC Builder finds the component1 directory, which contains component1_hw.tcl. When SOPC Builder finds that component, the recursive descent stops so that no components in subdirectories of component1 are found. 3. SOPC Builder then searches in the adjacent component2 directory, which includes component2_hw.tcl. If SOPC Builder finds that component, the recursive descent stops. 1 If you save your _hw.tcl file in the <install_dir>/ip/ directory, SOPC Builder finds your _hw.tcl file and stops. SOPC Builder does not conduct the search just described.
December 2010
Altera Corporation
46
The user_components.ipx file includes a single line of code redirecting SOPC Builder to the location of the user library. Example 41 shows the code for this redirection.
Example 41. Redirect to User Library
<library> <path path="c:/<user_install_dir>/user_ip/**/*" /> /<library>
For both of these approaches, if you install a new version of the Quartus II software, you must also update the installation to include your libraries. You can verify that components are available and also decrease the time it takes to launch SOPC Builder by using two utilities, ip-catalog and ip-make-ipx. The following sections describe these utilities.
ipcatalog
Shows the a catalog of components in either plain text or XML format. Usage
ip-catalog --project-dir[=<directory>] --name[=<value>] --verbose[=<true|false>] --xml[=<true|false>] --help
47
Options
--project-dir[=<directory>]. Optional. Components can be found in certain locations relative to the project, if any. By default, the current directory, . is used. To exclude any project directory, use . --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[=<true|false>]. Optional. When true, reports the progress of the command. --xml[=<true|false>]. Optional. When true, prints the output in XML format instead of a line- and colon-delimited format. --help. Shows help for the ip-catalog command.
ip-make-ipx
This command creates an index file for the directory specified. It returns a 0 for successful completion and a non-zero value for failure. Usage
ip-make-ipx --source-directory[=<directory>] --output[=<file>] --relative-vars[=<value>] --thorough-descent --message-before[=<value>] --message-after[=<value>] --help
Options
--source-directory=<directory>. Optional. The directory to index. The default directory is .. You can also provide a comma separated list of directories. --output[=<file>]. Optional. The name of the file to generate. The default name is ./components.ipx. --relative-vars[=<value>]. Optional. Causes the output file to include references relative to the specified variable or variables where possible. You can specify multiple variables as a comma-separated list. --thorough-descent[=<true|false>]. Optional. If set, a component or .ipx file in a directory does not prevent subdirectories from being searched. --message-before[=<value>]. Optional. A message to print to stdout when indexing begins --message-after[=<value>]. Optional. A message to print to stdout when indexing completes --help. Show help for this command
December 2010
Altera Corporation
48
A <path> element contains a single attribute, also called path and may reference a directory with a wildcard, (*), or reference a single file. Two asterisks designate any number of subdirectories. A single asterisk designates a match to a single file or directory. In searching down the designated path, the following three types of files are identified:
.ipxadditional index files _hw.tclSOPC Builder component definitions _sw.tclNios II board support package (BSP) software component definitions
A <component> element contains several attributes to define a component. If you provide all the required details for each component in an .ipx file, the start-up time for SOPC Builder is less than if SOPC Builder must discover the files in a directory. Example 42 shows two <component> elements. Note that the paths for file names are specified relative to the .ipx file.
Example 42. Component Elements
<library> <component name="An SOPC Component" displayName="SOPC Component" version="2.1" file="./components/sopc_component/sc_hw.tcl" /> <component name="legacy_component" displayName="Legacy Component (Classic Edition!)" version="0.9" file="./components/legacy/old_component/class.ptf" /> </library>
Component Structure
Most components are defined with a _hw.tcl file, a text file written in the Tcl scripting language that describes the components in to SOPC Builder. You can add a component to SOPC Builder by either writing a Tcl description or you can use the component editor to generate an automatic Tcl description of it. This section describes the structure of Tcl components and how they are stored. f For details about the SOPC Builder component editor, refer to Chapter 6, Component Editor. For details about the SOPC Builder Tcl commands, refer to Chapter 7, Component Interface Tcl Reference.
49
A component description file, which is a Tcl file with file name of the form <entity name>_hw.tcl. Verilog HDL or VHDL files that define the top-level module of the custom component (optional).
The _hw.tcl file defines everything that SOPC Builder requires about the name and location of component design files. The SOPC Builder component editor saves components in the _hw.tcl format. You can use these Tcl files as a template for editing components by hand. When you edit a previously saved _hw.tcl file, SOPC Builder automatically saves the earlier version as _hw.tcl~. For more information about the information that you can include in the _hw.tcl file, refer to the Chapter 7, Component Interface Tcl Reference.
<component_directory>/
<hdl>/ a directory that contains the component HDL design files and the _hw.tcl file <component name>_hw.tclthe component description file <component name>.v or .vhdthe HDL file that contains the top-level module <component_name>_sw.tclthe software driver configuration file. This file specifies the paths for the .c and .h files associated with the component. <software>/a directory that contains software drivers or libraries related to the component, if any. Altera recommends that the software directory be subdirectory of the directory that contains the _hw.tcl file.
f For information on writing a device driver or software package suitable for use with the Nios II IDE design flow, refer to the Hardware Abstraction Layer section of the Nios II Software Developers Handbook. The Nios II Software Build Tool Reference chapter of the Nios II Software Developers Handbook describes the commands you can use in the Tcl script.
Component Versioning
You can create and maintain multiple versions of the same component using one of the following options:
Define the module property version in your _hw.tcl file. f For more information, refer to the Chapter 7, Component Interface Tcl Reference.
December 2010
Altera Corporation
410
If multiple versions of the component are defined in your component libraries, you can add a different the version of a component by right-clicking on the component and selecting Add version <version_number>. You can create an .ipx file in the same directory as your SOPC Builder project to control the search path for your project.
Classic components configured with the More Options tab in SOPC Builder, such as complex IP components provided by third-party IP developers, are not supported in the Quartus II software in version 7.1 and beyond. If your component has a bind program, you cannot use the component without recreating it with the component editor or with Tcl scripting. To make changes to a classic component with the component editor, you must first upgrade the component by editing the classic component and saving it in the _hw.tcl component format in the component editor.
This chapter describes the Quartus II software features that are used with SOPC Builder, including the following:
Quartus II IP File
The Quartus II IP File (.qip) generated by SOPC Builder provides the Quartus II software with all required information about your SOPC Builder system. SOPC Builder creates the .qip during system generation and adds a reference to it in the Quartus II Settings File (.qsf). The .qip file includes references to the following information:
HDL files used in the SOPC Builder system TimeQuest Timing Analyzer Synopsys Design Constraint (.sdc) files Component definition files for archiving purposes
The .qip file is based on Tcl scripting syntax and is similar to the .qsf file. The information required to process most components is included in the system's single .qip file. Some complex components provide their own .qip file, in which case the system's .qip file references the component .qip file. 1 The .qip file is normally added to your project automatically by SOPC Builder. If it does not get added automatically you can add the file in the same way that you add other source files to your project. You can also have a .qip file for each component in your design. When you generate a design, each .qip is pulled into the main .qip file for your system by reference.
December 2010
Altera Corporation
52
Chapter 5: Using SOPC Builder with the Quartus II Software TimeQuest Timing Analyzer
f For more information about incremental compilation, refer to the Quartus II Incremental Compilation for Hierarchical and Team-Based Design chapter in volume 1 of the Quartus II Handbook.
Analyzing PLLs
You must constrain PLL clocks for proper analysis by the TimeQuest Timing Analyzer. You can define clocks generated by PLLs using one of the following methods:
Use the derive_pll_clocks command to derive clocks for all PLL outputs in the design. This is the best method. Use the create_generated_clock command to designate each clock output. Use the -create_base_clocks option of the derive_pll_clock assignments to designate the base clock feeding the PLL.
The following example focuses on the use of the derive_pll_clocks assignment, because this method automatically defines clock frequencies and phase shifts. 1 derive_pll_clocks generates clocks for all PLLs in the Quartus II hardware project, not just for the PLLs in the SOPC Builder system.
Chapter 5: Using SOPC Builder with the Quartus II Software TimeQuest Timing Analyzer
53
The SOPC system shown in Figure 51 illustrates the use of the derive_pll_clocks assignment in the case of a single clock input and one PLL using a single output.
Figure 51. Example SOPC System
After running the following commands in the TimeQuest Timing Analyzer, two clocks are generated:
create_clock -name master_clk -period 20 [get_ports {clk}] derive_pll_clocks
The TimeQuest Timing Analyzer analyzes and reports performance of the constrained clocks in the Clocks Summary report. This displays a report as shown in Figure 52.
Figure 52. Clocks Summary Report
master_clk is defined by the create_clock command, and the_my_pll clock is derived from the derive_pll_clocks command.
December 2010
Altera Corporation
54
Chapter 5: Using SOPC Builder with the Quartus II Software TimeQuest Timing Analyzer
For the system described in the PLL section, the following command sets false paths for the PLL outputs:
set_false_path -to [get_ports {*_pio[*]}]
Because design contains a 4-bit PIO, filter *_pio[*] includes the following I/O pins.
FPGA
PLL
SDRAM clk
SDRAM
Exernal Clock
To constrain this interface, you must create a clock that is recognized by the external SDRAM; then you must set the I/O timing relative to that clock. Example 51 shows how to constrain a PLL output clock and set a Tcl variable for that clock.
Example 51. Constraining PLL Output Clock
create_clock -period 20.000 -name ext_clk [get_ports {clk}] derive_pll_clocks set sdram_clk\my_pll_inst|altpll_component|auto_generated|pll1|clk[0]
You can then use the create_generated_clock command to define a clock as recognized by the external memory. This generated clock automatically adds delays associated with routing to the clock output pin and the delay of the pin itself. You must also account for some board delay due to the PCB trace between the FPGA and SDRAM by using the offset option. The following command shows the creation of the sdram_clk_pin generated clock derived from the output pin sdram_clk clock. A 0.5 ns offset accounts for PCB routing delay.
Chapter 5: Using SOPC Builder with the Quartus II Software TimeQuest Timing Analyzer
55
There may be some uncertainty associated with the PCB delay not accounted for in this command. The uncertainty can be included in the I/O constraints that are specific to input or output and minimum or maximum delays. The I/O constraints must be defined in relation to the data sheet for the external memory. Figure 54 shows part of a data sheet for an SDRAM device with the worst case input and output timing highlighted for a CAS latency of 3.
Figure 54. AC Characteristics from SDRAM Device Data sheet
The mapping of external memory timing to FPGA I/O delays is shown in Table 51. This table also shows whether the minimum or maximum PCB routing delay should be used, which must be added to the FPGA delay constraints.
Table 51. External Memory Timing Memory Timing Max clock to out Min clock to out Min setup Min hold
Note to Table 51:
(1) The constraint for minimum output delay is actually 0 Min hold.
FPGA Timing Max input delay Min input delay Max output delay Min output delay (-ve)
December 2010
Altera Corporation
56
Chapter 5: Using SOPC Builder with the Quartus II Software TimeQuest Timing Analyzer
You can use the set_input_delay and set_output_delay commands to set the I/O constraints. In the following examples, a common PCB routing delay of 0.5ns 0.1 ns is used, which adds a 0.4 ns or 0.6 ns delay to the paths. Example 52 illustrates the use of these commands.
Example 52. set_input_delay and set_output_delay commands
set_input_delay -clock sdram_clk_pin -max [expr 5.5 + 0.6] <ports> set_input_delay -clock sdram_clk_pin -min [expr 2.5 + 0.4] <ports> set_output_delay -clock sdram_clk_pin -max [expr 2.0 + 0.6] <ports> set_output_delay -clock sdram_clk_pin -min [expr -1 + 0.4)]<ports>
In this example, <ports> represent a list of I/O ports for the relevant constraints as shown in Example 53.
Example 53. <ports>
set_output_delay -clock sdram_clk_pin -max [expr 2.0 + 1.2] \ [get_ports {cas_n ras_n cs_n we_n addr[*]}]
You can use multiple set_input_delay and set_output_delay commands to set different delays for different I/O.
Chapter 5: Using SOPC Builder with the Quartus II Software TimeQuest Timing Analyzer
57
f For more design examples, refer to TimeQuest Design Examples on www.altera.com. Also, AN: 433 Constraining and Analyzing Source-Synchronous Interfaces describes source synchronous constraints for the TimeQuest Timing Analyzer.
December 2010
Altera Corporation
58
Chapter 5: Using SOPC Builder with the Quartus II Software TimeQuest Timing Analyzer
6. Component Editor
The SOPC Builder component editor provides a GUI to support the creation and editing of the Hardware Component Description File (_hw.tcl) file that describes a component to SOPC Builder. You use the component editor to do the following:
Specify the Verilog HDL or VHDL files that describe the modules in your component hardware. Conversely, create an HDL template for a component by first defining its interface using the HDL Files tab of the component editor. Specify the signals for each of the components interfaces, and define the behavior of each interface signal. Specify relationships between interfaces, such as determining which clock interface is used by a slave interface. Declare any parameters that alter the component structure or functionality, and define a user interface to let users parameterize instances of the component.
f For information about using the component editor in a development flow, refer to the following pages on the Altera website: SOPC Builder Component Development Flow Using the Component Editor Overview. For information about Avalon component interfaces, refer to Avalon Component Interfaces Supported in the Component Editor Version 7.2 and Later. For examples of changes to typical Avalon interfaces, refer to Examples of Changes to Typical Avalon Interfaces for the Component Editor Version 7.2 and Later. For information about upgrading components, refer to Upgrading Your Component with SOPC Builder Component Editor Version 7.2 and Later. For information about the use of the component editor, see the following sections:
Starting the Component Editor on page 62. HDL Files Tab on page 62. Signals Tab on page 63. Interfaces Tab on page 66. HDL Parameters Tab on page 66. Saving a Component on page 67. Editing a Component on page 68. Component Parameterization on page 68.
f For more information about components, refer to Chapter 7, Component Interface Tcl Reference. For more information about the Avalon-MM interface, refer to the Avalon Interface Specifications.
December 2010
Altera Corporation
62
A component has one or more interfaces. Typically, an interface means an Avalon Memory-Mapped (Avalon-MM) master or slave or an Avalon Streaming (Avalon-ST) source or sink. You can also specify exported component signals that appear at the top-level of the SOPC Builder system, which can be connected to logic outside the SOPC Builder system. The component editor lets you build a component with any combination of Avalon interfaces, which include:
Avalon-MM master and slave Avalon-ST source and sink Avalon-MM tristate slave Interrupt sender and receiver Clock input and output Nios II custom instruction master and slave interfaces Conduit (for exporting signals to the top level)
Each interface is comprised of one or more signals. The component can represent logic that is instantiated inside the SOPC Builder system, or can represent logic outside the system with an interface to it on the generated system.
Bottom-Up Design
You can use the HDL Files tab to specify Verilog HDL or VHDL files that describe the component logic. Files are provided to downstream tools such as the Quartus II software and ModelSim in the same order as they appear in the table.
63
You can also use the component editor to define the interface to components outside the SOPC Builder system. In this case, you do not provide HDL files. Instead, you use the component editor to interactively define the hardware interface. After you specify an HDL file, the component editor analyzes the file by invoking the Quartus II Analysis and Elaboration module. The component editor analyzes signals and parameters declared for all modules in the top-level file. If the file is successfully analyzed, the component editors Signals tab lists all design modules in the Top Level Module list. If your HDL contains more than one module, you must select the appropriate top-level module from the Top Level Module list. All files are managed in a single table, with options for Synth and Sim. You can select the Top option to select the top-level file for synthesis. When the top-level module is changed, the component editor performs best-effort signal matching against the existing port definitions. If a port is absent from the module, it is removed from the port list. You can use the up and down arrows to specify the HDL file analysis order. By default, all files are added with both Synth and Sim options turned on. To add a simulation-only file, turn off the Synth option for that file. Files that turn on the Sim option are passed to ModelSim for simulation. To add a synthesis-only file, turn off the Sim file option. Only files that you mark for Synth are added to the Quartus II IP File (.qip) for your project. c The component editor determines the signals on the component when only the top-level module or entity is added to the table, but all of the files required for the component must be added for the component to compile in Quartus II software or work in simulation.
Top-Down Design
The Create HDL Template button on the HDL Files tab allows you to create an HDL template for a component if you have not provided a HDL description for it. Clicking the Create HDL Template button shows you the component HDL and lets you choose between Verilog HDL and VHDL. Altera recommends that you define your signals, interfaces, parameters and basic component information, including the component name, before creating the HDL template by clicking Save. The component editor writes <component_name>.v or <component_name>.vhd to your project directory. After you have component the components HDL code, you can add other files that are required to define your component, including the _hw.tcl file, and synthesis and simulation files using the Add button on the HDL Files tab.
Signals Tab
You use the Signals tab to specify the purpose of each signal on the top-level component module. If you specified a file on the HDL Files tab, the signals on the top-level module appear on the Signals tab. The Interface list also allows creation of a new interface so that you can assign a signal to a different interface without first switching to the Interfaces tab. Each signal must belong to an interface and be assigned a legal signal type for that interface. In addition to Avalon Memory-Mapped and Streaming interfaces, components typically have clock interfaces, interrupt interfaces, and perhaps a conduit interface for exported signals.
December 2010
Altera Corporation
64
For any value of <interface_name> the component editor automatically creates an interface by that name, if necessary, and assigns the signal to it. The <signal_type> must match one of the valid signal types for the type of interface. Refer to the Avalon Interface Specifications for the signal types available for each interface type. You can append _n to indicate an active-low signal. Table 61 lists the valid values for <interface_type>.
Table 61. Valid Values for <Interface Type> Value avs avm ats aso asi cso csi coe inr ins ncm ncs Avalon-MM slave Avalon-MM master Avalon-MM tristate slave Avalon-ST source Avalon-ST sink Clock output Clock input Conduit Interrupt receiver Interrupt sender Nios II custom instruction master Nios II custom instruction slave Meaning
65
Example 61 shows a Verilog HDL module declaration with signal names that infer two Avalon-MM slaves.
Example 61. Verilog HDL Module With Automatically Recognized Signal Names
module my_slave_irq_component ( // Signals for Avalon-MM slave port s1 with irq csi_clockreset_clk; //clockreset clock interface csi_clockreset_reset_n;//clockreset clock interface avs_s1_address;//s1 slave interface avs_s1_read; //s1 slave interface avs_s1_write; //s1 slave interface avs_s1_writedata; //s1 slave interface avs_s1_readdata; //s1 slave interface ins_irq0_irq; //irq0 interrupt sender interface ); input csi_clockreset_clk; input csi_clockreset_reset_n; input [7:0]avs_s1_address; input avs_s1_read; input avs_s1_write; input [31:0]avs_s1_writedata; output [31:0]avs_s1_readdata; output ins_irq0_irq;
Avalon-MM Slave Avalon-MM Slave with Interrupt Avalon-MM Master Avalon-MM Master with Interrupt Avalon-ST Source Avalon-ST Sink
After adding a typical Avalon interface using a template, you can add or delete signals to customize the interface.
December 2010
Altera Corporation
66
Interfaces Tab
The Interfaces tab allows you to configure the interfaces on your component and specify a name for each interface. The interface name identifies the interface and appears in the SOPC Builder connection panel. The interface name is also used to uniquely identify any signals that are ports on the top-level SOPC Builder system. The Interfaces tab allows you to configure the type and properties of each interface. For example, an Avalon-MM slave interface has timing parameters that you must set appropriately. The Interfaces tab displays waveforms that illustrate the timing that you specified. If you update the timing parameters, the waveforms automatically update to illustrate the new timing. The waveforms are available for the following interface types:
If you convert a component from a class.ptf to a _hw.tcl file, you may require three interfaces: a clock input, the Avalon slave, and an interrupt sender. A parameter in the interrupt sender must be set to reference the Avalon slave.
Click Preview the Wizard at any time to see how the component GUI appears. The following rules apply to HDL parameters exposed via the component GUI:
Editable parameters cannot contain computed expressions. If a parameter <N> defines the width of a signal, the signal width must be of the form <N-1>:0. When a VHDL component is used in a Verilog HDL SOPC Builder system, or vice versa, numeric parameters must be 32-bit decimal integers. When passing other numeric parameter types, unpredictable results occur.
f Refer to Chapter 7, Component Interface Tcl Reference for detailed information about creating and displaying parameters using Tcl scripts.
67
Library Info
The Library Info tab allows you to specify the following information about your component:
Display NameSpecifies the user-visible name for this component in SOPC Builder. VersionSpecifies the version number of the component. GroupSpecifies which group in SOPC Builder displays your component in the list of available components. If you enter a previously unused group name, SOPC Builder creates a new group by that name. DescriptionAllows you to describe the component. Created ByAllows you to specify the author of the component. IconAllows you to place an image in the title bar of your component, in place of the MegaCore logo. The icon can be a .jpg, .gif, or .png file. The directory for the icon is relative to the directory that contains the _hw.tcl file. DocumentationAllows you to specify multiple documents that pertain to your component. You can use this property to specify a file on the internet or in your companys file system. The specified file can be in either .html or .pdf format. To specify an internet file, begin your path with http://, for example: http://mydomain.com/datasheets/my_memory_controller.html. To specify a file in your companys file system, you begin you path with file:/// for Linux and file://// for Windows, for example: file:////company_server/datasheets/ my_memory_controller.pdf. For handwritten _hw.tcl files, you can specify documentation using the add_documentation_link Tcl command. f For more information refer to the add_documentation_link command in Chapter 7, Component Interface Tcl Reference.
Saving a Component
You can save the component by clicking Finish on any of the tabs, or by clicking Save on the File menu. Based on the settings you specify in the component editor, the component editor creates a component description file with the file name <class-name>_hw.tcl. The component editor saves the file in the same directory as the HDL file that describes the components hardware interface. If you did not specify an HDL file, you can save the component description file to any location you choose. You can relocate component files later. For example, you could move component files into a subdirectory and store it in a central network location so that other users can instantiate the component in their systems. The _hw.tcl file contains relative paths to the other files, so if you move the _hw.tcl file you should move all the HDL and other files associated with it. 1 Altera recommends that you store _hw.tcl files for a project is in the ip/<class-name> directory for the project. You should store the HDL and other files in the same directory as the _hw.tcl file.
December 2010
Altera Corporation
68
Editing a Component
After you save a component and exit the component editor, you can edit it in SOPC Builder. To edit a component, right-click it in the list of available components on the System Contents tab and click Edit Component. 1 You cannot edit components that were created outside of the component editor, such as Altera-provided components. If you edit the HDL for a component and change the interface to the top-level module, you need to edit the component to reflect the changes you made to the HDL.
Software Assignments
You can use Tcl commands to create software assignments.You can register any software assignment that you want, as arbitrary key-value pairs. Example 62 shows a typical Tcl API script:
Example 62. Typical Software Assignment with Tcl API Scripting
set_module_assignment name value set_interface_assignment name value
The assignments are added to the SOPC information file (.sopcinfo), available for use for downstream components.
Component Parameterization
To edit component instance parameters, select a component in the System Contents tab of the SOPC Builder window and click Edit.
You define SOPC Builder components by declaring their properties and behaviors in a Hardware Component Description File (_hw.tcl). Each _hw.tcl file represents one component instance which you can add to an SOPC Builder system. You can also share the components that you design with other designers. For your component to have maximum flexibility, you should consider what aspects of its behavior can be parameterized so that other users can change the default parameterization to address different design requirements. An SOPC Builder component is usually composed of the following four types of files:
_hw.tcl filedescribes the SOPC Builder related characteristics, such as interface behaviors. This file is required. HDL filesdefine the components functionality as hardware. These files are optional. _sw.tclused by the software build tools to compile the component driver code. This file is optional. Component driver filesdefines the component register map and driver software to allow software to control the component. These files are optional.
Information in a Hardware Component Description File Component Phases on page 72 Writing a Hardware Component Description File on page 72 Overriding Default Behaviors on page 78 Hardware Tcl Command Reference on page 712
Basic component informationincludes the components name, version, and description, a link to its documentation, and pointers to HDL implementation files for synthesis and simulation. Parameter DeclarationsParameters are values that the user of your component can set that affect how the component is implemented, such as the size of a memory. Properties of each parameter include the parameters name, whether or not it is visible, and, if visible, the text to display when describing it. When the SOPC Builder system is generated, the parameters can be applied to the component as Verilog HDL parameters or VHDL generics. Interface PropertiesThe interfaces of a component define how to connect it to the rest of the system and determine how other components in the system interact with it. When you add interfaces to a component, you declare which signals make up each interface. You also define interface properties, such as wait states for an Avalon Memory-Mapped (Avalon-MM) interface.
December 2010
Altera Corporation
72
Depending on your component design, your _hw.tcl file may be one of the following two types:
StaticA static _hw.tcl file defines the top-level HDL file and associated component files. The HDL that describes a static component is created by the component author and is not changed by users of the component. HDL parameters are available when instantiating the component. GeneratedA generated _hw.tcl file provides a user-defined program to generate the components HDL. The HDL can be different for different parameterizations of the component.
Component Phases
The following section describes the distinct phases in the development of an SOPC Builder component.
Main ProgramSOPC Builder first discovers a component and adds it to the component library. The _hw.tcl file is executed and the Tcl statements provide non-instance-specific information to SOPC Builder. During this phase, some component interfaces may be incompletely described and ports may have a width of 0 or -1 to indicate that they are variable. ValidationValidation allows the component to generate error, warning, or informational messages. Validation occurs when an instance of a component is created, when its parameters are changed, or when some other property of the system is changed. ElaborationElaboration occurs as SOPC Builder queries a component for its interface information. Elaboration typically occurs immediately after validation and before generation. Interfaces defined in the main program can be enabled or disabled during elaboration. Depending on the validation callback code, elaboration and validation may alternate a few times. Elaboration and validation always occur before generation. Once elaboration is complete, the component must be completely described. For example, all port widths must have positive values. GenerationGeneration creates all the information that the Quartus II software and HDL simulator require. The required files typically include VHDL or Verilog HDL files, simulation models, timing constraints, and other information. EditorAfter an instance of your component has been added to an SOPC Builder system, allows the user of your component to edit the GUI that displays the parameterization. You can change the appearance of the default editor to make it easier to use.
Chapter 7: Component Interface Tcl Reference Writing a Hardware Component Description File
73
The version number is a Quartus II release version such as 10.0. SOPC builder guarantees that a valid _hw.tcl file that requests a particular sopc package behaves identically in future versions of the tool. Because of differences between versions of the Quartus II software, you cannot assume that an HDL file that works with one sopc package automatically works with other versions of the package. 1 This chapter describes the behavior of components that request the sopc 10.0 package. For earlier releases, refer to the documentation for that release.
f An excellent source of information about Tcl syntax is the Tcl Developer Xchange website.
Example 71. Basic Information for _hw.tcl File
# The package command must be the first command in the file package require -exact sopc 10.0 # The name and VERSION of the component set_module_property NAME example_uart set_module_property VERSION 1.0 # The name of the component to display in the library set_module_property DISPLAY_NAME "Example Component" # The components description. set_module_property DESCRIPTION "An Example Component" # The component library group that component belongs to set_module_property GROUP Examples
Declaring Parameters
By including configuration parameters in your _hw.tcl file, you allow users of your component to parameterize it in different ways. Each parameter has a number of properties such as its name, type, display name, and default value that can be used to control how the parameter is displayed and used. Example 72 illustrates the use of parameters that can be configured by users of your component.
Example 72. Declaring Parameters
# Declare Baud Rate parameter as an integer with a default value of 9600. add_parameter BAUD_RATE int 9600 # Display this parameter as "Baud Rate" in the Parameter Editor. set_parameter_property BAUD_RATE DISPLAY_NAME "Baud Rate (bps)" # We only support three baud rates set_parameter_property BAUD_RATE ALLOWED_RANGES {9600 19200 38400}
December 2010
Altera Corporation
74
Chapter 7: Component Interface Tcl Reference Writing a Hardware Component Description File
Parameters can be divided into three types: user parameters, system information parameters and derived parameters. The following sections describe these parameter types.
User Parameters
User parameters are parameters that users have control over and that are exposed in the component GUI.
Derived Parameters
Derived parameters are parameters that are inferred by the component itself from user parameters or other derived parameters. For example, a clock period parameter can be derived from a data rate parameter.
SYSTEM_INFO Parameters
You can use SYSTEM_INFO parameter to request that certain parameter values are populated with information about the system. For example, you might want to know the frequency of the clock that ends up being connected to your clock input. When you declare SYSTEM_INFO properties, you provide an <info-type> and further arguments. The <info-type> is the type of information you want, such as clock_rate, and you use the additional arguments to specify things, such as which clock input interface you require. Example 73 illustrates the use of the SYSTEM_INFO parameter. For more information about the SYSTEM_INFO parameter properties refer to Table 75 on page 726
Example 73. Syntax of Tcl Command using the SYSTEM_INFO Parameter set_parameter_property my_parameter SYSTEM_INFO {<info-type> [<arg>]}
Chapter 7: Component Interface Tcl Reference Writing a Hardware Component Description File
75
Declaring Interfaces
To declare an interface, use the add_interface command. Then use the set_interface_property and add_interface_port commands to set its properties and indicate which signals belong to it. The interface declaration statement includes the name of the interface, the interface direction, and the clock interface with which it is associated. For interfaces that are not associated with clocks (such as clock interfaces themselves), omit the associated clock interface, or use the word asynchronous. Example 74 illustrates interface declaration.
Example 74. Declare Interfaces
# Declare the clock sink interface, "clock_sink", type=clock, direction=sink add_interface clock_sink clock sink # The clock interface has two signals, named "clk" and "reset_n" of types "clk" "reset_n" add_interface_port clock_sink clk clk input 1 add_interface_port clock_sink reset_n reset_n input 1 # Declare the Avalon slave interface, name=avalon_slave_0, type=avalon, # directon=slave, associated with the clock_sink clock interface. add_interface avalon_slave_0 avalon slave clock_sink # Set a number of properties about the Avalon Slave interface set_interface_property avalon_slave_0 writeWaitTime 0 set_interface_property avalon_slave_0 addressAlignment DYNAMIC set_interface_property avalon_slave_0 readWaitTime 1 set_interface_property avalon_slave_0 readLatency 0 # Declare all the signals that belong to my Avalon Slave interface add_interface_port avalon_slave_0 my_readdata readdata output 8 add_interface_port avalon_slave_0 my_read read input 1 add_interface_port avalon_slave_0 my_write write input 1 add_interface_port avalon_slave_0 my_waitrequest waitrequest output 1 add_interface_port avalon_slave_0 my_address address input 24 add_interface_port avalon_slave_0 my_writedata writedata input 8
December 2010
Altera Corporation
76
Default Behaviors
The _hw.tcl file described in the previous section has default behaviors during the editor, validation, elaboration, and generation phases. These default behaviors apply to instances of a component. This section describes the default SOPC Builder behaviors for each of these phases. To override these default behaviors, refer to Overriding Default Behaviors on page 78.
77
multiplication, and division operators are allowed. For more complex port widths, the width of the port can be set as an arbitrary function of the components parameters in an elaboration callback. The width expression is the last argument to the add_interface_port command. Example 76 illustrates the use of mathematical operators and the width_expr property.
Example 76. Defining Port Widths Using Simple Mathematical Operators
add_interface_port din din_data data input {WIDTH * SYMBOLS} set_port_property din_data width_expr WIDTH
If the component defines the TOP_LEVEL_HDL_MODULE property, SOPC Builder creates a Verilog HDL or VHDL wrapper module to instantiate the top-level module and applies the parameters as selected by the user of your component. SOPC Builder does not apply parameters in the wrapper if they are not declared in the underlying HDL file. or
If the component does not define the TOP_LEVEL_HDL_MODULE property, but instead sets the INSTANTIATE_IN_SYSTEM_MODULE module property to false, the module is not instantiated inside the SOPC Builder system and a wrapper file is not created. Rather, the interface to the module is exported to the top-level of the SOPC Builder system, and the module must be connected outside the system.
December 2010
Altera Corporation
78
You can place parameters in logical groups and provide images and text to create a custom GUI for your component. Example 77 defines four parameters and illustrates the use of the add_display_item command and the DISPLAY_HINT and ALLOWED_RANGES parameters.
Example 77. Defining and Customizing GUI Parameters
# provide an icon for the sound group add_display_item icon Speaker speaker-image speaker.png add_parameter sound string 0 0 add_parameter volume_control boolean 0 0 add_parameter separate_control string 0 0 # Setup display_names for the parameters set_parameter_property sound DISPLAY_NAME Audio set_parameter_property volume_control DISPLAY_NAME "Include Volume Control Interface" set_parameter_property separate_control DISPLAY_NAME "Treble/Bass Controls" # Display all parameters add_display_item Speaker add_display_item Speaker add_display_item Speaker in the Speaker group sound parameter volume_control parameter separate_control parameter
# There are 4 choices for the sound parameter. # Strings with internal spaces require double quotes set_parameter_property sound ALLOWED_RANGES {"0:No Audio" 1:Monophonic 2:Stereo 4:Quadraphonic} set_parameter_property separate_control ALLOWED_RANGES {"No Control" "Single Control" "Dual Controls"} #Specify how parameters should be displayed set_parameter_property volume_control DISPLAY_HINT boolean set_parameter_property separate_control DISPLAY_HINT radio
Figure 71 shows the GUI that the Tcl commands in Example 713 produces.
Figure 71. Parameter GUI for Audio Component
79
Validation Callback
You can use the validation callback to provide validation that extends beyond the default range checking. A validation callback is defined by setting the VALIDATION_CALLBACK module property to be the name of the validation callback procedure, as shown in Example 78. This validation procedure displays an error if you select a baud rate of 38400 and odd parity. You can also use the validation callback to set the value of derived parameters. Derived parameters are parameters that are derived from other parameters; their values are not editable and are not saved in the SOPC Builder design file (.sopc). You indicate that a parameter is derived by setting the parameter's DERIVED property to true. In Example 78 BAUDRATE_PRESCALE is a derived parameter whose value is 1/16 of the value of the BAUDRATE parameter.
Example 78. Custom Validation Callback Function
# Declare the validation callback. set_module_property VALIDATION_CALLBACK my_validation_callback # Add the BAUDRATE_PRESCALE parameter, and indicate that its derived add_parameter BAUDRATE_PRESCALE int 600 set_parameter_property BAUDRATE_PRESCALE DERIVED true # Add the PARITY parameter add_parameter PARITY string ODD set_parameter_property PARITY ALLOWED_RANGES {EVEN ODD} # The validation callback proc my_validation_callback {} { # Get the current value of parameters we care about set br [get_parameter_value BAUD_RATE] set p [get_parameter_value PARITY] # Display an error for invalid combinations. if {($br==38400) && ($p=="ODD")} { send_message warning "Odd parity at 38400 bps is not supported." } # Set the value of our DERIVED parameter set bp [expr $br / 16] set_parameter_value BAUDRATE_PRESCALE $bp }
Elaboration Callback
You can use an elaboration callback to change interface properties or add new interfaces as a function of parameter values. You define an elaboration callback by setting the ELABORATION_CALLBACK module property to the name of the elaboration callback function, as shown in Example 79. You can enable and disable interfaces from the elaboration callback if they are only needed for some parameterizations of the component. Example 79 shows how an Avalon-MM slave interface can be included in an instance of the component, based on the USE_STATUS_INTERFACE parameter. All of the functionality available in the validation callback can also be used in the elaboration callback; separate callbacks for validation and elaboration are not required.
December 2010
Altera Corporation
710
The elaboration callback will not be called when parameters with AFFECTS_ELABORATION=false are changed by the user of the component.
st_readdata readdata output 16 st_read read input 1 st_write write input 1 st_waitrequest waitrequest output 1 st_address address input 24 st_writedata writedata input 16
# The elaboration callback proc my_elaboration_callback {} { # Get the current value of parameters we care about set use_status [get_parameter_value USE_STATUS_INTERFACE] # Optionally add the status interface if { $use_status } { set_interface_property status_slave ENABLED true } }
Generation Callback
If you define a generation callback, SOPC Builder does not generate an HDL wrapper file to apply parameter values to your component. Instead, it calls the generation callback you defined during the generation phase, allowing the component to programmatically generate its HDL. A generation callback is defined by setting the GENERATION_CALLBACK module property to be the name of the generation callback function, as Example 710 illustrates. Generation callbacks typically retrieve the current value of the components parameters and the generation properties that guide the generation process, and then generate the HDL files and supporting files in Tcl or by calling an external program. The callback procedure also reports the required files to SOPC Builder with the add_file command. Any files added in the generation callback are in addition to the files added in the main body of the _hw.tcl file. The generation callback must write <output_name.v or .sv> for Verilog or <output_name.vhd> for VHDL to the specified <output_directory>. This file is a parameterized instance of the component. Other supporting files, such as .hex files to initialize memory, may be written to <output_directory>. These file names must begin with <output_name>. If the supporting files are the same for all parameterizations of the component, you add them from the main program rather than the generation
711
callback. If your system includes multiple instantiations of a component with different parameterizations, you must add the supporting files from the main program to prevent failures. If a static supporting file is only needed in some parameterizations of the component, you should add it from the main program and turn it on or off by setting its SYNTHESIS and SIMULATION properties appropriately from the elaboration callback.
Example 710. Generation Callback Example
set_module_property GENERATION_CALLBACK my_generate # My generation method proc my_generate {} { send_message info "Starting Generation" # get generation settings set language [get_generation_property HDL_LANGUAGE] set outdir [get_generation_property OUTPUT_DIRECTORY ] set outputname [get_generation_property OUTPUT_NAME ] # get parameter values set p1 [get_parameter_value PARAMETER_ONE] set csr [get_parameter_value CSR_ENABLED] # Your callback needs to write $outdir$outputname.v here, # perhaps by using exec to call an external program. # add_file creates files relative to the _hw.tcl directory; therefore specify $outdir # for synthesis and simulation files exec perl my_generate.pl lang=$language dir=$outdir name=$outputname p1=$p1 csr=$csr add_file ${outdir}${outputname}.v SYNTHESIS add_file ${outdir}${outputname}_sim.v SIMULATION }
Editor Callback
You can use the editor callback procedure to replace the parameterization GUI. An editor callback is defined by setting the EDITOR_CALLBACK module property to the name of your editor callback procedure, as shown in the Example 711. If the editor callback is defined, SOPC Builder calls the editor callback instead of displaying the parameterization GUI, typically when the component is added to a system or updated after it is in the system. To display your custom GUI, the editor callback must call another program. Typically, an editor callback provides the current parameter values to your program via the command line and collects the new parameter values via stdout. The editor callback then uses the set_parameter_value command to update SOPC Builder with the new parameter values. The editor callback returns one of the following three values:
OKindicates that the results of the edit should be applied. CANCELindicates that the system should revert to the state it was in before the
ERRORindicates that the GUI was unable to launch. An appropriate error message
should be displayed.
December 2010
Altera Corporation
712
Module Definition on page 714 Parameters on page 721 Display Items on page 729 Interfaces and Ports on page 732 Generation on page 738
The description of each command indicates during which phases it is available: in the main body of the program (main), or during the validation, elaboration, generation, and editor callback phases, or any combination. Table 72 summarizes the commands and provides a reference to the full description.
713
Starting with Quartus II software version 9.1, all Tcl commands that you can use in the validation callback are also available in the elaboration callback. With this change, you may be able to omit the custom validation callback by including some validation commands in your elaboration callback.
Table 72. Command Summary (Note 1) (Part 1 of 2) Command Module Definition package <require> -exact sopc <version> get_module_properties get_module_property <propertyName> set_module_property <propertyName> <propertyValue> get_module_ports get_module_assignments get_module_assignment <moduleName> set_module_assignment <moduleName> [value] get_files add_file filename [<fileProperties> . . . ] add_documentation_link <docType> <title> <fileOrUrl> get_file_properties get_file_property <filename> <propertyName> set_file_property <filename> <propertyName> <propertyValue> send_message <messageLevel> <messageText> Parameters add_parameter <parameterName> <parameterType> [<defaultValue> <description>] get_parameters get_parameter_properties get_parameter_property <parameterName> <propertyName> set_parameter_property <parameterName> <propertyName> <value> get_parameter_value <parameterName> set_parameter_value <parameterName> <value> decode_address_map <address_map_XML_string> Display Items add_display_item <groupName> <id> <type> [<additionalInfo>] GET_DISPLAY_ITEMS GET_DISPLAY_ITEM_properties GET_DISPLAY_ITEM_PROPERTY <itemName> <propertyName> set_display_item_PROPERTY <itemName> <propertyName> <value> Interfaces and Ports add_interface <interfaceName> <interfaceType> <direction> [<associatedClock>] page 733 page 729 page 731 page 731 page 731 page 731 page 722 page 722 page 723 page 727 page 727 page 728 page 728 page 728 page 714 page 715 page 716 page 717 page 717 page 717 page 718 page 718 page 718 page 719 page 719 page 720 page 720 page 720 page 721 Full Description
December 2010
Altera Corporation
714
Table 72. Command Summary (Note 1) (Part 2 of 2) Command get_interfaces <interfaceName> get_interface_property <interfaceName> <propertyName> set_interface_property <interfaceName> <propertyName> <value> add_interface_port <interfaceName> <portName> <portRole> [<direction> <width_expr>] get_interface_ports [<interfaceName>] get_port_properties get_port_property <portName> <propertyName> set_port_property <portName> <propertyName> [<value>] get_interface_assignments get_interface_assignment <interfaceName> <name> set_interface_assignmet <interfaceName> <name> [<value>] Generation get_generation_property <propertyName> get_generation_properties
Note to Table 72:
(1) Arguments enclosed in []s are optional
Full Description page 733 page 734 page 735 page 735 page 736 page 736 page 737 page 737 page 738 page 738 page 738
Module Definition
This section provides information about the commands that you use to define and query a module.
package
The package command allows you to specify a particular version of the SOPC Builder software to avoid software compatibility issues. You should use the package command at the beginning of your _hw.tcl file. When used, the component files behave as if they are interpreted by the version of the SOPC Builder software that you specify. When the package command is not used, version 9.0 of the SOPC Builder software is assumed. For components designed before 9.0, you can set the required package to 9.0. This document describes the behavior of component which start with package require -exact sopc 10.0 For earlier releases, refer to the documentation for that release. f package is a standard Tcl command. For more information on this command refer to the following web page: http://www.tcl.tk/man/tcl8.0/TclCmd/package.htm
package Callback availability Usage Returns Main (before any other commands in the file) package require -exact sopc <version> None
715
package Arguments Example version The version of SOPC Builder that you require, specified as decimal number
get_module_properties
This command returns the names of all the available module properties as a list of strings. You can use the get_module_property and set_module_property commands to get and set values of individual properties. The value returned by this command is always the same for a particular version of SOPC Builder.
get_module_properties Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_module_properties List of strings None get_module_properties
Table 73 lists the available module properties, their use, and the phases in which they can be set.
Table 73. Module Properties (Part 1 of 2) Property Name AUTHOR DESCRIPTION DISPLAY_NAME EDITABLE Property Type String String String Boolean Can Be Set Main program Main program Main program Main program Description The modules author. The description of the module, such as Example SOPC Builder Module. The name to display when referencing the module, such as My SOPC Component. Indicates if the component is editable in the component editor. The name of the editor callback. The default parameterization UI is displayed if this property is not set. The name of the elaboration callback. For static and generated components, the default elaborations used if this property is not set. The name of the generation callback. The component group that the module belongs to, such as Example Components. A path to an icon to display in the modules parameter editor.
EDITOR_CALLBACK
String
Main program
December 2010
Altera Corporation
716
Table 73. Module Properties (Part 2 of 2) Property Name Property Type Can Be Set Description When false the instances of the module are not included in the generated system interconnect fabric. Instead, interfaces to the module are exported out of the top-level of the SOPC Builder system. The directory containing the _hw.tcl file. All relative file names within the Tcl file are resolved relative to this directory. This directory is set as the current directory when running the main program or a callback. The path to the _hw.tcl file. The name of the module, such as my_sopc_component. Indicates which of the files added by the add_file command contains the modules top-level HDL. Indicates the name of the top-level module which must be defined in the modules top-level HDL file. The name of the validation callback. This callback is run in addition to the default validation. The modules version, such as 8.1.
INSTANTIATE_IN_SYSTEM_MODULE
Boolean
Main program
MODULE_DIRECTORY
String
MODULE_TCL_FILE NAME
String String
TOP_LEVEL_HDL_FILE
String
Main program
TOP_LEVEL_HDL_MODULE
String
Main program
VALIDATION_CALLBACK VERSION
String String
The INSTANTIATE_IN_SYSTEM_MODULE, TOP_LEVEL_HDL_MODULE and GENERATION_CALLBACK commands are used to select the type of generation used by the component. You must set only one of these in the main program of your file.
get_module_property
This command returns the value of a single module property.
get_module_property Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_module_property <propertyName> String, boolean, or file propertyName One of the properties listed in Table 73 on page 715 set my_name [get_module_property NAME]
717
set_module_property
This command allows you to set the values for module properties.
set_module_property Callback availability Usage Returns Arguments Example Main program set_module_property <propertyName> <propertyValue> None propertyName propertyValue One of the properties listed in Table 73 on page 715 The new value of the property
get_module_ports
This command returns a list of the names of all the ports which are currently defined.
get_module_ports Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_module_ports String None get_module_ports
get_module_assignments
This command returns names of the module assignment variables.
get_module_assignments Callback availability Usage Returns Arguments Example Main, validation, elaboration, and compose get_module_assignments String None get_module_assignments
December 2010
Altera Corporation
718
get_module_assignment
This command returns the value of the specified argument. You can use the get_module_assignment and set_module_assignment and the get_interface_assignment and set_interface_assignment commands to transfer information about hardware components to embedded software tools and applications.
get_module_assignment Callback availability Usage Returns Arguments Example Main, validation, elaboration, and compose get_module_assignment <name> String name The name whose value is being retrieved get_module_assignment embedded.sw.CMacro.colorSpace
set_module_assignment
This command sets the value of the specified argument.
set_module_assignment Callback availability Usage Returns Arguments Example Main, validation, elaboration, and compose set_module_assignment <name> [<value>] None name value The name whose value is being set The value of the <name> argument
get_files
This command returns a list of all the files that have been added to the module.
get_files Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_files List of strings None set list_of_files [get_files]
719
add_file
This command adds a synthesis, simulation, or TimeQuest constraints file to the module. Files added in the main program cannot be removed. Adding files in the generation callback allows the included files to be a function of the parameter set or to be a result of generation. Files added in callbacks are in addition to any files added in the main program.
add_file Callback availability Usage Returns Main and generation add_file filename [<fileProperties> . . . ] String filename Arguments The file name to be added, relative to the directory containing the _hw.tcl file Files support the following 3 properties: fileProperties
Example
add_documentation_link
This command allows you to add multiple documentation links for a single component.
add_documentation_link Callback availability Usage Returns Main add_documentation_link filename <docType> <title> <fileOrUrl> None docType Arguments title fileOrUrl One of the following document types: USER_GUIDE, RELEASE_NOTES, WEBLINK, ERRATA, DATASHEET, REFERENCE_MANUAL, WAVEFORM, SCHEMATICS. TUTORIAL, OTHER The title of the document for use on menus and buttons. A path to the component documentation, using a syntax that provides the entire URL, not a relative path. For example: http://www.mydomain.com/my_ memory_controller.html or file:///datasheet.txt.
Example
December 2010
Altera Corporation
720
get_file_properties
This command returns the list of all properties that have been defined for a file.
get_file_properties Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_file_properties List of strings None get_file_properties
get_file_property
This command returns the value of a single file property. The file name passed as an argument may be a partial as long as it is unique. For example, if the full file name is /components/my_file.v, my_file.v is sufficient.
get_file_property Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_file_property <filename> <propertyName> Boolean filename propertyName The file name whose properties are being retrieved The file name property whose value is being retrieved
set_file_property
This command sets the value of a single file property. The file name passed to the function can be a partial file name as long as it is unique. For example, if the full file name is /components/my_file.v, my_file.v is sufficient. The available properties are described in the add_files command.
set_file_property Callback availability Usage Returns Arguments Example Main, elaboration, and generation set_file_property <filename> <propertyName> <propertyValue> Boolean filename propertyName propertyValue The file name whose properties are being retrieved Name of the file property whose value is being retrieved Value to set for the file property
721
send_message
This command sends a message to the user of the component. The message text is normally interpreted as HTML. The <b> element can be used to provide emphasis. If you do not want the message text to be interpreted as HTML then pass a list like { info text } as the message level.
send_message Callback availability Usage Returns Main, validation, elaboration, generation, and editor send_message <messageLevel> <messageText> None The following 4 message levels are supported:
Errorprovides an error message. The SOPC Builder system cannot be generated while there are error messages. Warningprovides a warning message. Infoprovides an informational message. Debugprovides messages when debug mode is enabled.
Arguments
messageLevel
messageText Example
Parameters
Parameters allow users of your component to affect its operation in the same manner as Verilog HDL parameters or VHDL generics.
add_parameter
This command adds a parameter to your component. Most of the parameter types are self-explanatory because they are used in the C programming language or HDL. However, the string_list and integer_list parameters that are used to create tables in GUIs require some explanation.
When you use the add_parameter command with a string_list or integer_list parameter type, the parameter you define is displayed in a variable-sized table that includes add and remove buttons.
December 2010
Altera Corporation
722
If you define multiple parameters of type string_list or integer_list, you can also use the add_display_item command to specify that parameters should each be displayed as a column in a table, each parameter of type string_list or integer_list becomes a column in the table. Example 712 illustrates the use of the integer_list parameter types to create a multi-column table.
Example 712. Creating Tables Using the string_list and integer_list Parameter Types
add_parameter bitsWide INTEGER add_parameter divider INTEGER add_parameter coefficients INTEGER_LIST add_parameter positions INTEGER_LIST add_display_item myTable coefficients TABLE add_display_item myTable positions TABLE
add_parameter Callback availability Usage Returns Main program add_parameter <parameterName> <parameterType> [<defaultValue> <description>] String parameterName parameterType defaultValue description Example A name that you, the component author, choose for your parameter The following types are supported: Integer, Natural, Positive, Boolean, Std_logic, Std_logic_vector, String, String_list, and Integer_list. The default length of the parameter is derived from its range. Explains the use of the parameter
Arguments
get_parameters
This command returns the names of all parameters that have been previously defined by add_parameter as a space separated list.
get_parameters Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_parameters List of strings None set parameter_summary [get_parameters]
723
get_parameter_properties
This command returns a list of all the available parameter properties as a list of strings. The get_parameter_property and set_parameter_property commands are used to get and set the values of these properties, respectively.
get_parameter_properties Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_parameter_properties List of strings None set property_summary [get_parameter_properties]
Table 74 describes the properties available to describe the behaviors of each of the parameters you can specify, their use, and when they can be set.
Table 74. Parameter Properties (Part 1 of 3) Property Name Type/ Default Can Be Set Description Set AFFECTS_ELABORATION to false for parameters that do not affect the external interface of the module. An example of a parameter that does not affect the external interface is isNonVolatileStorage. An example of a parameter that does affect the external interface is width. When the value of a parameter changes, if that parameter has set AFFECTS_ELABORATION=false, the elaboration phase (calling the callback or hardware analysis) is not repeated, improving performance. Because the default value of AFFECTS_ELABORATION is true, the provided HDL file is normally re-analyzed to determine the new port widths and configuration every time a parameter changes. The default value of AFFECTS_GENERATION is false if you provide a top-level HDL module, it is true if you provide a custom generation callback. Set AFFECTS_GENERATION to false if the value of a parameter does not change the results of system generation.
AFFECTS_GENERATION
Boolean, refer to
DESCRIPTION
Main program
December 2010
Altera Corporation
724
Table 74. Parameter Properties (Part 2 of 3) Property Name Type/ Default Can Be Set Description Indicates the range or ranges that the parameter value can have. For integers, The ALLOWED_RANGES property is a list of ranges that the parameter can take on, where each range is a single value, or a range of values defined by a start and end value separated by a colon, such as 11:15. This property can also specify legal values and display strings for integers, such as {0:None 1:Monophonic 2:Stereo 4:Quadrophonic} meaning 0,1,2,4 are the legal values. You can also assign longer strings to be displayed in the GUI to string variables. For example, ALLOWED_RANGES {"dev1:Cyclone IV GX" "dev2:Stratix V GT"}Refer to Example 77 on page 78 and Figure 71 on page 78 for additional examples illustrating the use of this property. When true, indicates that the parameter value does not need to be stored, typically because it is set from the validation callback. The default value is false. A user-visible description of the parameter. Provides a hint about how to display a property. The following values are possible:
ALLOWED_RANGES
String, ""
Main program
DERIVED
Main program
DESCRIPTION
Main program
booleanfor integer parameters whose value can be 0 or 1. The parameter displays as a checkbox. radiodisplays a parameter with a list of values as radio buttons instead of a drop-down list. hexadecimalfor integer parameters, display and interpret the value as a hexadecimal number, for example: 0x00000010 instead of 16. fixed_sizefor string_list and integer_list parameters, the fixed_size DISPLAY_HINT eliminates the add and remove buttons from tables.
DISPLAY_HINT
String, ""
Main program
Refer to Example 77 on page 78 and Figure 71 on page 78 for examples illustrating the use of this property. DISPLAY_NAME DISPLAY_UNITS String, "" String, "" Main program Main program This is the GUI label that appears to the left of the parameter. This is the GUI label that appears to the right of the parameter. When false, the parameter is disabled, meaning that it is displayed, but greyed out, indicating that it is not editable on the parameterization GUI. When true, the parameter must be passed to the HDL component description. The default value is false.
ENABLED
Main program, Boolean,tr validation, and ue elaboration, callbacks Boolean, false Main program
HDL_PARAMETER
725
Table 74. Parameter Properties (Part 3 of 3) Property Name Type/ Default Can Be Set Description This property allows you to change the default value of a parameter without affecting older components that have assigned a default value to this parameter using the defaultValue argument. The practical result is that older components will continue to use defaultValue for the parameter and newer components can use the value assigned by NEW_INSTANCE_VALUE. Allows you to assign information about the instantiating system to a parameter that you define. SYSTEM_INFO requires a keyword argument specifying the type of information requested, <info-type>. <infotype> may also take an argument. The syntax of the Tcl command is: set_parameter_property my_parameter SYSTEM_INFO <info-type> [<arg>] The following values for <info-type> are predefined: SYSTEM_INFO String, "" Main program
NEW_INSTANCE_VALUE
String, ""
Main program
UNITS
String, ""
Main program
Sets the units of the parameter. The following values are possible: picoseconds, nanoseconds, microseconds, milliseconds, seconds, hertz, kilohertz, megahertz, gigahertz, address, bits, bytes, kilobytes, megabytes, gigabytes, bitspersecond, kilobitspersecond, megabitspersecond, gigabitspersecond. For example, set_parameter_property frequency UNITS gigahertz Indicates whether or not to display the parameter in the parameterization GUI.
VISIBLE
December 2010
Altera Corporation
726
Table 75 lists the properties that you can use with the system_info parameter property.
Table 75. SYSTEM_INFO Properties (Part 1 of 2) Property ADDRESS_MAP String Type Description Assigns an XML formatted string describing the address map to the parameter you specify. set_parameter_property <my_parameter> SYSTEM_INFO {ADDRESS_MAP <my_avalon-mm_master>} Assigns an integer to the parameter that you specify that is the number of bits an Avalon-MM master must drive to address all of its slaves, using byte addresses. set_parameter_property <my_parameter> SYSTEM_INFO {ADDRESS_WIDTH <my_avalon-mm_master>} Assigns an integer representing the clock domain to the parameter you specify. You can use this command to determine whether multiple interfaces in your module are on the same clock domain. The absolute value of the integer value is arbitrary, but if two interfaces are on the same clock domain, the CLOCK_DOMAIN value is guaranteed to be the same and greater than zero. set_parameter_property <my_parameter> SYSTEM_INFO {CLOCK_DOMAIN <my_clk>} CLOCK_RATE Integer or String Assigns a positive number which is the clock frequency in Hz to the clock input interface you specify. Assigns 0 if the clock rate is not known. set_parameter_property <my_parameter> SYSTEM_INFO {CLOCK_RATE <my_clk>} Assigns the family name (not the specific device part number) of the currently selected device to the parameter you specify. set_parameter_property <my_parameter> SYSTEM_INFO {DEVICE_FAMILY} Creates a list of key/value pairs delineated by spaces indicating whether a particular device feature is available in the currently selected device family. The format of the list is suitable for passing to the Tcl array set command. This list is assigned to the parameter you specify. The following features are supported: M512_MEMORY, M4K_MEMORY, M9K_MEMORY, M144K_MEMORY, MRAM_MEMORY, MLAB_MEMORY, ESB, DSP, and EMUL. set_parameter_property <my_parameter> SYSTEM_INFO {DEVICE_FEATURES} Creates a mask indicating which bits of the interrupt receiver vector are connected to an interrupt sender. This mask is assigned to the parameter you specify. You can use this interrupt mask to optimize logic that handles interrupts. set_parameter_property <my_parameter> SYSTEM_INFO (INTERRUPTS_USED <my_interrupt_receiver>}
ADDRESS_WIDTH
Integer
CLOCK_DOMAIN Integer
DEVICE_FAMILY String
DEVICE_FEATURES String
INTERRUPTS_USED
Integer or string
727
Table 75. SYSTEM_INFO Properties (Part 2 of 2) Property MAX_SLAVE_DATA_WIDTH Integer set_parameter_property <my_parameter> SYSTEM_INFO {MAX_SLAVE_DATA_WIDTH <my_avalon_mm_master>} Assigns an integer representing the reset domain to the parameter you specify. You can use this command to determine whether multiple interfaces in your module are on the same reset domain. The absolute value of the integer value is arbitrary, but if two interfaces are on the same reset domain, the RESET_DOMAIN value is guaranteed to be the same and greater than zero. set_parameter_property <my_parameter> SYSTEM_INFO {RESET_DOMAIN <my_reset>} Type Description Assigns an integer to the parameter you specify that is the data width of the widest slave connected to the specified Avalon-MM master.
RESET_DOMAIN Integer
get_parameter_property
This command returns a single parameter property.
get_parameter_property Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_parameter_property <parameterName> <propertyName> string, boolean, or units depending on property refer to Table 74 on page 723 parameterName propertyName The name of the parameter whose property value is being retrieved One of the properties listed in Table 74 on page 723
set_parameter_property
This command sets a single parameter property.
set_parameter_property Callback availability Usage Returns Main, validation, and elaboration set_parameter_property <parameterName> <propertyName> <value> string, boolean, or units depending on property parameterName Arguments propertyName value Example Specifies the parameter that is being set Specifies the property of parameterName that is being set, refer to Table 74 on page 723 for a list of properties Provides the values
December 2010
Altera Corporation
728
get_parameter_value
This command returns the current value of a parameter defined previously with the add_parameter command.
Validation, elaboration (1), compose. generation, and editor get_parameter_value <parameterName> String parameterName Specifies the parameter that is being retrieved set fifo_width [get_parameter_value fifo_width]
set_parameter_value
This command sets a parameter value. The values of derived parameters can be set from the validation and elaboration callbacks. The values of parameters which are not marked as derived or system_info can be set from the editor callback.
set_parameter_value Callback availability Usage Returns Arguments Example Validation, elaboration, and editor set_parameter_value <parameterName> <value> None parameterName value Specifies the parameter that is being set Specifies the value of parameterName
decode_address_map
This is a utility function to convert an XMLformatted address map into a list of Tcl lists. Each inner list is in the correct format for conversion to an array. The XML code describing each slave includes: its name, start address, and end address + l. Figure 72 shows a portion of an SOPC Builder system with three Avalon-MM slave devices.
Figure 72. SOPC Builder System with Three Avalon-MM Slaves
729
Example 713 shows the XML that describes the address map for the Avalon-MM master that accesses these slaves. The format of the XML string provided may differ from that described here, it may have different white space between the elements and could include additional attributes or elements. Using decode_address_map command to decode the XML representing an Avalon-MM masters address map is easier and ensures that your code will work with future versions of the XML address map. 1 Altera recommends that you use the code provided in the description of Example 713 to enumerate over the components within an address map, rather than writing your own parser.
decode_address_map Callback availability Usage Returns Arguments Validation, compose. elaboration, and generation decode_address_map <address_map_XML_string> List of Tcl lists, each one suitable for passing to array set address_map_ XML_string An XML string describing the address map of an Avalon-MM master.
Example
set address_map_xml [get_parameter_value my_map_param] set address_map_dec [decode_address_map $address_map_xml] foreach i $address_map_dec { array set info $i send_message info "Connected to slave $info(name)" }
Display Items
You specify your component GUI using the display commands.
add_display_item
You can use this command to specify the following aspects of component display:
You can create logical groups for a components parameters. For example, you might want to create separate groups for the components timing, size, and simulation parameters. A component displays the groups and parameters in the order that you specify the display items for them in the _hw.tcl file. You can create multi-column tables to present a components parameters. Refer to Example 712 on page 722 for an example that illustrates multi-column tables. You can specify an image to provide a pictorial representation of a parameter or parameter group.
December 2010
Altera Corporation
730
You can create a button by adding a display item of type action. The display item includes the name of the callback to run when the action is performed.
add_display_item Callback availability Usage Returns Main program add_display_item <groupName> <id> <type> [<additionalInfo>] String groupName id Specifies the group to which a display item belongs. Specifies the parameter or icon to be displayed in a group. Each display item associated with a component must have a different ID. Specifies the category of the display item. The following types are defined:
icona .gif, .jpg, or .png file parametera parameter in the instance texta block of text groupa group. if the groupName is also defined, the new group is a child of the groupName group. if groupName is an empty string, the group is toplevel. actionan action defined by a callback procedure when you click the button labeled by actionName.
type
Arguments
Provides extra information required for display items. The following examples illustrate how you use the additionalInfo argument for the various types:
add_display_item groupName id icon path-to-image-file add_display_item groupName parameterName parameter (additionalInfo not required) add_display_item groupName id text "your-text" The your-text argument is a block of text that is displayed in the GUI. Some simple HTML formatting is allowed, such as <b> and <i>, if the text starts with "html>". add_display_item parentGroupName childGroupName group [tab] The tab is an optional parameter. If present, the group appears in separate tab in the GUI for the instance. add_display_item parentGroupName actionName action buttonClickCallbackProc
additionalInfo
Examples
731
GET_DISPLAY_ITEMS
This command returns a list of all items to be displayed as part of the parameterization GUI.
get_display_items Callback availability Usage Returns Arguments Example Main, elaboration, generation, and editor get_display_items List of strings None get_display_items
GET_DISPLAY_ITEM_properties
This command returns a list of names of the properties of display items that are part of the parameterization GUI.
get_display_item_properties Callback availability Usage Returns Arguments Example Main get_display_item_properties List of strings None get_display_item_properties
GET_DISPLAY_ITEm_property
This command returns the value of specific property of a display item that is part of the parameterization GUI.
get_display_item_property Callback availability Usage Returns Arguments Example Main get_display_item_property <itemName> <propertyName> String itemName propertyName The item whose property value is being retrieved The property whose value is being retrieved
December 2010
Altera Corporation
732
sET_DISPLAY_ITEm_property
This command sets the value of specific property of a display item that is part of the parameterization GUI.
set_display_item_property Callback availability Usage Returns Arguments Main set_display_item_property <itemName> <propertyName> <value> String itemName propertyName value Example The item whose property value is being set The property whose value is being set The value to set
set_display_item_property my_action DISPLAY_NAME Click Me set_display_item_property my_action DESCRIPTION clicking this button runs the click_me_callback proc in the hw.tcl file
add_interface
This command adds an interface to your module. As the component author, you choose the name of the interface. By default, interfaces are enabled. You can set the interface property ENABLED to false, to disable a component interface. If an interface is disabled, it is hidden and its ports are automatically terminated to their default values. Signals that you designate as active low by appending a _n are terminated to 1. All other signals are terminated to 0.
733
f The properties available for each interface type are different. The common properties, ENABLED and ASSOCIATED_CLOCK apply to all interface types. Refer to the Avalon Interface Specifications for a description of other properties.
add_interface Callback availability Usage Returns Main program, and elaboration add_interface <interfaceName> <interfaceType> <direction> [<associatedClock>] (1) String interfaceName A name that you choose to identify an interface. There are 7 interfaceTypes. The following directions are possible for these interfaceTypes: Interface TypeDirection avalonmaster, slave (2) Arguments interfaceType and direction avalon_tristateslave avalon_streamingsource, sink interruptsender, receiver conduitend clocksource, sink nios_custom_instructionslave associatedClock Example
Notes:
(1) For interfaces that are not associated with clocks, such as clock interfaces themselves, the associatedClock is omitted. Another option is to specify the associatedClock argument as asynchronous. (2) The terms master, source, and start are interchangeable. The terms slave, sink, and end are interchangeable.
This defines the clock associated with the interface. It is required for all interfaces except clock interfaces.
get_interfaces
This command returns the names of all interfaces that have been previously defined by add_interface as a space separated list.
get_interfaces Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_interfaces List of strings None set all_interfaces [get_interfaces]
December 2010
Altera Corporation
734
get_interface_properties
This command returns the names of all the available interface properties for the specified interface as a space separated list.
get_interface_properties
Main program, validation, elaborations, and editor get_interface_properties <interfaceName> List of strings interfaceName The name of an interface that you defined get_interface_properties mm_slave
f The properties available for each interface type are different. Refer to the Avalon Interface Specifications for more information about interface properties. The interface properties that are common to all interface types are listed below in Table 76.
Table 76. Interface Properties Common to All Interface Types Property ASSOCIATED_CLOCK ENABLED Type String Boolean Description The name of the clock interface that this interface is synchronous to. Specifies whether or not interface is enabled.
get_interface_property
This command returns the value of a single interface property from the specified interface.
get_interface_property Callback availability Usage Returns Main program, and elaboration get_interface_property <interfaceName> <propertyName> string, boolean, or units depending on property Refer to the Avalon Interface Specifications for more information about interface properties interfaceName Arguments propertyName The name of an interface from which you want to retrieve information The name of the property whose value you want to retrieve. This property is either ENABLED or ASSOCIATED_CLOCK or a property name defined by the interface.
Example
735
set_interface_property
This command sets a single interface property for an interface.
set_interface_property Callback availability Usage Returns Main and elaboration set_interface_property <interfaceName> <propertyName> <value> String interfaceName Arguments propertyName value Example The name of an interface that includes this property The name of the property whose value you want to set, which is ENABLED or ASSOCIATED_CLK or a name from the Avalon Interface Specifications. The value to set for the specified property
add_interface_port
This command adds a port to an interface on your module. As the component author, you determine the name of the port. The port width and direction must be set by the end of the elaboration phase. The port width can be set with one of the following mechanisms:
A constant width or a width expression can be set in the main program A constant width can be set in the elaboration callback
Without an elaboration callback, for static components quartus_map determines the port width from the HDL
add_interface_port Callback availability Usage Returns Main program and elaboration add_interface_port <interfaceName> <portName> <portRole> [<direction> <width_expr>] String interfaceName portName portRole direction width_expr Example The name of the interface to which the port belongs. The name of the port that you, the component author, have chosen. The role of this port within the interfaces. Port roles are referred to as signal types in the Avalon Interface Specification. Refer to the Avalon Interface Specifications for the signal types available for each interface type. The direction can be input, output, or bidir The port's width expression. In simple cases, this is just the width of the port in bits.
Arguments
December 2010
Altera Corporation
736
get_interface_ports
This command returns the names of all of the ports that have been added to a given interface. If the interface name is omitted, all ports for all interfaces are returned.
get_interface_ports Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_interface_ports [<interfaceName>] String interfaceName The name of the interface whose ports you want to list. (Optional) get_interface_ports mm_slave
get_port_properties
This command returns a list of all available port properties.
get_port_properties Callback availability Usage Returns Main, validation, elaboration, generation, and editor get_port_properties <portName> String, boolean, or units depending on property refer to Table 74 on page 723 The name of the port whose properties are required. The following 7 port properties are supported:
Arguments
portName
termination
boolean
termination_value
integer
737
Table 77. Port Properties (Part 2 of 2) Name vhdl_type width Type std_logic std_logic_vector auto integer Description indicates the type of a VHDL port. The default value, auto, selects std_logic if the width is fixed at 1, and std_logic_vector otherwise. The width of the port in bits. The width expression of a port. Setting the width and width_expr properties have the same effect; they both update the effective width expression. The width/width_expr properties can be set to an integer at any time. They can only be set to arithmetic expressions in the main program. The values of the width and width_expr properties behave differently when get_port_property is used. width always returns the current integer width of the port. width_expr always returns the unevaluated width expression.
width_expr
string
get_port_property
This command returns the value of single port property for the specified port.
get_port_property Callback availability Usage Returns Arguments Example Main, validation, elaboration, generation, and editor get_port_property <portName> <propertyName> Depends on the type of the property portName propertyName The name of the port One of the supported properties described in Table 77.
set_port_property
This command sets a single port property.
set_port_property Callback availability Usage Returns Arguments Example Main program, elaboration, and generation set_port_property <portName> <propertyName> [<value>] String, boolean, or units depending on property refer to Table 74 on page 723 portName propertyName value The name of the port One of the supported properties described in Table 77. The value to set
December 2010
Altera Corporation
738
get_interface_assignments
This command returns the value of all interface assignments for the specified interface.
get_interface_assignments Callback availability Usage Returns Arguments Example Main, validation, and elaboration get_interface_assignments <interfaceName> String interfaceName The name of the Avalon interface whose assignment is being retrieved get_interface_assignments s1
get_interface_assignment
This command returns the value of the specified name for the specified interface.
get_interface_assignment Callback availability Usage Returns Arguments Example Main, validation, and elaboration get_interface_assignments <interfaceName> <name> String interfaceName name The name of the Avalon interface whose assignment is being retrieved The assignment whose value is being retrieved
get_interface_assignment s1 embeddedsw.configuration.isFlash
set_interface_assignment
This command sets the value of the specified assignment for the specified interface.
set_interface_assignment Callback availability Usage Returns Arguments Example Main, validation, and elaboration set_interface_assignment <interfaceName> <name> [<value>] None interfaceName name value The name of the Avalon interface whose assignment is being set The assignment whose value is being set The value to assign
set_interface_assignment s1 embeddedsw.configuration.isFlash 1
Generation
This section covers the commands that get generation properties.
739
get_generation_properties
This command returns the names of all the available generation properties as a space separated list. These properties cannot be changed by the module. Generation properties are provided to the generation callback to support per-instance HDL generation.
get_generation_properties Callback availability Usage Main, validation, elaboration, generation, and editor get_generation_properties String. The following generation properties are supported:
Returns
Refer to Table 78 for a description of the generation properties. Arguments Example None get_generation_properties
output_directory
file
output_name
string
get_generation_property
This command returns the value of a single generation property.
get_generation_property Callback availability Usage Returns Generation get_generation_property <propertyName> String, boolean, or units depending on property refer to Table 74 on page 723 One of the 3 generation properties: Arguments propertyName
Example
get_generation_property OUTPUT_DIRECTORY
December 2010
Altera Corporation
740
This chapter identifies the files you must include when archiving an SOPC Builder project. With this information, you can archive the SOPC Builder system. You may want to archive your SOPC Builder system for one of the following reasons:
To place an SOPC Builder design under source control To create a backup To bundle a design for transfer to another location
To use this information, you must decide what source control or archiving tool to use, and you must know how to use it. This chapter describes how to find and identify the files that you must include in an archived SOPC Builder design. Refer to Required Files on page 82.
Limitations
This chapter provides information about archiving SOPC Builder systems, including Nios II software applications, if any. If your SOPC Builder system does not contain a Nios II processor, you can disregard information about archiving Nios II software applications. This chapter does not cover archiving SOPC Builder components, for two reasons:
SOPC Builder components can be recovered, if necessary, from the original Quartus II and Nios II installations. If your SOPC Builder system was developed with an earlier version of the Quartus II software and Nios II Embedded Design Suite (EDS), when you restore it for use with the current version, you normally use the current, installed components.
If your SOPC Builder system was developed with an earlier version of the Quartus II Complete Design Suite and you restore it for use with the current version, the regenerated system is functionally identical to the original system. However, there might be differences in details such as timing performance, component implementation, or HAL implementation. f For details of version changes, refer to the Quartus II Reference Documentation. To ensure that you can regenerate your exact original design, maintain a record of the tool and IP version(s) originally used to develop the design. Retain the original installation files or media in a safe place. The archival process addressed by this chapter is different than Quartus II project archiving. A Quartus II project archive contains the complete Quartus II project, including the SOPC Builder module. The Quartus II software adds all HDL files to the archive, including HDL files generated by SOPC Builder, although these files are not strictly necessary, if you regenerate the design files afterwards. A Quartus II project archive also archives the Quartus II IP (.qip) file.
December 2010
Altera Corporation
82
This chapter is only concerned with archiving the SOPC Builder system, without the generated HDL files. f For more details about archiving Quartus II projects, refer to the Managing Quartus II Projects chapter in volume 2 of the Quartus II Handbook.
Required Files
This section describes the files required to archive an SOPC Builder system and its associated Nios II software projects (if any). This is the minimum set of files needed to completely recompile an archived system, both the SRAM Object File (.sof) and the executable software (.elf). 1 If you have Nios II software projects, archive them together with the SOPC Builder system on which they are based. For more details about archiving Nios II designs, refer to the Using the Nios II Software Build Tools chapter of the Nios II Software Developers Handbook. The files listed in Table 81 are located in the Quartus II project directory.
Table 81. Files Required for an SOPC Builder System File Description SOPC Builder design file (.sopc) File Name <sopc_builder_system>.sopc Write Permission Required? (1) Yes Yes Yes No No Yes
SOPC Builder classic system description for <sopc_builder_system>.ptf generation, a peripheral template file (.ptf) (1) SOPC Builder report file, an SOPC information file (.sopcinfo) All non-generated HDL source files (2) Quartus II project file (.qpf) Quartus II settings file (.qsf)
Notes to Table 81:
(1) The <sopc_builder_system>.ptf file is only required if you intend to edit or view the system in a version of SOPC Builder prior to version 7.1 and must also be writable to generate a system. (2) Include all HDL source files not generated by SOPC Builder, including HDL source files you create or copy from elsewhere. To identify a file generated by SOPC Builder, open the file and look for the following header: Legal Notice: (C)<year> Altera Corporation. All rights reserved.
Many source control tools mark local files read-only by default. In this case, you must override this behavior. You do not have to check the files out of source control unless you are modifying the SOPC Builder design or Nios II software project.
Most systems generated with SOPC Builder require memory. For example, embedded processor systems require memory for software, while digital signal processing (DSP) systems require memory for data buffers. Many systems use multiple types of memories. For example, a processor-based DSP system can use off-chip SDRAM to store software, and on-chip RAM for fast access to data buffers. You can use SOPC Builder to integrate almost any type of memory into your system. This chapter uses design examples to describe how to build a memory subsystem as part of a larger system created with SOPC Builder. This chapter focuses on the following kinds of memory most commonly used in SOPC Builder systems:
On-Chip RAM and ROM on page 96 EPCS Serial Configuration Device on page 99 SDR SDRAM on page 911 DDR SDRAM on page 914 DDR2 SDRAM on page 914 Off-Chip SRAM and Flash Memory on page 915
This chapter assumes that you are familiar with the following task and concepts:
Creating FPGA designs and making pin assignments with the Quartus II software. For details, refer to the Introduction to the Quartus II Software manual. Building simple systems with SOPC Builder. For details, refer to Chapter 1, Introduction to SOPC Builder. SOPC Builder components. For details, refer to Chapter 4, SOPC Builder Components. Basic concepts of the Avalon interfaces. You do not need extensive knowledge of the Avalon interfaces, such as transfer types or signal timing. However, to create your own custom memory subsystem with external memories, you need to understand the Avalon Memory-Mapped (Avalon-MM) interface. For details, refer to Chapter 2, System Interconnect Fabric for Memory-Mapped Interfaces and the Avalon Interface Specifications.
f Refer to the Memory System Design chapter in the Embedded Design Handbook for additional information on the efficient use of memories in SOPC Builder systems.
Example Design
This chapter demonstrates the process for building a system that contains one of each type of memory as shown in Figure 91. Each section of the chapter builds on previous sections, culminating in a complete system.
December 2010
Altera Corporation
92
By following the example design in this chapter, you learn how to create a complete customized memory subsystem for your system or design. The memory components in the example design are independent. For a custom system, you only need to instantiate the memories you need. You can also create multiple instantiations of the same type of memory, limited only by on-chip memory resources or FPGA pins to interface with off-chip memory devices.
Altera FPGA
JTAG Controller
JTAG UART S
S SDRAM Controller
SDRAM Interface S 8M x 8 bit CFI Flash Memory Chip S 256K x 32 bit SRAM Memory Chip 4M x 32 bit SDRAM Memory Chip
EPCS Interface
M S
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Hardware and Software Requirements
93
In Figure 91, all blocks shown below the system interconnect fabric comprise the memory subsystem. For demonstration purposes, this system uses a Nios II processor core to master the memory devices, and a JTAG UART core to communicate with the host PC. However, the memory subsystem could be connected to any master component, located either on-chip or off-chip.
A Quartus II project named quartus2_project. A Block Design File (.bdf) named toplevel_design. toplevel_design is the top-level design file for quartus2_project. toplevel_design instantiates the SOPC Builder system, as well as other pins and modules required to complete the design. An SOPC Builder system named sopc_memory_system. sopc_memory_system is a subdesign of toplevel_design. sopc_memory_system instantiates the memory components and other SOPC Builder components required for a functioning SOPC Builder system.
This discussion assumes that the quartus2_project already exists, sopc_memory_system has been started in SOPC Builder, and the Nios II core and the JTAG UART core are already instantiated. This example design uses the default settings for the Nios II core and the JTAG UART core; these settings do not affect the rest of the memory subsystem.
Quartus II software version 5.0 or higherBoth Quartus II Web Edition and the fully licensed version support this design flow. Nios II Embedded Design Suite (EDS) version 5.0 or higherBoth the evaluation edition and the fully licensed version support this design flow. The Nios II EDS provides the SOPC Builder memory components described in this chapter. It also provides several complete example designs which demonstrate a variety of memory components instantiated in working systems.
The Quartus II Web Edition software and the Nios II EDS, Evaluation Edition are available free for download from the Altera website. Visit www.altera.com/download. Also, for further reference, see the Design Examples. This chapter does not describe downloading and verifying a working system in hardware. Therefore, there are no hardware requirements for the completion of this chapter. However, the example memory subsystem has been tested in hardware.
December 2010
Altera Corporation
94
Design Flow
This section describes the design flow for building memory subsystems with SOPC Builder, which is similar to other SOPC Builder designs. After starting a Quartus II project and an SOPC Builder system, there are five steps to completing the system, as shown in Figure 92: 1. Component-level design in SOPC Builder 2. SOPC Builder system-level design 3. Simulation 4. Quartus II project-level design 5. Board-level design
Figure 92. Design Flow
Component-Level Design
Board-Level Design
95
Connect the memory component to masters in the system. Each memory component must be connected to at least one master. Assign a base address. Assign a clock domain. A memory component can operate on the same or different clock domain as the master(s) that access it.
Simulation
In this step, you verify the functionality of the SOPC Builder system. For systems with memories, this step depends on simulation models for each of the memory components, in addition to the system testbench generated by SOPC Builder. Refer to Simulation Considerations for more information.
Board-Level Design
In this step, you connect the physical FPGA pins to memory devices on the board. If the SOPC Builder system interfaces with off-chip memory devices, you must make board-level design choices.
Simulation Considerations
SOPC Builder can automatically generate a testbench for RTL simulation of the system using ModelSim. This testbench instantiates the SOPC Builder system and can also instantiate memory models for external memory components. The testbench is plain text HDL, located at the bottom of the top-level SOPC Builder system HDL design file. To explore the contents of the auto-generated testbench, open the top-level HDL file and search on keyword test_bench. 1 Beginning in ModelSim SE 6.2, design optimization is on by default. Optimization may eliminate design nodes which are referenced in your wave display file. In this case, the you cannot display the waveforms. You can ignore this failure if you want to run an optimized simulation. However, if you want to see the simulation signals, you can disable the optimized compile by setting VoptFlow = 0 in your modelsim.ini file. The modelsim.ini is stored in the top-level directory of the ModelSim installation.
December 2010
Altera Corporation
96
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough On-Chip RAM and ROM
The generic memory models store memory initialization files, such as Data (.dat) and Hexadecimal (.hex) files, in a directory named <Quartus II project directory>/<SOPC Builder system name>_sim. When generating a new system, SOPC Builder creates empty initialization files. You can manually edit these files to provide custom memory initialization contents for simulation.
On-chip memory has fast access time, compared to off-chip memory. SOPC Builder automatically instantiates on-chip memory inside the SOPC Builder system, so you do not have to make any manual connections. Certain memory blocks can have initialized contents when the FPGA powers up. This feature is useful, for example, for storing data constants or processor boot code. On-chip memories support dual port accesses, allowing two master to access the same memory concurrently.
Memory Type
The Memory type options define the structure of the on-chip memory:
RAM (writable)This setting creates a readable and writable memory. ROM (read only)This setting creates a read-only memory. Dual-port accessThis setting creates a memory component with two slaves, which allows two masters to access the memory simultaneously. c If two masters access the same address simultaneously in a dual-port memory undefined results will occur. (Concurrent accesses are only a problem for two writes. A read and write to the same location will read out the old data and store the new data.)
Block typeThis setting directs the Quartus II software to use a specific type of memory block when fitting the on-chip memory in the FPGA.
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough On-Chip RAM and ROM
97
The MRAM blocks do not allow the contents to be initialized during power up. The M512s memory type does not support dual-port mode where both ports support both reads and writes.
Because of the constraints on some memory types, it is frequently best to use the Auto setting. Auto allows the Quartus II software to choose a type and the other settings direct the Quartus II software to select a particular type.
Size
The Size options define the size and width of the memory.
Data widthThis setting determines the data width of the memory. The available choices are 8, 16, 32, 64, 128, 256, 512, or 1024 bits. Assign Data width to match the width of the master that accesses this memory the most frequently or has the most critical throughput requirements. For example, if you are connecting the on-chip memory to the data master of a Nios II processor, you should set the data width of the on-chip memory to 32 bits, the same as the data-width of the Nios II data master. Otherwise, the access latency could be longer than one cycle because the Avalon interconnect fabric performs width translation. Total memory sizeThis setting determines the total size of the on-chip memory block. The total memory size must be less than the available memory in the target FPGA. Minimize memory block usage (may impact fmax)Minimize memory block usage (may impact fmax)This option is only available for devices that include M4K memory blocks. If selected, the Quartus II software divides the memory by depth rather than width, so that fewer memory blocks are used. This change may decrease fmax.
Read Latency
On-chip memory components use synchronous, pipelined Avalon-MM slaves. Pipelined access improves fMAX performance, but also adds latency cycles when reading the memory. The Read latency option allows you to specify either one or two cycles of read latency required to access data. If the Dual-port access setting is turned on, you can specify a different read latency for each slave. When you have dual-port memory in your system you can specify different clock frequencies for the ports. You specify this on the System Contents tab in SOPC Builder.
December 2010
Altera Corporation
98
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough On-Chip RAM and ROM
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough EPCS Serial Configuration Device
99
Because the on-chip memory is contained entirely within the SOPC Builder system, sopc_memory_system has no I/O signals associated with onchip_ram. Therefore, you do not need to make any Quartus II project connections or assignments for the on-chip RAM, and there are no board-level considerations.
The FPGA design can reprogram its own configuration memory, providing a mechanism for remote upgrades. The FPGA design can use leftover space in the EPCS as nonvolatile storage.
Physically, the EPCS device is a serial flash memory device, which has slow access time. Altera provides software drivers to control the EPCS core for the Nios II processor only. f For further details about the features and usage of the EPCS device controller core, refer to the EPCS Device Controller Core chapter in the Embedded Peripherals IP User Guide.
Assign a base address. Set the IRQ connection to NC (no connect). The EPCS controller hardware is capable of generating an IRQ. However, the Nios II driver software does not use this IRQ, and therefore you can leave the IRQ signal disconnected.
There can only be one EPCS controller core per FPGA, and the instance of the core is always named epcs_controller. If you want to store Nios II code in the EPCS memory, point the Nios II reset address at the EPCS controller. Inside the EPCS controller is a bootloader, which Nios II runs after it leaves reset, that copies the code from the EPCS flash into main memory.
Functional simulation does not include the FPGA configuration process, and therefore the EPCS controller does not model the configuration features.
December 2010
Altera Corporation
910
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough EPCS Serial Configuration Device
The simulation model does not support read and write operations to the flash region of the EPCS device. A Nios II processor can boot from the EPCS device in simulation. However, the boot loader code is different during simulation. The EPCS controller boot loader code assumes that all other memory simulation models are initialized, and therefore the boot load process is unnecessary. During simulation, the boot loader simply forces the Nios II processor to jump to start, skipping the boot load process.
Verification in the hardware is the best way to test features related to the EPCS device.
Because the Quartus II software automatically connects the EPCS controller core to the FPGA pins, the SOPC Builder system has no I/O signals associated with epcs_controller. Therefore, you do not need to make any connections or assignments between the Quartus II project and the EPCS controller core. f This chapter does not cover the details of configuration using the EPCS device. For further information, refer to the Altera Configuration Handbook.
911
SDR SDRAM
Altera provides a free SDR SDRAM controller core, which allows you to use inexpensive SDRAM as bulk RAM in your FPGA designs. The SDR SDRAM controller core is necessary, because Avalon-MM signals cannot describe the complex interface on an SDRAM device. The SDR SDRAM controller acts as a bridge between the system interconnect fabric and the pins on an SDRAM device. The SDR SDRAM controller can operate in excess of 100 MHz. SDR SDRAM is a single data rate SDR SDRAM. Synchronous design allows precise cycle control. With the use of system clock, I/O transactions are possible on every clock cycle. Operating over a range of frequencies, programmable latencies allow the same device to be useful for a variety of high bandwidth, high performance memory system applications. f For further details about the features and usage of the SDR SDRAM controller core, refer to the SDR-SDRAM Controller Core with Avalon Interface chapter in the Embedded Peripherals IP User Guide.
December 2010
Altera Corporation
912
913
For demonstration purposes, Figure 95 shows the result of generating the SOPC Builder system at this stage, and connecting it in toplevel_design.bdf.
Figure 95. toplevel_design.bdf with SDRAM
After generating the system, the top-level SOPC Builder system file sopc_memory_system.v contains the list of SDRAM-related I/O signals that must be connected to FPGA pins. Example 91 shows these pins.
Example 91. I/O Signals Connected to FPGA Pins
output output output output output inout output output output [ 11: 0] zs_addr_from_the_sdram; [ 1: 0] zs_ba_from_the_sdram; zs_cas_n_from_the_sdram; zs_cke_from_the_sdram; zs_cs_n_from_the_sdram; [ 31: 0] zs_dq_to_and_from_the_sdram; [ 3: 0] zs_dqm_from_the_sdram; zs_ras_n_from_the_sdram; zs_we_n_from_the_sdram;
As shown in Figure 95, toplevel_design.bdf uses an instance of sdram_pll to phase shift the SDRAM clock by 63 degrees. (Degrees are relative to clock frequency. If you change the clock speed you must change the phase shift. You should parameterize the PLL with -3.5 ns, because the compensation is for the round-trip delays and clock to I/O delays.) toplevel_design.bdf also uses a subdesign delay_reset_block to insert a delay on the reset_n signal for the SOPC Builder system. This delay is necessary to allow the PLL output to stabilize before the SOPC Builder system begins operating.
December 2010
Altera Corporation
914
Figure 96 shows pin assignments in the Quartus II Assignment Editor for some of the SDRAM pins. The correct pin assignments depend on the target board.
Figure 96. Pin Assignments for SDRAM
DDR SDRAM
You can use double-data rate (DDR) SDRAM devices for a broad range of applications, such as embedded processor systems, image processing, storage, communications, and networking. In addition, the universal adoption of DDR SDRAM in PCs makes DDR SDRAM memory a solution for high-bandwidth applications. DDR SDRAM is a <2n> prefetch architecture where the internal data bus is twice the width of the external data bus and data transfers occur on both clock edges. It uses a strobe, DQS, which is associated with a group of data pins (DQ) for read and write operations. Both the DQS and DQ ports are bidirectional. Address ports are shared for write and read operations.
DDR2 SDRAM
Double-data rate DDR2 SDRAM is the second generation of double-data rate DDR SDRAM technology, with features such as lower power consumption, higher data bandwidth, enhanced signal quality, and on-die termination. DDR2 SDRAM brings higher memory performance to a broad range of applications, such as PCs, embedded processor systems, image processing, storage, communications, and networking. It is a <4n> pre-fetch architecture with two data transfers per clock cycle. The memory uses a strobe (DQS) associated with a group of data pins (DQ) for read and write operations. Both the DQ and DQS ports are bidirectional. Address ports are shared for write and read operations. f For more information refer to Literature: External Memory Interfaces page of the Altera website.
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
915
Off-chip memory cost-per-bit is less expensive than on-chip memory resources. The size of off-chip memory is bounded only by the 32-bit Avalon-MM address space. Off-chip ROM, such as flash memory, can be used for bulk storage of nonvolatile data. Multiple off-chip RAM and ROM memories can share address and data pins to conserve FPGA I/O resources at the expense of throughput.
Adding off-chip memories to an SOPC Builder system also requires the Avalon-MM Tristate Bridge component.
For common flash interface (CFI) flash memory devices, add the Flash Memory (Common Flash Interface) component in SOPC Builder. For Altera development boards, Altera provides SOPC Builder components that interface to the specific devices on each development board. For example, the Nios II EDS includes the components Cypress CY7C1380C SSRAM and IDT71V416 SRAM, which appear on Nios II development boards.
f For further details about the features and usage of the SSRAM controller core, refer to the Nios Development Board Cyclone II Edition Reference Manual or Nios Development Board Stratix II Edition. f For further details about the features and usage of the SDRAM controller core, refer to Chapter 9, SOPC Builder Memory Subsystem Development Walkthrough. These components make it easy for you to create memory systems targeting Altera development boards. However, these components target only the specific memory device on the board; they do not work for different devices.
For general memory devices, RAM or ROM, you can create a custom interface to the device with the SOPC Builder component editor. Using the component editor, you define the I/O pins on the memory device and the timing requirements of the pins.
In all cases, you must also instantiate the Avalon-MM Tristate Bridge component. Multiple off-chip memories can connect to a single tristate bridge, in order to share pins such as the off-chip address bus.
December 2010
Altera Corporation
916
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
The off-chip device has bidirectional data pins. Multiple off-chip devices share the address, data, or both address and data buses.
In SOPC Builder, you instantiate a tristate bridge by instantiating the Avalon-MM Tristate Bridge component. The Avalon-MM Tristate Bridge configuration wizard has a single option: To register incoming (to the FPGA) signals or not.
RegisteredThis setting adds registers to all FPGA input pins associated with the tristate bridge (outputs from the memory device). Not RegisteredThis setting does not add registers between the memory device output pins and the system interconnect fabric.
The Avalon-MM tristate bridge automatically adds registers to output signals from the tristate bridge to off-chip devices. Registering the input and output signals shortens the register-to-register delay from the memory device to the FPGA, resulting in higher system fMAX performance. However, the registers add one additional cycle of latency for Avalon-MM masters accessing memory connected to the tristate bridge in each direction. The registers do not affect the timing (setup, hold, and wait) of the transfers from the perspective of the memory device. f For details about the Avalon-MM tristate interface, refer to the Avalon Interface Specifications.
Flash Memory
In SOPC Builder, you instantiate an interface to CFI flash memory by adding a Flash Memory (Common Flash Interface) component. If the flash memory is not CFI compliant, you must create a custom interface to the device with the SOPC Builder component editor. The choice of flash devices and the configuration of the devices on the board help determine the component-level design for the flash memory configuration wizard. Typically, the component-level design task involves parameterizing the flash memory interface to match the devices on the board. Using the Flash Memory (Common Flash Interface) configuration wizard, you must specify the structure (address width and data width) and the timing specifications of the flash memory devices. f For details about features and usage, refer to the Common Flash Interface Controller Core chapter in the Embedded Peripherals IP User Guide.
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
917
For an example of instantiating the Flash Memory (Common Flash Interface) component in an SOPC Builder system, see Example Design with SRAM and Flash Memory on page 920.
SRAM
To instantiate an interface to off-chip SRAM: 1. Create a new component with the SOPC Builder component editor that defines the interface. 2. Instantiate the new interface component in the SOPC Builder system. The choice of RAM devices and the configuration of the devices on the board determine how you create the interface component. The component-level design task involves entering parameters into the component editor to match the devices on the board. f For details about using the component editor, refer to Chapter 6, Component Editor.
Avalon-MM slaveThis port faces the on-chip logic in the SOPC Builder system. You connect this slave to on-chip masters in the system. Avalon-MM tristate masterThis port faces the off-chip memory devices. You connect this master to the Avalon-MM tristate slaves on the interface components for off-chip memories.
You assign a clock to the Avalon-MM tristate bridge that determines the Avalon-MM clock cycle time for off-chip devices connected to the tristate bridge. You must assign base addresses to each off-chip memory. The Avalon-MM tristate bridge does not have an address; it passes unmodified addresses from on-chip masters to off-chip slaves.
Flash Memory (Common Flash Interface) componentThis component provides a generic simulation model. You can provide memory initialization contents for simulation in the file <Quartus II project directory>/<SOPC Builder system name>_sim/<Flash memory component name>.dat. Custom memory interface created with the component editorIn this case, you must manually connect the vendor simulation model to the system testbench. SOPC Builder does not automatically connect simulation models for custom memory components to the SOPC Builder system.
December 2010
Altera Corporation
918
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
Altera-provided interfaces to memory devicesAltera provides simulation models for these interface components. You can provide memory initialization contents for simulation in the file <Quartus II project directory>/<SOPC Builder system name>_sim/<Memory component name>.dat. Alternately, you can provide a specific vendor simulation model for the memory. In this case, you must manually wire up the vendor memory model in the system testbench.
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
919
c You must ensure that the address bits are properly assigned when mixed width components are connecting to the tristate bridge. Failing to ensure that the components are properly aligned may result in a board respin.
December 2010
Altera Corporation
920
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
PCB FPGA
Nios II Processor A[31:0] D[31:0] addr[19:0] data [7:0] CEn Parallel Flash (8-bit word) A[19:0] D[7:0] CEn
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
921
December 2010
Altera Corporation
922
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
After generating the system, the top-level SOPC Builder system file sopc_memory_system.v contains the list of I/O signals for SRAM and flash memory that must be connected to FPGA pins, as shown in Example 93.
Example 93. I/O Signals for SRAM and Flash Memory
output output output output output output output output bidirectional output address_to_the_ext_flash[ 23..0]; address to_the_ext_ram[ 19..0]; be_n_to_the_ext_ram[ 3..0]; read_n_to_the_ext_flash; read_n_to_the_ext_ram; read_n_to_the_ext_ram; select_n_to_the_ext_flash; select_n_to_the_ext_ram; tristate_bridge_data [ 31..0] write_n_to_the_ext_flash; output write_n_to_the_ext_ram;
The Avalon-MM tristate bridge signals that can be shared are named after the instance of the tristate bridge component, such as tri_state_bridge_data[31:0].
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
923
Figure 910 shows the pin assignments in the Quartus II Assignment Editor for some of the SRAM and flash memory pins. The correct pin assignments depend on the target board.
Figure 910. Pin Assignments for SRAM and Flash Memory
December 2010
Altera Corporation
924
Chapter 9: SOPC Builder Memory Subsystem Development Walkthrough Off-Chip SRAM and Flash Memory
This chapter describes the parts of a custom SOPC Builder component and guides you through the process of creating an example custom component, integrating it into a system, and testing it in hardware. This chapter is divided into the following sections:
Component Development Flow on page 102. Design Example: Checksum Hardware Accelerator on page 104. This design example shows you how to develop a component with both Avalon Memory-Mapped (Avalon-MM) master and slaves. Sharing Components on page 107. This section shows you how to use components in other systems, or share them with other designers. System Information Files (.sopcinfo) on page 107.
HDL filesdefine the components functionality as hardware. Hardware Component Description File (_hw.tcl) describes the SOPC Builder related characteristics, such as interface behaviors. This file is created by the component editor. C-language filesdefine the component register map and driver software to allow programs to control the component. Software Component Description File (_sw.tcl) fileused by the software build tools to use and compile the component driver code.
The component editor guides you through the creation of your component. You can then instantiate the component in an SOPC Builder system and make connections in the same manner as other SOPC Builder components. You can also share your component with other designers. For information about creating the _sw.tcl file, see the Developing Device Drivers for the Hardware Abstraction Layer chapter in the Nios II Software Developers Handbook.
Prerequisites
This chapter assumes that you are familiar with the following:
Building systems with SOPC Builder. For details, refer to Chapter 1, Introduction to SOPC Builder. SOPC Builder components. For details, refer to Chapter 4, SOPC Builder Components. Basic concepts of the Avalon-MM interface.
December 2010
Altera Corporation
102
Chapter 10: SOPC Builder Component Development Walkthrough Hardware and Software Requirements
Design files for the example designA hyperlink to the design files appears next to this user guide, on the SOPC Builder literature page. Nios development board and an Altera USB-BlasterTM download cableYou can use either of the following Nios development boards:
If you do not have a development board, you can follow the hardware development steps. You cannot download the complete system without a working board, but you can simulate the system. f You can download the Quartus II Web Edition software and the Nios II EDS, Evaluation Edition for free from the Altera Download Center at www.altera.com.
Chapter 10: SOPC Builder Component Development Walkthrough Component Development Flow
103
3. Import the component into SOPC Builder. a. Use the component editor to create a _hw.tcl file that describes the component. b. Instantiate the component into an SOPC Builder system. When importing an HDL file using the component editor, any parameter definitions that are dependent upon other defined parameters cause an error. Example 101 illustrates the declaration of a DEPTH parameter which is legal Verilog HDL syntax in the Quartus II software, but causes an error in the component editor syntax checker.
Example 101. DEPTH Parameter
parameter WIDTH = 32; parameter DEPTH = ((WIDTH == 32) ? 8 : 16);
To avoid this error, use a localparam for the dependent parameter instead, as shown in Example 102.
Example 102. localparam Parameter
parameter WIDTH = 32; localparam DEPTH = ((WIDTH == 32)?8:16);
SOPC Builder only supports the VHDL port types std_logic and std_logic_vector.
4. Develop the software driver, which can occur in parallel with the hardware implementation. Create the components driver, including a C header file that defines the hardware-level register map for software. f For further details, see the Nios II Software Developer's Handbook. 5. Perform in-system testing, such as the following: a. Test register-level accesses to the component in hardware or simulation using a microprocessor, such as the Nios II processor. b. Performance benchmarking.
Hardware Design
As with any logic design process, the development of SOPC Builder component hardware begins after the specification phase. Creating the HDL design is often an iterative process, as you write and verify the HDL logic against the specification. The architecture of a typical component consists of the following functional blocks:
Task logicImplements the component's fundamental function. The task logic is design dependent. Interface logicProvides a standard way of providing data to or getting data from the components and of controlling the functioning of the components. f For further details, refer to the Avalon Interface Specifications.
December 2010
Altera Corporation
104
Chapter 10: SOPC Builder Component Development Walkthrough Design Example: Checksum Hardware Accelerator
Figure 101 shows the top-level blocks of a checksum component, which includes both Avalon-MM master and slaves. f The work flow for developing SOPC Builder hardware, including how to decide upon and implement the register map, is described in the Using the Nios II Software Build Tools chapter in the Nios II Software Developers Handbook. Also, guidelines for developing device drivers is described in the Developing Device Drivers for the Hardware Abstraction Layer chapter of the Nios II Software Developers Handbook.
Chapter 10: SOPC Builder Component Development Walkthrough Design Example: Checksum Hardware Accelerator
105
Hardware accelerators can operate in parallel with a host processor; consequently, adding an interrupt sender interface to the hardware accelerator increases system performance. While the accelerator is operating on a buffer, the host processor can perform other tasks such as preparing another buffer for transmission. The interrupt is asserted after the buffer checksum is calculated. The host processor can be interrupted by the hardware accelerator to notify it that a checksum result has been calculated. The host processor can then read the checksum value and clear the interrupt by writing to the status register via the accelerator slave interface.
Figure 101. Checksum Component with Avalon-MM Master and Slaves
clk reset Clock Input Interface clk reset
master_address[31..0] master_readdata[31..0] transform_readdata[31..0] master_read master_byteenable[3..0] master_waitrequest master_readdatavalid transform_byte_lanes read_address[31..0] read_length[31..0]
Checksum Transform
transform_read transform_data_available
slave_address[2..0] slave_writedata[31..0] slave_write checksum_result[15..0] checksum_invert checksum_clear Avalon-MM Slave Interface slave_readdata[31..0] slave_read slave_byteenable[3..0] control_irq
Checksum Accelerator
irq
December 2010
Altera Corporation
go_strobe
106
Chapter 10: SOPC Builder Component Development Walkthrough Design Example: Checksum Hardware Accelerator
Software Design
If you want a microprocessor to control your component, you must provide software files that define the software view of the component. At a minimum, you must define the register map for each Avalon-MM slave that is accessible to a processor. 1 In the example checksum project, you can view an example of a software driver in the directory <projectdir>/ip/checksum_accelerator, which is the top level folder of the hardware and software for the custom checksum block. Software drivers abstract hardware details of the component so that software can access the component at a high level. The driver functions provide the software an API to access the hardware. The software requirements vary according to the needs of the component. The most common types of routines initialize the hardware, read data, and write data. When developing software drivers, you should review the software files provided for other ready-made components. The IP installer provides many components you can use as reference. You can also view the <Nios II EDS install path>/components/ directory for examples. f For details about writing drivers for the Nios II hardware abstraction layer (HAL), refer to the Developing Device Drivers for the Hardware Abstraction Layer chapter of the Nios II Software Developers Handbook.
System Console
The system console is an interactive Tcl console available from within SOPC Builder that provides you with read and write access to the debugging capabilities that are available in your FPGA logic. You can use the system console to control and query the state of the Nios II processor, issue Avalon transactions, board bring-up, and access either JTAG UARTs or system level debug (SLD) nodes. f For further details, refer to the System Console User Guide.
System-Level Verification
After you package a _hw.tcl file with the component editor, you can instantiate the component in a system and verify the functionality of the overall SOPC Builder system. SOPC Builder provides support for system-level verification for HDL simulators such as ModelSim. SOPC Builder automatically produces a test bench for system-level verification.
107
You can include a Nios II processor in your system to enhance simulation capabilities during the verification phase. Even if your component has no relationship to the Nios II processor, the auto-generated ModelSim simulation environment provides an easy-to-use starting point.
Sharing Components
When you create a component, component editor saves the _hw.tcl file in the same directory as the top-level HDL file. Where appropriate, files referenced by the _hw.tcl file are specified relative to the _hw.tcl file itself, so the files can easily be moved and copied. To share a component, include it in your IP library. For more information about including components in an IP library refer to Finding Components in SOPC Builder in Chapter 4, SOPC Builder Components.
Name and version Where interface information was found on the disk, such as signal names and types, interface properties, and clock domain mapping Parameter names and values
Component and interface connections Base address, Avalon-MM interfaces, IRQ number interfaces Memory map as seen by each master in the system
The .sopcinfo file is a report file only, and cannot be edited with SOPC Builder.
December 2010
Altera Corporation
108
Chapter 10: SOPC Builder Component Development Walkthrough System Information Files (.sopcinfo)
You use bridges to control the topology of the generated SOPC Builder system. Bridges are not end-points for data, but rather affect the way data is transported between components. By inserting Avalon-MM bridges between masters and slaves, you control system topology, which in turn affects the interconnect that SOPC Builder generates. You can also use bridges to separate components in different clock domains and to implement clock domain crossing logic. Manual control of the interconnect can result in higher performance or lower logic utilization or both. Altera provides the following Avalon-MM bridges:
Avalon-MM Pipeline Bridge on page 118 Clock Crossing Bridge on page 1112 Avalon-MM DDR Memory Half-Rate Bridge on page 1120
f For additional information on using bridges to optimize and control the topology of SOPC Builder systems, refer to Avalon Memory-Mapped Design Optimizations in the Embedded Design Handbook.
December 2010
Altera Corporation
112
Structure of a Bridge
A bridge has one Avalon-MM slave and one Avalon-MM master, as shown in Figure 111. In an SOPC Builder system, one or more masters connect to the bridge slave; in turn, the Avalon-MM bridge master connects to one or more slaves. In Figure 111, all three masters have logical connections to all three slaves, although physically each master only connects to the bridge.
Figure 111. Example of an Avalon-MM Bridge in an SOPC Builder System
M1 M
M2 M
M3 M
S Avalon-MM Bridge M
S S1
S S2
S S3
M S
Transfers initiated to the bridges slave propagate to the master in the same order in which they are initiated on the slave. f For details on the Avalon-MM interface, refer to the Avalon Interface Specifications.
113
Figure 112 and Figure 113 show an SOPC system without bridges. This system includes three CPUs, a DDR SDRAM controller, a message buffer RAM, a message buffer mutex, and a tristate bridge to an external SRAM.
Figure 112. Example System Without BridgesSOPC Builder View
December 2010
Altera Corporation
114
Figure 113 illustrates the default system interconnect fabric for the system in Figure 112.
Figure 113. Example System without BridgesSystem Interconnect View
CPU1 M
System Interconnect Fabric
CPU2 M
CPU3 M
CPU1 Addr, Data, BurstReq CPU2 Addr, Data, BurstReq CPU3 Addr, Data, BurstReq
CPU1 Addr, Data, BurstReq CPU2 Addr, Data, BurstReq CPU3 Addr, Data, BurstReq
CPU1 Addr, Data, BurstReq CPU2 Addr, Data, BurstReq CPU3 Addr, Data, BurstReq
CPU_Select_Mux2
CPU_Select_Mux1
CPU_Select_Mux3
M S
Figure 114 and Figure 115 show how inserting bridges can affect the generated logic. For example, if the DDR SDRAM controller can run at 166 MHz and the CPUs accessing it can run at 120 MHz, inserting an Avalon-MM clock-crossing bridge between the CPUs and the DDR SDRAM has the following benefits:
Allows the CPU and DDR interfaces to run at different frequencies. Places system interconnect fabric for the arbitration logic and multiplexer for the DDR SDRAM controller in the slower clock domain. Reduces the complexity of the interconnect logic in the faster domain, allowing the system to achieve a higher fMAX. 1 Inserting the clock-crossing bridge does increase read latency and may not be beneficial unless your system includes more devices that access the memory.
CPU_Select_Mux4
115
In the system illustrated in Figure 114, the message buffer RAM and message buffer mutex must respond quickly to the CPUs, but each response includes only a small amount of data. Placing an Avalon-MM pipeline bridge between the CPUs and the message buffers results in the following benefits:
Eliminates separate arbiter logic for the message buffer RAM and message buffer mutex, which reduces logic utilization and propagation delay, thus increasing the fMAX. Reduces the overall size and complexity of the system interconnect fabric.
If an orange triangle appears next to an address in Figure 114, it indicates that the address is an offset value and is not the true value of the address in the address map.
December 2010
Altera Corporation
116
Figure 115 shows the system interconnect fabric that SOPC Builder creates for the system in Figure 114. Figure 115 is the same system that is pictured in Figure 113 with bridges to control system topology.
Figure 115. Example System with a Bridge
CPU1 M
CPU2 M
CPU3 M
rddata_cpu1
rddata_cpu2
rddata_cpu3
The address span of an Avalon-MM bridge is the smallest power-of-two size that encompasses all of its slaves ranges.
117
The address range of an Avalon-MM bridge is a numerical range from its base address to its base address plus its (span -1).
Equation 111.
range = [base_address .. (base_address + (span - 1)];
SOPC Builder follows several rules in constructing an address map for a system with Avalon-MM bridges: 1. The address span of each Avalon-MM slave is rounded up to the nearest power of two. 2. Each Avalon-MM slave connected to a bridge has an address relative to the base address of the bridge. This address must be a multiple of its span. (See Figure 116.)
Figure 116. Avalon-MM Master and Slave Addresses
Avalon-MM Master1 sees Slave1 at Addr = 0x1100 Avalon-MM Master1 sees Slave2 at Addr = 0x1400
Addr = 0x400
Slave2
Master1
Addr = 0x1000
Avalon-MM Bridge
M S
Slave1
December 2010
Altera Corporation
118
3. In the example shown in Figure 116, if the address span of Slave 1 is 0x100 and the address span of Slave 2 is 0x200, Figure 117 illustrates the address span of the Avalon-MM bridge.
Figure 117. The Address Span of an Avalon-MM Bridge
Master Address Space
Avalon-MM Bridge Address Translation span = 0x800 = 0x1000 .. (0x1000 + 0x7FF) = 0x1000 .. 0x17FF Slave Addr Space 0x7FF Slave2 0x1400 0x5FF Slave2 0x400 Slave1 0x1000 span = 0x200 range = 0x400 - 0x5FF
Slave1
0x000
119
Component Overview
The Avalon-MM pipeline bridge inserts registers in the path between its master and slaves. In a given SOPC Builder system, if the critical register-to-register delay occurs in the system interconnect fabric, the pipeline bridge can help reduce this delay and improve system fMAX. The bridge allows you to independently pipeline different groups of signals that can create a critical timing path in the interconnect:
Master-to-slave signals, such as address, write data, and control signals Slave-to-master signals, such as read data The waitrequest signal to the master
You can also use the Avalon-MM pipeline bridge to control topology without adding a pipeline stage. To instantiate a bridge that does not add any pipeline stages, simply do not select any of the Pipeline Options on the parameter page. For the system illustrated in Figure 115, a pipeline bridge that does not add a pipeline register stage is optimal because the CPUs benefit from minimal delay from the message buffer mutex and message buffer RAM.
c A pipeline bridge with no latency cannot be used with slaves that support pipelined reads. If a slave does not have read latency, you cannot connect it to a bridge with no pipeline stages, because the pipeline bridge slave port has a readdatavalid signal. Pipelined read components cannot have zero read latency. Some examples of 0 latency components available in SOPC Builder include the UART, Timer and SPI core. You are connecting a pipeline bridge to one of these components, increase the read latency from 0 to 1. The Avalon-MM pipeline bridge component integrates easily into any SOPC Builder system.
December 2010
Altera Corporation
1110
Functional Description
Figure 118 shows a block diagram of the Avalon-MM pipeline bridge component.
Figure 118. Avalon-MM Pipeline Bridge Block Diagram
Avalon-MM Pipeline Bridge
Master-to-Slave Pipeline
D Master-to-Slave Signals Slave I/F Connects to an Avalon-MM Slave Interface waitrequest Pipeline waitrequest Wait Request Logic D Q ENA
Master-to-Slave Signals
Master I/F
Connects to an Avalon-MM Master Interface
waitrequest
Slave-to-Master Signals
Slave-to-Master Signals
Slave-to-Master Pipeline
Interfaces
The bridge interface is composed of an Avalon-MM slave and an Avalon-MM master. The data width of the ports is configurable, which can affect how SOPC Builder generates dynamic bus sizing logic in the system interconnect fabric. Both ports support Avalon-MM pipelined transfers with variable latency. Both ports optionally support bursts of lengths that you can configure.
1111
readdata readdatavalid
When you include a register stage, it affects the timing and latency of transfers through the bridge, as follows:
The latency increases by one cycle in each direction. Write transfers on the master side of the bridge are decoupled from write transfers on the slave side of the bridge because Avalon-MM write transfers do not require an acknowledge signal from the slave. Including the waitrequest register stage increases the latency of master-to-slave signals by one additional cycle when the waitrequest signal is asserted.
Burst Support
The bridge can support bursts with configurable maximum burst length. When configured to support bursts, the bridge propagates bursts between master-slave pairs, up to the maximum burst length. Not having burst support is equivalent to a maximum burst length of one. In this case, the system interconnect fabric automatically decomposes master-to-bridge bursts into a sequence of individual transfers.
December 2010
Altera Corporation
1112
CPU1 M
CPU2 M
CPU3 M
DMA Read M
DMA Write M
M S
1113
Functional Description
Figure 1110 shows a block diagram of the Avalon-MM clock-crossing bridge component. The following sections describe the components hardware functionality.
Figure 1110. Avalon-MM Clock-Crossing Bridge Block Diagram
Avalon-MM Clock-Crossing Bridge
Master-to-Slave Signals
in
Master-to-Slave FIFO
out
Master-to-Slave Signals
waitrequest
waitrequest
slave_clk
master_clk
December 2010
Altera Corporation
1114
Interfaces
The bridge interface comprises an Avalon-MM slave and an Avalon-MM master. The data width of the ports is configurable, which affects the size of the bridge hardware and how SOPC Builder generates dynamic bus sizing logic in the system interconnect fabric. Both ports support Avalon-MM pipelined transfers with variable latency. Both ports optionally support bursts of user-configurable length. Ideally, the settings for one port match the other, such that there are no mixed data widths or bursting capabilities.
readdata readdatavalid
You can configure the depth of each FIFO. Because there are more signals traveling in the master-to-slave direction, changing the depth of the master-to-slave FIFO has a greater impact on the memory utilization of the bridge. For read transfers across the bridge, the FIFOs in both directions incur latency for data to return from the slave. To avoid paying a latency penalty for each transfer, the master can issue multiple reads that are queued in the FIFO. The slave of the bridge asserts readdatavalid when it drives valid data and asserts waitrequest when it is not ready to accept more reads. For write transfers, the master-to-slave FIFO causes a delay between the master-to-bridge transfers and the corresponding bridge-to-slave transfers. Because Avalon-MM write transfers do not require an acknowledge from the slave, multiple write transfers from master-to-bridge might complete by the time the bridge initiates the corresponding bridge-to-slave transfers.
1115
Burst Support
The bridge optionally supports bursts with configurable maximum burst length. When configured to support bursts, the bridge propagates bursts between master-slave pairs, up to the maximum burst length. Not having burst support is equivalent to a maximum burst length of one. In this case, the system interconnect fabric automatically breaks master-to-bridge bursts into a sequence of individual transfers. When you configure the bridge to support bursts, you must configure the slave-to-master FIFO depth deeply enough to capture all burst read data without overflowing. The masters connected to the bridge could potentially fill the master-to-slave FIFO with read burst requests; therefore, the minimum slave-to-master FIFO depth is described by equation given in Example 111.
Example 111. Minimum Slave-To-Master FIFO Depth
= ((master-to-slave FIFO depth) * (max burst length)) + max slave latency/pending reads
December 2010
Altera Corporation
1116
CPU M
S UART
S System ID
S LCD Display
S Flash Memory S DDR SDRAM S Avalon Tristate Bridge M M S Avalon-MM Master Port Avalon-MM Slave Port S External SRAM
1117
On/Off
When you turn on this option, the FIFO uses registers as storage instead of embedded memory blocks. This can considerably increase the size of the bridge hardware and lower the fMAX.
Slave-to-master FIFO
FIFO depth
On/Off
When you turn on this option, the FIFO uses registers as storage instead of embedded memory blocks. This can considerably increase the size of the bridge hardware and lower the fMAX.
Common options Determines the data width of the interfaces on the bridge, and affects the size of both FIFOs. For the highest bandwidth, set Data width to be as wide as the widest master connected to the bridge. The number of pipeline stages in the clock crossing logic in the issuing master to target slave direction. Increasing this value leads to a larger meantime between failures (MTBF). You can determine the MTBF for a given design can be determined by running a TimeQuest timing analysis. The number of pipeline stages in the clock crossing logic in the issuing master to target slave direction. Increasing this value leads to a larger meantime between failures (MTBF). You can determine the MTBF for a given design can be determined by running a TimeQuest timing analysis. Burst settings
Data width
28
28
Allow bursts
On/Off
Includes logic for the bridges master and slaves to support bursts. You can use this option to restrict the minimum depth for the slave-to-master FIFO.
2, 4, 8, 16, 32, 64, Determines the maximum length of bursts for the bridge to 128, 256, 512, 1024 support, when you turn on Allow bursts.
December 2010
Altera Corporation
1118
The clock-domain adapters in the system interconnect fabric provide the following benefits that simplify system design efforts:
Allow component interfaces to operate at different clock frequencies. Eliminate the need to design CDC hardware. Allow each Avalon-MM port to operate in only one clock domain, which reduces design complexity of components. Enable masters to access any slave without communication with the slave clock domain. Allow you to focus performance optimization efforts only on components that require fast clock speed.
CDC Logic
control waitrequest Receiver Handshake FSM transfer request Synchronizer control Sender Handshake FSM waitrequest
Synchronizer
acknowledge
Receiver Port
address
Sender Port
The synchronizer blocks in Figure 1112 use multiple stages of flipflops to eliminate the propagation of metastable events on the control signals that enter the handshake FSMs. The CDC logic works with any clock ratio. Altera tests the CDC logic extensively on a variety of system architectures, both in simulation and in hardware, to ensure that the logic functions correctly. The typical sequence of events for a transfer across the CDC logic is described as follows:
1119
1. Master asserts address, data, and control signals. 2. The master handshake FSM captures the control signals, and immediately forces the master to wait. 1 The FSM uses only the control signals, not address and data. For example, the master simply holds the address signal constant until the slave side has safely captured it.
3. Master handshake FSM initiates a transfer request to the slave handshake FSM. 4. The transfer request is synchronized to the slave clock domain. 5. The slave handshake FSM processes the request, performing the requested transfer with the slave. 6. When the slave transfer completes, the slave handshake FSM sends an acknowledge back to the master handshake FSM. 7. The acknowledge is synchronized back to the master clock domain. 8. The master handshake FSM completes the transaction by releasing the master from the wait condition. Transfers proceed as normal on the slave and the master side, without a special protocol to handle crossing clock domains. From the perspective of a slave, there is nothing different about a transfer initiated by a master in a different clock domain. From the perspective of a master, a transfer across clock domains simply requires extra clock cycles. Similar to other transfer delay cases (for example, arbitration delay or wait states on the slave side), the system interconnect fabric simply forces the master to wait until the transfer terminates. As a result, pipeline master ports do not benefit from pipelining when performing transfers to a different clock domain.
Four additional master clock cycles, due to the master-side clock synchronizer Four additional slave clock cycles, due to the slave-side clock synchronizer
December 2010
Altera Corporation
1120
Chapter 11: Avalon Memory-Mapped Bridges Avalon-MM DDR Memory Half-Rate Bridge
One additional clock in each direction, due to potential metastable events as the control signals cross clock domains
Systems that require a higher performance clock should use the Avalon-MM clock crossing bridge instead of the automatically inserted CDC logic. The clock crossing bridge includes a buffering mechanism, so that multiple reads and writes can be pipelined. After paying the initial penalty for the first read or write, there is no additional latency penalty for pending reads and writes, increasing throughput by up to four times, at the expense of added logic resources.
f For more information, refer to Chapter 3, System Interconnect Fabric for Streaming Interfaces and Avalon Memory-Mapped Design Optimizations in the Embedded Design Handbook.
Chapter 11: Avalon Memory-Mapped Bridges Avalon-MM DDR Memory Half-Rate Bridge
1121
access it by using lightweight logic that translates one single-word request into a two-word burst to a memory running at twice the clock frequency and half the width. For systems with a 8-bit DDR interface, using the Half-Rate DDR Bridge in conjunction with a DDR SDRAM high-performance memory controller creates a datapath that matches the throughput of the DDR memory to the CPU. This half-rate bridge provides the same functionality as the clock crossing bridge, but with significantly lower latency2 cycles instead of 12. The cores master interface is designed to be connected to a high-speed DDR SDRAM controller and thus only supports bursting. Because the slave interface is designed to receive single-word requests, it does not support bursting. Figure 1114 shows a system including an 8-bit DDR memory, a high-performance memory controller, the Half-Rate DDR Bridge, and a CPU.
Figure 1114. SOPC Builder Memory System Using a DDR Memory Half-Rate Bridge
PCB FPGA
DDRn
16
Half-Rate Bridge
32
CPU
<----------->
<----------->
The Avalon-MM DDR Memory Half-Rate Bridge core has the following features and requirements:
SOPC Builder ready with TimeQuest Timing Analyzer constraints Requires master clock and slave clock to be synchronous Handles different bus sizes between CPU and memory Requires the frequency of the master clock to be double of the slave clock Has configurable address and data port widths in the master interface
December 2010
Altera Corporation
1122
Chapter 11: Avalon Memory-Mapped Bridges Avalon-MM DDR Memory Half-Rate Bridge
Using the Half-Rate Bridge with a full-rate DDR SDRAM high-performance memory controller results an average of 48% performance improvement over a system using a half-rate DDR SDRAM high-performance memory controller in a series of embedded applications. The performance improvement is 62.2% based on the Dhrystone benchmark, and 87.7% when accessing memory bypassing the cache. For memory systems that use the Half-Rate bridge in conjunction with DDR2/3 High Performance Controller, the data throughput is the same on the Half-Rate Bridge master and slave interfaces. The decrease in memory latency on the Half-Rate Bridge slave interface results in higher performance for the processor. Table 112 shows the resource usage for Stratix II and Stratix III devices in version 9.1 of the Quartus II software with a data width of 16 bits, an address span of 24 bits.
Table 112. Resource Utilization Data for Stratix II and Stratix III Devices Device Family Stratix II Stratix III Combinational ALUTs 61 60 134 138 ALMs Logic Register 153 153 0 0 Embedded Memory
Table 113 lists the resource usage for a Cyclone III device.
Table 113. Resource Utilization Data for Cyclone III Devices Logic Cells (LC) 233 Logic Register 152 LUT-only LC 33 Register-only LC 84 LUT/Register LCs 121 0 Embedded Memory
Functional Description
The Avalon MM DDR Memory Half Rate Bridge works under two constraints:
Its memory-side master has a clock frequency that is synchronous (zero phase shift) to, and twice the frequency of, the CPU-side slave. Its memory-side master is half as wide as its CPU-side slave.
The bridge leverages these two constraints to provide lightweight, low-latency clock-crossing logic between the CPU and the memory. These constraints are in contrast with the Avalon-MM Clock-Crossing Bridge, which makes no assumptions about the frequency/phase relationship between the master- and slave-side clocks, and provides higher-latency logic that fully-synchronizes all signals that pass between the two domains. The Avalon MM DDR Memory Half-Rate Bridge has an Avalon-MM slave interface that accepts single-word (non-bursting) transactions. When the slave interface receives a transaction from a connected CPU, it issues a two-word burst transaction on its master interface (which is half as wide and twice as fast). If the transaction is a read request, the bridge's master interface waits for the slaves two-word response, concatenates the two words, and presents them as a single readdata word on its slave interface to the CPU. Every time the data width is halved, the clock rate is doubled. As a result, the data throughput is matched between the CPU and the off-chip memory device.
Chapter 11: Avalon Memory-Mapped Bridges Avalon-MM DDR Memory Half-Rate Bridge
1123
Figure 1115 shows the latency in the Avalon-MM Half-Rate Bridge core. The core adds two cycles of latency in the slave clock domain for read transactions. The first cycle is introduced during the command phase of the transaction and the second cycle, during the response phase of the transaction. The total latency is 2+<x>, where <x> refers to the latency of the DDR SDRAM high-performance memory controller. Using the clock crossing bridge for this same purpose would impose approximately 12 cycles of additional latency.
Figure 1115. Avalon-MM DDR Memory Half-Rate Bridge Block Diagram
DDR2/3 High Performance Controller (full rate) Half-Rate Bridge Cmd +1
Q D
DDR2/3 Memory
M Rsp +1
D Q
CPU
Table 115 describes the parameters that are derived based on the Data Width and Address Width settings for the Avalon-MM Half-Rate Bridge core.
Table 115. Derived Parameters for Avalon-MM DDR Memory Half-Rate Bridge Core Parameter Master interfaces Byte Enable Width Slave interfaces Data Width Slave interfaces Address Width Slave interfaces Byte Enable Width Description The width of the byte-enable signal in the master interface. The width of the data signal in the slave interface. The width of the address signal in the slave interface. The width of the byte-enable signal in the slave interface.
December 2010
Altera Corporation
1124
Chapter 11: Avalon Memory-Mapped Bridges Avalon-MM DDR Memory Half-Rate Bridge
Example System
The following example provides high-level steps showing how the Avalon-MM DDR Memory Half-Rate Bridge core is connected in a system. This example assumes that you are familiar with the SOPC Builder GUI. f For a quick introduction to this tool, read of the one-hour online course, Using SOPC Builder. 1. Add a Nios II Processor to the system. 2. Add a DDR2 SDRAM High-Performance Controller and configure it to full-rate mode. 3. Add Avalon-MM DDR Memory Half-Rate Bridge to the system. 4. Configure the parameters of the Avalon-MM DDR Memory Half-Rate Bridge based on the memory controller. For example, for a 32 MByte DDR memory controller in full rate mode with 8 DQ pins (see Figure 1114), the parameters should be set as the following:
Data Width = 16 For a memory controller that has 8 DQ pins, its local interface width is 16 bits. The local interface width and the data width must be the same, therefore data width is set to 16 bits.
Address Width = 25 For a memory capacity of 32 MBytes, the byte address is 25 bits. Because the master address of the bridge is byte aligned, the address width is set to 25 bits.
5. Connect altmemddr_auxhalf to the slave clock interface (clk_s1) of the Half-Rate Bridge. 6. Connect altmemddr_sysclk to the master clock interface (clk_m1) of the Half-Rate Bridge. 7. Remove all connections between Nios II processor and the memory controller, if there are any. 8. Connect the master interface (m1) of the Avalon-MM DDR Memory Half-Rate Bridge to the memory controller slave interface. 9. Connect the slave interface (s1) of the Avalon-MM DDR Memory Half-Rate Bridge to the Nios II processor data_master interface. 10. Connect altmemddr_auxhalf to Nios II processor clock interface.
1125
Device Support
Altera device support for the bridge components is listed in Table 116.
Table 116. Device Family Support Device Family Arria GX Arria II GX Stratix Stratix II Stratix II GX Stratix III Stratix IV Stratix V Stratix IV Cyclone II Cyclone III Cyclone IV Hardcopy HardCopy II HardCopy III HardCopy IV MAX MAX II Avalon-MM Pipeline Bridge Support Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Avalon-MM ClockCrossing Bridge Support Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full No support No support Avalon-MM Half-Rate Bridge Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full No support No support
December 2010
Altera Corporation
1126
Avalon Streaming (Avalon-ST) interconnect components facilitate the design of high-speed, low-latency datapaths for the system-on-a-programmable-chip (SOPC) environment. Interconnect components in SOPC Builder act as a part of the system interconnect fabric. They are not end points, but adapters that allow you to connect different, but compatible, streaming interfaces. You use Avalon-ST interconnect components to connect cores that send and receive high-bandwidth data, including multiplexed streams, packets, cells, time-division multiplexed (TDM) frames, and digital signal processor (DSP) data. The interconnect components that you add to an SOPC Builder system insert logic between a source and sink interface, enabling that interface to operate correctly. This chapter describes four Avalon-ST interconnect components, also called adapters:
Timing Adapter on page 122adapts between sinks and sources that have different characteristics, such as ready latencies. Data Format Adapter on page 125adapts source and sink interfaces that have different data widths. Channel Adapter on page 127adapts source and sink interfaces that have different settings for the channel signal. Error Adapter on page 129ensures that per-bit error information recorded at the source is correctly transferred to the sink
All of these interconnect components adapt initially incompatible Avalon-ST source and sink interfaces so that they function correctly, facilitating the development of high-speed, low-latency datapaths.
Adding pipeline stages to adjust the timing of the ready signal Tying signals that are not used by either the source or sink to 0 or 1
Changing the number of symbols (words) that are driven per cycle Changing the number of channels driven
December 2010
Altera Corporation
122
When the interconnect component adapts the data interface, it has one Avalon-ST sink interface and one Avalon-ST source interface, as shown in Figure 121. You configure the adapter components manually, using SOPC Builder. In contrast to the Avalon-MM interface, which allows you to create various topologies with a number of different master and slave components, you always use the Avalon-ST interconnect components to adapt point-to-point connections between streaming cores.
Figure 121. Example of an Avalon-ST Interconnect Component in an SOPC Builder System
sink
sink
sink
f For details about the system interconnect fabric, refer to Chapter 12, Avalon Streaming Interconnect Components. For details about the Avalon-ST interface protocol, refer to the Avalon Interface Specifications. Figure 122 illustrates a datapath that connects a Triple Speed Ethernet MegaCore function to a Scatter-Gather DMA controller core using a timing adapter, data format adapter, and channel adapter so that the cores can interoperate.
Address Mapping
Figure 122. Avalon-ST Datapath Constructed Using Avalon Streaming Interconnect Components
Triple Speed src Ethernet Core
sink
Timing Adapter
src
sink
sink
...
src
ch 0 .. 3
sink
Timing Adapter
src
sink
sink
The control and status signals for the components containing source or sink interfaces can be mapped to a slave interface which is then accessible in the global Avalon address space.
Timing Adapter
The timing adapter has two functions:
It adapts source and sink interfaces that support the ready signal and those that do not. It adapts source and sink interfaces that support the valid signal and those that do not. It adapts source and sink interfaces that have different ready latencies.
The timing adapter treats all signals other than the ready and valid signals as payload, and simply drives them from the source to the sink. Table 121 outlines the adaptations that the timing adapter provides.
Table 121. Timing Adapter Condition The source has ready, but the sink does not. Adaptation In this case, the source can respond to backpressure, but the sink never needs to apply it. The ready input to the source interface is connected directly to logical 1. The sink may apply backpressure, but the source is unable to respond to it. There is no logic that the adapter can insert that prevents data loss when the source asserts valid but the sink is not ready. The adapter provides simulation time error messages and an error indication if data is ever lost. The user is presented with a warning, and the connection is allowed. The source responds to ready assertion or deassertion faster than the sink requires it. A number of pipeline stages equal to the difference in ready latency are inserted in the ready path from the sink back to the source, causing the source and the sink to see the same cycles as ready cycles. The source cannot respond to ready assertion or deassertion in time to satisfy the sink. A buffer whose depth is equal to the difference in ready latency is inserted to compensate for the sources inability to respond in time.
The source does not have ready, but the sink does.
The source and sink both support backpressure, but the sinks ready latency is greater than the source's. The source and sink both support backpressure, but the sinks ready latency is less than the source's.
123
124
Table 122. Timing Adapter Estimated Resource Usage and Performance Input Ready Latency 1 1 1 1 2 3 4 Output Ready Latency 2 3 4 0 1 1 1 Stratix II and Stratix II GX (Approximate LEs) fMAX (MHz) 500 500 500 500 456 456 456 ALM Count 2 2 4 21 21 21 21 Mem Bits 0 0 0 80 80 80 80 Cyclone II fMAX (MHz) 420 420 420 420 401 401 401 Logic Cells 2 3 4 183 188 188 188 Stratix (Approximate LEs) fMAX (MHz) 422 422 422 422 317 317 317 Logic Cells 1 2 3 20 21 21 21 Mem Bits 0 0 0 80 80 80 80
Table 123. Avalon-ST Timing Adapter Parameters Input Interface Parameters Parameter Support Backpressure with the ready signal Ready Latency Description Turn on this option to add the backpressure functionality to the interface. When the ready signal is used, the value for ready_latency indicates the number of cycles between when the ready signal is asserted and when valid data is driven. Turn this option on if the interface includes the valid signal. Turning this option off means that data being received is always valid. Output Interface Parameters Support Backpressure with the ready signal Ready Latency Turn on this option to add the backpressure functionality to the interface. When the ready signal is used, the value for ready_latency indicates the number of cycles between when the ready signal is asserted and when valid data is driven. Turn this option on if the interface includes the valid signal. Turning this option off means that data driven is always valid. Common to Input and Output Interfaces Channel Signal Width (bits) Type the width of the channel signal. A channel width of 4 allows up to 16 channels. The maximum width of the channel signal is eight bits. Set to 0 if channels are not used.
125
Table 123. Avalon-ST Timing Adapter Parameters Input Interface Parameters Parameter Max Channel Data Bits Per Symbol Data Symbols Per Beat Include Packet Support Description Type the maximum number of channels that the interface supports. Valid values are 0255. Type the number of bits per symbol. Type the number of symbols per active transfer. Turn this option on if the interfaces supports a packet protocol, including the startofpacket, endofpacket and empty signals. You can use this signal to specify the number of empty symbols in the cycle that includes the endofpacket signal. This signal is not necessary if the number of symbols per beat is 1. Type the width of the error signal. Valid values are 031 bits. Type 0 if the error signal is not used. Type the description for each of the error bits. Separate the description fields by commas. For a connection to be made, the description of the error bits in the source and sink must match. Refer to Error Adapter on page 129 for the adaptations that can be made when the bits do not match.
The source and sink have a different number of symbols per beat.
December 2010
Altera Corporation
126
127
Table 126. Data Format Adapter Parameters Input Interface Parameters Parameter Description Output Interface Parameters Data Symbols Per Beat Include the empty signal Type the number of symbols transferred per active cycle. Turn this option on if the cycle that includes the endofpacket signal can include empty symbols. This signal is not necessary if the number of symbols per beat is 1. Common to Input & Output Channel Signal Width (bits) Type the width of the channel signal. A channel width of 4 allows up to 16 channels. The maximum width of the channel signal is 8 bits. Type 0 if you do not need to send channel numbers. Type the maximum number of channels that the interface supports. Valid values are 0255. Turn this option on if the interface supports a packet protocol, including the startofpacket, endofpacket, and empty signals. Type the width of the error signal. Valid values are 031 bits. Type 0 if the error signal is not used. Type the description for each of the error bits. Separate the description fields by semicolons. For a connection to be made, the description of the error bits in the source and sink must match. Refer to Error Adapter on page 129 for the adaptations that can be made when the bits do not match. Type the number of bits per symbol.
Channel Adapter
The channel adapter provides adaptations between interfaces that have different support for the channel signal or for the maximum number of channels supported. The adaptations are described in Table 127.
Table 127. Channel Adapter Condition The source uses channels, but the sink does not. The sink has channel, but the source does not. The source and sink both support channels, and the source's maximum number of channels is less than the sink's. Description of Adapter Logic You are given a warning at generation time. The adapter provides a simulation error and signals an error for data for any channel from the source other than 0. You are given a warning, and the channel inputs to the sink are all tied to a logical 0.
The source's channel is connected to the sink's channel unchanged. If the sink's channel signal has more bits, the higher bits are tied to a logical 0. The sources channel is connected to the sinks channel unchanged. If the sources channel signal has more bits, the higher bits are left unconnected. You are given a warning that channel information may be lost. An adapter provides a simulation error message and an error indication if the value of channel from the source is greater than the sink's maximum number of channels. In addition, the valid signal to the sink is deasserted so that the sink never sees data for channels that are out of range.
The source and sink both support channels, but the source's maximum number of channels is greater than the sink's.
December 2010
Altera Corporation
128
Table 128. Avalon-ST Channel Adapter Parameters Parameter Description Input Interface Parameters Channel Signal Width (bits) Max Channel Type the width of the channel signal. A channel width of 4 allows up to 16 channels. The maximum width of the channel signal is eight bits. Set to 0 if channels are not used. Type the maximum number of channels that the interface supports. Valid values are 0255. Output Interface Parameters Channel Signal Width (bits) Max Channel Type the width of the channel signal. A channel width of 4 allows up to 16 channels. The maximum width of the channel signal is eight bits. Set to 0 if channels are not used. Type the maximum number of channels that the interface supports. Valid values are 0255. Common to Input and Output Interfaces Support Backpressure with the ready signal Ready Latency Turn on this option to add the backpressure functionality to the interface. When the ready signal is used, the value for ready_latency indicates the number of cycles between when the ready signal is asserted and when valid data is driven. Type the number of bits per symbol. Type the number of symbols per active transfer. Turn this option on if the interfaces supports a packet protocol, including the startofpacket, endofpacket and empty signals. You can use this signal to specify the number of empty symbols in the cycle that includes the endofpacket signal. This signal is not necessary if the number of symbols per beat is 1. Type the width of the error signal. Valid values are 031 bits. Type 0 if you do not need to send error values. Type the description for each of the error bits. Separate the description fields by semicolons. For a connection to be made, the description of the error bits in the source and sink must match. Refer to Error Adapter on page 129 for the adaptations that can be made when the bits do not match.
Data Bits Per Symbol Data Symbols Per Beat Include Packet Support
129
Error Adapter
The error adapter ensures that per-bit error information provided by source interfaces is correctly connected to the sink interface's input error signal. The adaptations are described in Table 129:
Table 129. Avalon-ST Error Adapter Parameters Parameter Description Input Interface Parameters Error Signal Width (bits) Type the width of the error signal. Valid values are 031 bits. Type 0 if the error signal is not used. Type the description for each of the error bits. Separate the description fields by commas. For a connection to be made, the description of the error bits in the source and sink must match. Refer to Error Adapter on page 129 for the adaptations that can be made when the bits do not match. Output Interface Parameters Error Signal Width (bits) Type the width of the error signal. Valid values are 031 bits. Type 0 if you do not need to send error values. Type the description for each of the error bits. Separate the description fields by semicolons. For a connection to be made, the description of the error bits in the source and sink must match. Refer to Error Adapter on page 129 for the adaptations that can be made when the bits do not match. Common to Input and Output Interfaces Support Backpressure with the ready signal Ready Latency Turn on this option to add the backpressure functionality to the interface. When the ready signal is used, the value for ready_latency indicates the number of cycles between when the ready signal is asserted and when valid data is driven. Type the width of the channel signal. A channel width of 4 allows up to 16 channels. The maximum width of the channel signal is eight bits. Set to 0 if channels are not used. Type the maximum number of channels that the interface supports. Valid values are 0255. Type the number of bits per symbol. Type the number of symbols per active transfer. Turn this option on if the interfaces supports a packet protocol, including the startofpacket, endofpacket and empty signals. Turn this option on if the cycle that includes the endofpacket signal can include empty symbols. This signal is not necessary if the number of symbols per beat is 1.
Channel Signal Width (bits) Max Channel Data Bits Per Symbol Data Symbols Per Beat Include Packet Support
December 2010
Altera Corporation
1210
Additional Information
Typographic Conventions
The following table shows the typographic conventions this document uses.
Visual Cue Bold Type with Initial Capital Letters Meaning Indicate command names, dialog box titles, dialog box options, and other GUI labels. For example, Save As dialog box. For GUI elements, capitalization matches the GUI. Indicates directory names, project names, disk drive names, file names, file name extensions, software utility names, and GUI labels. For example, \qdesigns directory, D: drive, and chiptrip.gdf file. Indicate document titles. For example, Stratix IV Design Guidelines. Indicates variables. For example, n + 1. italic type Variable names are enclosed in angle brackets (< >). For example, <file name> and <project name>.pof file. Indicate keyboard keys and menu names. For example, the Delete key and the Options menu.
December 2010
Altera Corporation
Info2
Meaning Quotation marks indicate references to sections within a document and titles of Quartus II Help topics. For example, Typographic Conventions. Indicates signal, port, register, bit, block, and primitive names. For example, data1, tdi, and input. The suffix n denotes an active-low signal. For example, resetn.
Courier type
Indicates command line commands and anything that must be typed exactly as it appears. For example, c:\qdesigns\tutorial\chiptrip.gdf. Also indicates sections of an actual file, such as a Report File, references to parts of files (for example, the AHDL keyword SUBDESIGN), and logic function names (for example, TRI).
An angled arrow instructs you to press the Enter key. Numbered steps indicate a list of items when the sequence of the items is important, such as the steps listed in a procedure. Bullets indicate a list of items when the sequence of the items is not important. The hand points to information that requires special attention. A question mark directs you to a software help system with related information. The feet direct you to another document or website with related information. A caution calls attention to a condition or possible situation that can damage or destroy the product or your work. A warning calls attention to a condition or possible situation that can cause you injury. The envelope links to the Email Subscription Management Center page of the Altera website, where you can sign up to receive update notifications for Altera documents.
1 h f c w