Xilinx Tutorial
Xilinx Tutorial
8.2
Xilinx is disclosing this Document and Intellectual Property (hereinafter the Design) to you for use in the development of designs to operate on, or interface with Xilinx FPGAs. Except as stated herein, none of the Design may be copied, reproduced, distributed, republished, downloaded, displayed, posted, or transmitted in any form or by any means including, but not limited to, electronic, mechanical, photocopying, recording, or otherwise, without the prior written consent of Xilinx. Any unauthorized use of the Design may violate copyright laws, trademark laws, the laws of privacy and publicity, and communications regulations and statutes. Xilinx does not assume any liability arising out of the application or use of the Design; nor does Xilinx convey any license under its patents, copyrights, or any rights of others. You are responsible for obtaining any rights you may require for your use or implementation of the Design. Xilinx reserves the right to make changes, at any time, to the Design as deemed desirable in the sole discretion of Xilinx. Xilinx assumes no obligation to correct any errors contained herein or to advise you of any correction if such be made. Xilinx will not assume any liability for the accuracy or correctness of any engineering or technical support or assistance provided to you in connection with the Design. THE DESIGN IS PROVIDED AS IS WITH ALL FAULTS, AND THE ENTIRE RISK AS TO ITS FUNCTION AND IMPLEMENTATION IS WITH YOU. YOU ACKNOWLEDGE AND AGREE THAT YOU HAVE NOT RELIED ON ANY ORAL OR WRITTEN INFORMATION OR ADVICE, WHETHER GIVEN BY XILINX, OR ITS AGENTS OR EMPLOYEES. XILINX MAKES NO OTHER WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, REGARDING THE DESIGN, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NONINFRINGEMENT OF THIRD-PARTY RIGHTS. IN NO EVENT WILL XILINX BE LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, EXEMPLARY, SPECIAL, OR INCIDENTAL DAMAGES, INCLUDING ANY LOST DATA AND LOST PROFITS, ARISING FROM OR RELATING TO YOUR USE OF THE DESIGN, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE TOTAL CUMULATIVE LIABILITY OF XILINX IN CONNECTION WITH YOUR USE OF THE DESIGN, WHETHER IN CONTRACT OR TORT OR OTHERWISE, WILL IN NO EVENT EXCEED THE AMOUNT OF FEES PAID BY YOU TO XILINX HEREUNDER FOR USE OF THE DESIGN. YOU ACKNOWLEDGE THAT THE FEES, IF ANY, REFLECT THE ALLOCATION OF RISK SET FORTH IN THIS AGREEMENT AND THAT XILINX WOULD NOT MAKE AVAILABLE THE DESIGN TO YOU WITHOUT THESE LIMITATIONS OF LIABILITY. The Design is not designed or intended for use in the development of on-line control equipment in hazardous environments requiring failsafe controls, such as in the operation of nuclear facilities, aircraft navigation or communications systems, air traffic control, life support, or weapons systems (High-Risk Applications). Xilinx specifically disclaims any express or implied warranties of fitness for such High-Risk Applications. You represent that use of the Design in such High-Risk Applications is fully at your risk. Copyright 1995-2006 Xilinx, Inc. All rights reserved. XILINX, the Xilinx logo, and other designated brands included herein are trademarks of Xilinx, Inc. PowerPC is a trademark of IBM, Inc. All other trademarks are the property of their respective owners.
www.xilinx.com
Preface
Tutorial Contents
This guide covers the following topics. Chapter 1, Overview of ISE and Synthesis Tools, introduces you to the ISE primary user interface, Project Navigator, and the synthesis tools available for your design. Chapter 2, HDL-Based Design, guides you through a typical HDL-based design procedure using a design of a runners stopwatch. Chapter 3, Schematic-Based Design, explains many different facets of a schematicbased ISE design flow using a design of a runners stopwatch. This chapter also shows how to use ISE accessories such as StateCAD, Project Navigator, CORE Generator, and ISE Text Editor. Chapter 4, Behavioral Simulation, explains how to use the ModelSim Simulator to simulate a design before design implementation to verify that the logic that you have created is correct. Chapter 5, Design Implementation, describes how to Translate, Map, Place, Route (Fit for CPLDs), and generate a Bit file for designs. Chapter 6, Timing Simulation, explains how to perform a timing simulation using the block and routing delay information from the routed design to give an accurate assessment of the behavior of the circuit under worst-case conditions. Chapter 7, iMPACT Tutorial explains how to program a device with a newly created design using the IMPACT configuration tool.
www.xilinx.com
Tutorial Flows
This document contains three tutorial flows. In this section, the three tutorial flows are outlined and briefly described, in order to help you determine which sequence of chapters applies to your needs. The tutorial flows include: HDL Design Flow Schematic Design Flow Implementation-only Flow
Implementation-only Flow
The Implementation-only flow is as follows: Chapter 5, Design Implementation Chapter 6, Timing Simulation Note that timing simulation is optional; however, it is strongly recommended. Chapter 7, iMPACT Tutorial
www.xilinx.com
Additional Resources
Additional Resources
To find additional documentation, see the Xilinx website at: http://www.xilinx.com/literature. To search the Answer Database of silicon, software, and IP questions and answers, or to create a technical support WebCase, see the Xilinx website at: http://www.xilinx.com/support.
www.xilinx.com
www.xilinx.com
Table of Contents
Preface: About This Tutorial
About the In-Depth Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Tutorial Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Tutorial Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
HDL Design Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Schematic Design Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Implementation-only Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
www.xilinx.com 1-800-255-7778
Design Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Functional Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Design Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Adding Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Checking the Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Correcting HDL Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating an HDL-Based Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the New Source Wizard and ISE Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Language Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a Language Template to Your File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a CORE Generator Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a CORE Generator Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Instantiating the CORE Generator Module in the HDL Code. . . . . . . . . . . . . . . . . . . . . Creating a DCM Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the DCM Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Instantiating the DCM1 Macro - VHDL Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Instantiating the DCM1 Macro - Verilog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Synthesizing the Design using XST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Entering Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Entering Synthesis Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Synthesizing the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The RTL / Technology Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Synthesizing the Design using Synplify/Synplify Pro . . . . . . . . . . . . . . . . . . . . . . . . . Examining Synthesis Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Synthesizing the Design using LeonardoSpectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . Entering Synthesis Options through ISE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Synthesizing the Design Using Precision Synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . Entering Synthesis Options through ISE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The RTL/Technology Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 30 30 31 31 34 35 36 36 38 41 41 43 44 46 47 48 48 48 49 50 51 52 53 53 53
www.xilinx.com 1-800-255-7778
Creating a New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a New Project: Using New Project Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a New Project: Using a Tcl Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Stopping the Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
56 57 58 59
Design Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Functional Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Design Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Opening the Schematic File in the Xilinx Schematic Editor. . . . . . . . . . . . . . . . . . . . . . Manipulating the Window View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Schematic-Based Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Defining the time_cnt Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding I/O Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding Components to time_cnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Placing the Remaining Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Correcting Mistakes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Drawing Wires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding Buses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding Bus Taps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding Net Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Checking the Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Saving the Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating and Placing the time_cnt Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the time_cnt symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Placing the time_cnt Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a CORE Generator Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a CORE Generator Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a State Machine Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding New States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a State Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a State Machine Reset Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the State Machine HDL output file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the State Machine Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a DCM Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Clocking Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the dcm1 Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating an HDL-Based Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the New Source Wizard and ISE Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Language Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a Language Template to Your File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the hex2led Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Placing the stmach, ten_cnt, clk_div_262k, DCM1, debounce, and hex2led Symbols Hierarchy Push/Pop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Device Inputs/Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding Input Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding I/O Markers and Net Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Assigning Pin Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Completing the Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 63 63 64 64 65 67 68 68 68 69 70 71 72 72 72 72 73 73 75 76 77 78 80 80 81 81 81 83 84 84 86 87 87 87 89 90 90 90 91 91
www.xilinx.com 1-800-255-7778
Specifying Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating Timing Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Translating the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Constraints Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Pin-out Area Constraints Editor (PACE) . . . . . . . . . . . . . . . . . . . . . . . . . .
10
www.xilinx.com 1-800-255-7778
Mapping the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Using Timing Analysis to Evaluate Block Delays After Mapping . . . . . . . . . . . . 126
Estimating Timing Goals with the 50/50 Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Report Paths in Timing Constraints Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Placing and Routing the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using FPGA Editor to Verify the Place and Route . . . . . . . . . . . . . . . . . . . . . . . . . . . Evaluating Post-Layout Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changing HDL with Partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating Configuration Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a PROM File with iMPACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Command Line Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
www.xilinx.com 1-800-255-7778
11
12
www.xilinx.com 1-800-255-7778
Chapter 1
Overview of ISE
ISE controls all aspects of the design flow. Through the Project Navigator interface, you can access all of the design entry and design implementation tools. You can also access the files and documents associated with your project. Project Navigator maintains a flat directory structure; therefore, you must maintain revision control through the use of snapshots.
www.xilinx.com
13
Sources Window
This window consists of three tabs which provide information for the user. Each tab is discussed in further detail below.
Sources Tab
The Sources tab displays the project name, the specified device, and user documents and design source files associated with the selected Design View. The Design View (Sources for) drop-down list at the top of the Sources tab allows you to view only those source files associated with the selected Design View, such as Synthesis/Implementation. In the Number of drop-down list, a Resources column and a Preserve Column are available for Designs that use Partitions. The use of partitions is covered in Chapter 5, Design Implementation.
14
www.xilinx.com
Overview of ISE
Each file in a Design View has an associated icon. The icon indicates the file type (HDL file, schematic, core, or text file, for example). For a complete list of possible source types and their associated icons, see the ISE Help. Select Help > ISE Help Contents, select the Index tab and search for Source file types. If a file contains lower levels of hierarchy, the icon has a + to the left of the name. HDL files have this + to show the entities (VHDL) or modules (Verilog) within the file. You can expand the hierarchy by clicking the +. You can open a file for editing by double-clicking on the filename.
Snapshots Tab
The Snapshots tab displays all snapshots associated with the project currently open in Project Navigator. A snapshot is a copy of the project including all files in the working directory, and synthesis and simulation sub-directories. A snapshot is stored with the project for which is was taken, and the snapshot can be viewed in the Snapshots tab. You can view the reports, user documents, and source files for all snapshots. All information displayed in the Snapshots tab is read-only. Using snapshots provides an excellent version control system, enabling subteams to do simultaneous development on the same design.
Note: Remote sources are not copied with the snapshot. A reference is maintained in the snapshot. For more information, see the ISE Help.
Libraries Tab
The Libraries tab displays all libraries associated with the project open in Project Navigator.
Processes Window
This window contains one default tab called the Processes tab.
Processes Tab
The Processes tab is context sensitive and changes based upon the source type selected in the Sources tab and the Top-Level Source Type in your project. From the Processes tab, you can run the functions necessary to define, run and view your design. The Processes tab provides access to the following functions: Add an Existing Source Create New Source View Design Summary Design Entry Utilities Provides access to symbol generation, instantiation templates, HDL Converter, View command line Log File, and simulation library compilation. User Constraints Provides access to editing location and timing constraints. Synthesis Provides access to Check Syntax, Synthesis, View RTL or Technology Schematic, and synthesis reports. This varies depending on the synthesis tools you use.
www.xilinx.com
15
Implement Design Provides access to implementation tools, design flow reports, and point tools. Generate Programming File Provides access to the configuration tools and bitstream generation.
The Processes tab incorporates automake technology. This enables the user to select any process in the flow and the software automatically runs the processes necessary to get to the desired step. For example, when you run the Implement Design process, Project Navigator also runs the Synthesis process because implementation is dependent on up-todate synthesis results.
Note: To view a running log of command line arguments in the Console tab of the Transcript window, expand Design Entry Utilities and select View Command Line Log File. See the Using Command Line section of Chapter 5, Design Implementation for further details.
Transcript Window
The Transcript window contains five default tabs: Console, Errors, Warnings, Tcl Console, Find in Files. Console Displays errors, warnings, and information messages. Errors are signified by a red (X) next to the message, while warnings have a yellow exclamation mark (!). Warnings Displays only warning messages. Other console messages are filtered out. Errors Displays only error messages. Other console messages are filtered out. Tcl Console Is a user interactive console. In additions to displaying errors, warnings and informational messages, the Tcl Console allows a user to enter Project Navigator specific Tcl commands. For more information on Tcl commands, see the ISE Help. Find in Files Displays the results of the Edit > Find in Files function.
16
www.xilinx.com
Workspace
Design Summary
The Design Summary lists high-level information about your project, including overview information, a device utilization summary, performance data gathered from the Place & Route (PAR) report, constraints information, and summary information from all reports with links to the individual reports.
Text Editor
Source files and other text documents can be opened in a user designated editor. The editor is determined by the setting found by selecting Edit > Preferences, expand ISE General and click Editor. The default editor is the ISE Text Editor. ISE Text Editor enables you to edit source files and user documents. You can access the Language Templates, which is a catalog of ABEL, Verilog and VHDL language, and User Constraints File templates that you can use and modify in your own design.
Schematic Editor
The Schematic Editor is integrated in the Project Navigator framework. The Schematic Editor can be used to graphically create and view logical designs.
Creating a Snapshot
To create a snapshot: 1. 2. Select Project > Take Snapshot. In the Take a Snapshot of the Project dialog box, enter the snapshot name and any comments associated with the snapshot.
The snapshot containing all of the files in the project directory along with project settings is displayed in the Snapshots tab.
Restoring a Snapshot
Since snapshots are read-only, a snapshot must be restored in order to continue work. When you restore a snapshot, it replaces the project in your current session.
www.xilinx.com
17
To restore a snapshot: 1. 2. In the Snapshots tab, select the snapshot from the drop-down list. Select Project > Make Snapshot Current.
Before the snapshot replaces the current project, you are given the option to place the current project in a snapshot so that your work is not lost.
Viewing a Snapshot
The Snapshots tab contains a list of all the snapshots available in the current project. To review a process report or verify process status within a snapshot: 1. 2. 3. Expand the snapshot source tree and select the desired source file. Right-click the mouse over the desired process report. From the menu, select Open Without Updating.
Creating an Archive
To create an archive: 1. Select Project > Archive. 2. In the Create Zip Archive dialog box, enter the archive name and location. Note: The archive contains all of the files in the project directory along with project settings. Remote
sources are not zipped up into the archive. For more information, see the ISE Help.
Restoring an Archive
You cannot restore an archived file directly into Project Navigator. The compressed file can be extracted with any ZIP utility and you can then open the extracted file in Project Navigator.
LeonardoSpectrum
This synthesis tool is not part of the ISE package and is not available unless purchased separately. Two commonly used properties are Optimization Goal and Optimization Effort. With these properties you can control the synthesis results for area or speed and the amount of time the synthesizer runs.This synthesis tool is available for both an HDL- and Schematic-based design flow.
18
www.xilinx.com
Process Properties
Process properties enable you to control the synthesis results of LeonardoSpectrum. Most of the commonly used synthesis options available for the LeonardoSpectrum stand-alone version are available for LeonardoSpectrum synthesis through ISE. For more information, see the LeonardoSpectrum online help.
Precision Synthesis
This synthesis tool is not part of the ISE package and is not available unless purchased separately. Two commonly used properties are Optimization Goal and Optimization Effort. With these properties you can control the synthesis results for area or speed and the amount of time the synthesizer runs.This synthesis tool is available for both an HDL- and Schematic-based design flow.
Process Properties
Process properties enable you to control the synthesis results of Precision. Most of the commonly used synthesis options available for the Precision stand-alone version are available for Precision synthesis through ISE. For more information, see the Precision online help.
www.xilinx.com
19
Synplify/Synplify Pro
This synthesis tool is not part of the ISE package and is not available unless purchased separately. This synthesis tool is available for HDL-based designs, but it is not available for a schematic-based design.
Process Properties
Process properties enable you to control the synthesis results of Synplify/Synplify Pro. Most of the commonly used synthesis options available in the Synplify/Synplify Pro stand-alone version are available for Synplify/Synplify Pro synthesis through ISE. For more information, see the Synplify/Synplify Pro online help.
20
www.xilinx.com
Process Properties
Process properties enable you to control the synthesis results of XST. Two commonly used properties are Optimization Goal and Optimization Effort. With these properties you can control the synthesis results for area or speed, and the amount of time the synthesizer runs. More detailed information is available in the XST User Guide, available in the collection of software manuals. From ISE, select Help > Software Manuals, or go on the web at http://www.xilinx.com/support/sw_manuals/xilinx8/.
www.xilinx.com
21
22
www.xilinx.com
Chapter 2
HDL-Based Design
This chapter includes the following sections: Overview of HDL-Based Design Getting Started Design Description Design Entry Synthesizing the Design
www.xilinx.com
23
Getting Started
The following sections describe the basic requirements for running the tutorial.
Required Software
To perform this tutorial, you must have the following software and software components installed: Xilinx Series ISE 8.2i Spartan-3 libraries and device files
Note: For detailed software installation instructions, refer to the ISE Release Notes and Installation
Guide.
This tutorial assumes that the software is installed in the default location c:\xilinx. If you have installed the software in a different location, substitute your installation path for c:\xilinx in the procedures that follow.
The following third-party simulation tool is optional for this tutorial, and may be used in place of the ISE Simulator: ModelSim
VHDL or Verilog?
This tutorial supports both VHDL and Verilog designs, and applies to both designs simultaneously, noting differences where applicable. You will need to decide which HDL language you would like to work through for the tutorial, and download the appropriate files for that language. XST can synthesize a mixed-language design. However, this tutorial does not go over the mixed language feature.
24
www.xilinx.com
Getting Started
www.xilinx.com
25
26
www.xilinx.com
Getting Started
5.
Select the following values in the New Project Wizard - Device Properties window:
Product Category: All Family: Spartan3 Device: XC3S200 Package: FT256 Speed: -4 Synthesis Tool: XST (VHDL/Verilog) Simulator: ISE Simulator (VHDL/Verilog)
6. 7. 8.
Click Next, then Next, and then click Add Source in the New Project Wizard - Add Existing Sources window. Browse to c:\xilinx\ISEexamples\wtut_vhd or c:\xilinx\ISEexamples\wtut_ver. Select the following files (.vhd files for VHDL design entry or .v files for Verilog design entry) and click Open.
9.
10. In the Adding Source Files dialog box, verify that all added HDL files are associated with Synthesis/Imp + Simulation, then click OK.
3.
Note: If presented with a dialog box stating that *.ise appears to be locked, click Yes to continue
project creation.
www.xilinx.com
27
Design Description
The design used in this tutorial is a hierarchical, HDL-based design, which means that the top-level design file is an HDL file that references several other lower-level macros. The lower-level macros are either HDL modules or IP modules. The design begins as an unfinished design. Throughout the tutorial, you will complete the design by generating some of the modules from scratch and by completing others from existing files. When the design is complete, you will simulate it to verify the designs functionality. In the runners stopwatch design, there are three external inputs and three external output buses. The system clock is an externally generated signal. The following list summarizes the input lines and output buses.
Inputs
The following are input signals for the tutorial stopwatch design. STRTSTOP Starts and stops the stopwatch. This is an active low signal which acts like the start/stop button on a runners stopwatch. RESET Resets the stopwatch to 00.0 after it has been stopped. CLK Externally generated system clock.
Outputs
The following are outputs signals for the design. SEG_A, SEG_B, SEG_C, SEG_D, SEG_F, SEG_G, SEG_DP These outputs drive the individual segments and the decimal point for all four digits of the stopwatch design. The digits of the stopwatch are displayed on 7-segment LED displays. AN[3:0] This is a one-hot vector signal which drives the anodes of the four 7-segment LED displays to determine which display will be lighted.
Functional Blocks
The completed design consists of the following functional blocks. clk_div_262k Macro which divides a clock frequency by 262,144. dcm1 Clocking Wizard macro with internal feedback, frequency controlled output, and duty-cycle correction. The CLKFX_OUT output converts the 50 MHz clock of the Spartan-3 demo board to 26.2144 MHz.
28
www.xilinx.com
Design Entry
debounce Schematic module implementing a simplistic debounce circuit for the STRTSTOP input signal.
hex2led HDL-based macro. This macro decodes the ones and tens digit values from hexadecimal to 7-segment display format.
led_control Module controlling the data multiplexing to the four 7-segment LED displays. statmach State Machine module defined and implemented in State Diagram Editor. ten_cnt CORE Generator 4-bit binary encoded counter. This macro outputs a 4-bit code which is decoded to represent the tenths and hundredths digit of the watch value as a 10-bit one-hot encoded value.
time_cnt Module which counts from 0:0 to 9:59 decimal. This macro has three 4-bit outputs, which represent the minutes and seconds digits of the decimal point.
Design Entry
For this hierarchical design, you will examine HDL files, correct syntax errors, create an HDL macro, and add a CORE Generator module. You will create and use each type of design macro. All procedures used in the tutorial can be used later for your own designs. With the wtut_vhd.ise or wtut_ver.ise project open in Project Navigator, the Sources tab displays all of the source files currently added to the project, with the associated entity or module names (see Figure 2-4). In the current project, time_cnt and hex2led are instantiated, but the associated entity or module is not defined in the project. Instantiated components with no entity or module declaration are displayed with a red question mark.
www.xilinx.com
29
Note: Alternatively, the time_cnt.vhd file could be added to the project by entering the following command in the Tcl Console tab and then selecting View > Refresh.
xfile add time_cnt.vhd The red question-mark (?) for time_cnt should change to show the VHD file icon.
Note: Check Syntax is not available when Synplify is selected as the synthesis tool.
30
www.xilinx.com
Design Entry
d. In the MSB field enter 3, and in the LSB field enter 0. Refer to Figure 2-6.
www.xilinx.com
31
The VHDL file is displayed in Figure 2-7. The Verilog HDL file is displayed in Figure 2-8.
32
www.xilinx.com
Design Entry
Figure 2-8:
www.xilinx.com
33
In the ISE Text Editor, the ports are already declared in the HDL file, and some of the basic file structure is already in place. Keywords are displayed in blue, comments in green, and values are black. The file is color-coded to enhance readability and help you recognize typographical errors.
Note: You can add your own templates to the Language Templates for components or constructs that you use often.
To invoke the Language Templates and select the template for this tutorial: 1. From Project Navigator, select Edit > Language Templates. Each HDL language in the Language Templates is divided into five sections: Common Constructs, Device Primitive Instantiation, Simulation Constructs, Synthesis Constructs and User Templates. To expand the view of any of these sections, click the + next to the section. Click any of the listed templates to view the template contents in the right pane. 2. Under either the VHDL or Verilog hierarchy, expand the Synthesis Constructs hierarchy, expand the Coding Examples hierarchy, expand the Misc hierarchy, and select the template called 7-Segment Display Hex Conversion. Use the appropriate template for the language you are using. When the template is selected in the hierarchy the contents display in the right pane.
34
www.xilinx.com
Design Entry
3. 4.
www.xilinx.com
35
5.
(Verilog only) Replace the two <4-bit_hex_input> and the sixteen <7seg_output> entries with HEX and LED respectively. You now have complete and functional HDL code. Save the file by selecting File > Save. Select hex2led in the Sources tab. In the Processes tab, double-click Check Syntax. Close the ISE Text Editor.
6. 7. 8. 9.
7.
Component Name: ten_cnt Defines the name of the module. Output Width: 4 Defines the width of the output bus. Count Restrictions: Step Value: 1 Restrict Count: Selected Final Count Value: 9 This dictates the maximum count value.
Count Mode: UP
36
www.xilinx.com
Design Entry
Synchronous Settings: None selected Clock Enable: Select CE Click Next. Load Options: None selected Threshold Options: Asynchronous Threshold Output: Selected Synchronous Threshold Output: Not selected Cycle Early Threshold Output: Not selected Threshold Value: 9
Signal goes high when the specified value has been reached.
www.xilinx.com
37
8.
Check that only the following pins are used (used pins will be highlighted on the symbol on the left side of the customization GUI):
9.
Click Finish. The module is created and automatically added to the project library.
Note: A number of files are added to the project directory. Some of these files are:
ten_cnt.vho or ten_cnt.veo These are the instantiation templates used to incorporate the CORE Generator module into your source HDL.
ten_cnt.vhd or ten_cnt.v These are HDL wrapper files for the core and are used only for simulation. ten_cnt.edn This file is the netlist that is used during the Translate phase of implementation. ten_cnt.xco This file stores the configuration information for the Tenths module and is used as a project source.
VHDL Flow
To instantiate the CORE Generator module using a VHDL flow: 1. 2. 3. In Project Navigator, double-click stopwatch.vhd to open the file in ISE Text Editor. Place your cursor after the line that states:
-- Insert Coregen Counter Component Declaration
Select Edit > Insert File, then select ten_cnt.vho and click Open. The VHDL template file for the CORE Generator instantiation is inserted.
38
www.xilinx.com
Design Entry
to
--INST_TAG_END ------ END INSTANTIATION Template -----
5. 6. 7. 8. 9.
Select Edit > Cut. Place the cursor after the line that states:
--Insert Coregen Counter Instantiation
Select Edit > Paste two times because two CORE Generator counters are needed. Change the two instance names from your_instance_name to ten_cnt1 and ten_cnt2. Edit this instantiated code to connect the signals in the Stopwatch design to the ports of the CORE Generator module as shown in Figure 2-12.
www.xilinx.com
39
Verilog Flow
To instantiate the CORE Generator module using a Verilog flow: 1. 2. 3. 4. In Project Navigator, double-click stopwatch.v to open the file in the ISE Text Editor. Place your cursor after the line that states: //Place the Coregen module instantiation for ten_cnt here Select Edit > Insert File and select ten_cnt.veo. Highlight the inserted code of ten_cnt.veo from
//----------- Begin cut here for INSTANTIATION TEMPLATE ---//
to
// INST_TAG_END ------ End INSTANTIATION Template
5. 6. 7. 8.
Select Edit > Copy. Select Edit > Paste to paste another instantiation of ten_cnt after the first because two CORE Generator counters are needed. Change the two instance names from YourInstanceName to ten_cnt1 and ten_cnt2. Edit this code to connect the signals in the Stopwatch design to the ports of the CORE Generator module as shown in Figure 2-13.
40
www.xilinx.com
Design Entry
www.xilinx.com
41
5. 6. 7. 8. 9.
Click Next, then Finish. The Clocking Wizard is launched. Verify that RST, CLK0 and LOCKED ports are selected. Select CLKFX port. Type 50 and select MHz for the Input Clock Frequency. Verify the following settings:
Phase Shift: NONE CLKIN Source: External, Single Feedback Source: Internal Feedback Value: 1X Use Duty Cycle Correction: Selected
10. Click the Advanced button. 11. Select Wait for DCM lock before DONE Signal goes high. 12. Click OK. An informational message about the LCK_cycle and the STARTUP_WAIT BitGen option may appear. Click OK to close the message box. 13. Click Next, then click Next. 14. In the Clock Frequency Synthesizer dialog box, type 26.2144 and select MHz in the Use output frequency box.
( 26.2144Mhz ) 2
18
= 100Hz
15. Click Next and then Finish. The dcm1.xaw file is added to the list of project source files in the Sources tab.
42
www.xilinx.com
Design Entry
Select Edit > Paste to paste the component declaration. Highlight the instantiation template in the newly opened HDL Instantiation Template, shown below.
www.xilinx.com
43
10. Select Edit > Copy. 11. Place the cursor in the stopwatch.vhd file below the line labeled
-- Insert DCM1 instantiation here.
12. Select Edit > Paste to paste the instantiation template. 13. Make the necessary changes as shown in the figure below.
44
www.xilinx.com
7.
8.
www.xilinx.com
45
Figure 2-20: Specifying Synthesis Tool Note: If you do not see your synthesis tool among the options in the list, you may not have the software installed or may not have it configured in ISE. The Synthesis tools are configured in the Preferences dialog box (Edit > Preferences, expand ISE General, then click Integrated Tools).
Changing the design flow results in the deletion of implementation data. You have not yet created any implementation data in this tutorial. For projects that contain implementation data, Xilinx recommends that you take a snapshot of the project before changing the synthesis tool to preserve this data. For more information about taking a snapshot, see Creating a Snapshot in Chapter 1. A summary of available synthesis tools is available in Overview of Synthesis Tools in Chapter 1 Read the section for your synthesis tool: Synthesizing the Design using XST Synthesizing the Design using Synplify/Synplify Pro Synthesizing the Design using LeonardoSpectrum Synthesizing the Design Using Precision Synthesis
46
www.xilinx.com
View RTL Schematic Generates a schematic view of your RTL netlist. View Technology Schematic Generates a schematic view of your Technology netlist. Check Syntax Verifies that the HDL code is entered properly. Generate Post-Synthesis Simulation Model Creates HDL simulation models based on the synthesis netlist.
Entering Constraints
XST supports a User Constraint File (UCF) style syntax to define synthesis and timing constraints. This format is called the Xilinx Constraint File (XCF), and the file has an .xcf file extension. XST uses the .xcf extension to determine if the file is a constraints file. To create a new Xilinx Constraint File: 1. 2. 3. Select Project > Add Source. In the Add Existing Sources dialog box, change the Files of type: to All Files (*.*) and then select and add stopwatch.xcf. Notice that stopwatch.xcf is added as a User document.
Note: In place of the three steps above, you may add the .xcf file through the the Tcl Console, using the following command and then selecting View > Refresh.
xfile add stopwatch.xcf 4. 5. Double-click stopwatch.xcf to open the file in the ISE Text Editor. The following constraints should exist in the stopwatch.xcf file:
TIMESPEC TS_CLK=PERIOD CLK 20 ns; BEGIN MODEL stopwatch NET "CLK" TNM_NET = "CLK"; NET "CLK" LOC = "T9";
NET "AN<0>" LOC = "d14"; NET "AN<1>" LOC = "g14"; NET "AN<2>" LOC = "f14"; NET "AN<3>" LOC = "e13"; NET "RESET" LOC = "L13"; NET "SEG_A" LOC = "e14"; NET "SEG_B" LOC = "g13"; NET "SEG_C" LOC = "n15"; NET "SEG_D" LOC = "p15"; NET "SEG_E" LOC = "r16"; NET "SEG_F" LOC = "f13"; NET "SEG_G" LOC = "n16"; NET "SEG_DP" LOC = "P16"; NET "STRTSTOP" END; LOC = "M13";
www.xilinx.com
47
6.
Close stopwatch.xcf.
Note: For more constraint options in the implementation tools, see Using the Constraints Editor
and Using the Pin-out Area Constraints Editor (PACE) in Chapter 5, Design Implementation.
To view a schematic representation of your HDL code: 1. 2. In the Processes tab, click the + next to Synthesize to expand the process hierarchy. Double-click View RTL Schematic or View Technology Schematic.
48
www.xilinx.com
The RTL Viewer displays the top level schematic symbol for the design. Double-click on the symbol to push into the schematic and view the various design elements and connectivity. Right-click the schematic to view various operations that can be performed in the schematic viewer.
Note: For more information about XST constraints, options, reports, or running XST from the command line, see the XST User Guide. This guide is available in the collection of software manuals and is accessible from ISE by selecting Help > Software Manuals, or from the web at http://www.xilinx.com/support/sw_manuals/xilinx8/.
www.xilinx.com
49
To synthesize the design, set the global synthesis options: 1. 2. 3. 4. 5. Select stopwatch.vhd (or stopwatch.v). In the Processes tab, right-click the Synthesize process and select Properties. Check the Write Vendor Constraint File box. Click OK to accept these values. Double-click the Synthesize process to run synthesis.
Note: This step can also be done by selecting stopwatch.vhd (or stopwatch.v), clicking Synthesize in the Processes tab, and selecting Process > Run.
Processes available in Synplify and Synplify Pro synthesis include: View Synthesis Report Lists the synthesis optimizations that were performed on the design and gives a brief timing and mapping report. View RTL Schematic Accessible from the Launch Tools hierarchy, this process displays Synplify or Synplify Pro with a schematic view of your HDL code View Technology Schematic Accessible from the Launch Tools hierarchy, this process displays Synplify or Synplify Pro with a schematic view of your HDL code mapped to the primitives associated with the target technology.
Compiler Report
The compiler report lists each HDL file that was compiled, names which file is the top level, and displays the syntax checking result for each file that was compiled. The report also lists FSM extractions, inferred memory, warnings on latches, unused ports, and removal of redundant logic.
Note: Black boxes (modules not read into a design environment) are always noted as unbound in the Synplify reports. As long as the underlying netlist (.ngo, .ngc or .edn) for a black box exists in the project directory, the implementation tools merge the netlist into the design during the Translate phase.
Mapper Report
The mapper report lists the constraint files used, the target technology, and attributes set in the design. The report lists the mapping results of flattened instances, extracted counters, optimized flip-flops, clock and buffered nets that were created, and how FSMs were coded.
50
www.xilinx.com
Timing Report
The timing report section provides detailed information on the constraints that you entered and on delays on parts of the design that had no constraints. The delay values are based on wireload models and are considered preliminary. Consult the post-place and route timing reports discussed in Chapter 5, Design Implementation, for the most accurate delay information.
Resource Utilization
This section of the report lists all of the resources that Synplify uses for the given target technology. You have now completed Synplify synthesis. At this point, a netlist EDN file exists for the Stopwatch design. To continue with the HDL flow: Go to Chapter 4, Behavioral Simulation, to perform a pre-synthesis simulation of this design. OR Proceed to Chapter 5, Design Implementation, to place and route the design.
www.xilinx.com
51
52
www.xilinx.com
www.xilinx.com
53
54
www.xilinx.com
Chapter 3
Schematic-Based Design
This chapter includes the following sections: Overview of Schematic-Based Design Getting Started Design Description Design Entry
Getting Started
The following sections describe the basic requirements for running the tutorial.
Required Software
You must have Xilinx ISE 8.2i installed to follow this tutorial. For this design you must install the Spartan-3 libraries and device files. A schematic design flow is supported on Windows, Solaris, and Linux platforms.
www.xilinx.com
55
This tutorial assumes that the software is installed in the default location, c:\xilinx. If you have installed the software in a different location, substitute c:\xilinx for your installation path.
Note: For detailed instructions about installing the software, refer to the ISE 8.2i Installation Guide and Release Notes.
Unzip the tutorial design files in any directory with read-write permissions. The schematic tutorial files are copied into the directories when you unzip the files. This tutorial assumes that the files are unarchived under c:\xilinx\ISEexamples. If you restore the files to a different location, substitute c:\xilinx\ISEexamples with the project path.
56
www.xilinx.com
Getting Started
www.xilinx.com
57
5.
Select the following values in the New Project Wizard - Device Properties window:
Product Category: All Family: Spartan3 Device: XC3S200 Package: FT256 Speed: -4 Synthesis Tool: XST (VHDL/Verilog) Simulator: ISE Simulator (VHDL/Verilog)
6. 7. 8.
Click Next, and then click Add Source in the New Project Wizard - Add Existing Sources window. Browse to c:\xilinx\ISEexamples\wtut_sc. Select the following files and click Open.
9.
10. Verify that all added schematic files are associated with Synthesis/Imp + Simulation, and that the .dia file is associated with Synthesis/Implementation Only. 11. Click OK.
Note: If presented with a dialog box stating that wtut_sc.ise appears to be locked, click Yes to continue project creation.
58
www.xilinx.com
Design Description
3.
Design Description
The design used in this tutorial is a hierarchical, schematic-based design, which means that the top-level design file is a schematic sheet that refers to several other lower-level macros. The lower-level macros are a variety of different types of modules, including schematicbased modules, a CORE Generator module, a state machine module, an Architecture Wizard module, and HDL modules. The runners stopwatch design begins as an unfinished design. Throughout the tutorial, you will complete the design by creating some of the modules and by completing others from existing files. A schematic of the completed stopwatch design is shown in the following figure. Through the course of this chapter, you will create these modules, instantiate them, and then connect them.
www.xilinx.com
59
After the design is complete, you will simulate the design to verify its functionality. For more information about simulating your design, see Chapter 4, Behavioral Simulation.
60
www.xilinx.com
Design Description
Inputs
The following are input signals for the runners stopwatch design: STRTSTOP Starts and stops the stopwatch. This is an active-low signal that acts like the start/stop button on a runners stopwatch. RESET Resets the stopwatch to 00.00. CLK System clock for the stopwatch design.
Outputs
The following are output signals for the design: SEG_A, SEG_B, SEG_C, SEG_D, SEG_E, SEG_F, SEG_G, SEG_DP. These outputs drive the individual segments and the decimal point for all four digits of the stopwatch design. The digits of the stopwatch are displayed on 7-segment LED displays. AN(3:0) This is a one-hot vector signal that drives the anodes of the four 7-segment LED displays to determine which display will be lighted.
Functional Blocks
The completed design consists of the following functional blocks. Most of these blocks do not appear on the schematic sheet in the project until after you create and add them to the schematic during this tutorial. CLK_DIV_262k Schematic-based macro that divides a clock frequency by 262,144. DCM1 Clocking Wizard macro with internal feedback, frequency controlled output, and duty-cycle correction. The CLKFX_OUT output converts the 50Mhz clock of the Spartan-3 demo board to 26.2144Mhz. DEBOUNCE Schematic module that implements a simplistic debounce circuit for the strtstop input signal. HEX2LED HDL-based macro that decodes each of the digit values from binary to a 7-segment display format. LED_control Schematic module that controls the data multiplexing to the four, 7-segment LED displays. STATMACH State Machine macro that is defined and implemented in StateCAD.
www.xilinx.com
61
TEN_CNT CORE Generator 4-bit, binary, encoded counter. This macro outputs a 4-bit code that is decoded to represent the tenths and hundredths digits of the stopwatch.
TIME_CNT Schematic-based module that counts from 0:0 to 9:59 decimal. This macro has three 4bit outputs, which represent the minutes and seconds digits of the decimal value.
Design Entry
In this hierarchical design, you will create various types of macros, including schematicbased macros, HDL-based macros, state machine macros, and CORE Generator macros. You will learn the process for creating each of these types of macros, and you will connect the macros together to create the completed stopwatch design. All procedures used in the tutorial can be used later for your own designs.
62
www.xilinx.com
Design Entry
The stopwatch schematic diagram opens in the Project Navigator Workspace. You will see the unfinished design with elements in the lower right corner as shown in the figure below.
www.xilinx.com
63
In the following steps, you will create a schematic-based macro by using the New Source Wizard in Project Navigator. An empty schematic file is then created, and you can define the appropriate logic. The created macro is then automatically added to the projects library. The macro you will create is called time_cnt. This macro is a binary counter with three, 4bit outputs, representing the minutes and seconds values of the stopwatch. To create a schematic-based macro: 1. In Project Navigator, select Project > New Source. The New Source dialog box opens:
A new schematic called time_cnt is created, added to the project, and opened for editing.
64
www.xilinx.com
Design Entry
To add the I/O markers: 1. 2. 3. Select Tools > Create I/O Markers. The Create I/O Markers dialog box opens. In the Inputs box, enter clk,ce,clr. In the Outputs box, enter sec_lsb(3:0),sec_msb(3:0),minutes(3:0).
Note: The Create I/O Marker function is available only for an empty schematic sheet. However, I/O markers may be added to nets at any time by selecting Add > I/O Marker and selecting the desired net.
www.xilinx.com
65
This opens the Symbol Browser to the left of the schematic editor, displaying the libraries and their corresponding components.
Highlight the Counter category from the Symbol Browser dialog box and select the component cd4re from the symbols list. or Select All Symbols and type CD4RE in the Symbol Name Filter at the bottom of the Symbol Browser window.
3. 4.
Move the mouse back into the schematic window. You will notice that the cursor has changed to represent the CD4RE symbol. Move the symbol outline to the location shown in Figure 3-11 and click the left mouse button to place the object.
Note: You can rotate new components being added to a schematic by selecting Ctrl+R. You can rotate existing components by selecting the component, and then selecting Ctrl+R.
66
www.xilinx.com
Design Entry
5.
Place the second CD4CE symbol on the schematic by moving the cursor with attached symbol outline to the desired location, and clicking the left mouse button. See Figure 3-11.
Refer to Figure 3-11 for placement locations. To exit the Symbols Mode, press the Esc key on the keyboard.
www.xilinx.com
67
For a detailed description of the functionality of each of these components, right-click on the component and select Object Properties. In the Object Properties window, select Symbol Info. Symbol information is also available in the Libraries Guides, accessible from the collection of software manuals on the web at http://www.xilinx.com/support/sw_manuals/xilinx8/.
Correcting Mistakes
If you make a mistake when placing a component, you can easily move or delete the component. To move the component, click the component and drag the mouse around the window. Delete a placed component in one of two ways: Click the component and press the Delete key on your keyboard. or Right-click the component and select Delete.
Drawing Wires
Use the Add Wire icon in the Tools toolbar to draw wires (also called nets) to connect the components placed in the schematic. Perform the following steps to draw a net between the AND2 and CB4RE components on the time_cnt schematic. 1. Select Add > Wire or click the Add Wires icon in the Tools toolbar.
Draw the nets to connect the remaining components as shown in Figure 3-11. To specify the shape of the net: 1. 2. Move the mouse in the direction you want to draw the net. Click the mouse to create a 90-degree bend in the wire.
To draw a net between an already existing net and a pin, click once on the component pin and once on the existing net. A junction point is drawn on the existing net.
Adding Buses
In the Schematic Editor, a bus is simply a wire that has been given a multi-bit name. To add a bus, use the methodology for adding wires and then add a multi-bit name. Once a bus has been created, you have the option of tapping this bus off to use each signal individually. The next step is to create three buses called sec_lsb(3:0), sec_msb(3:0) and minutes(3:0), each consisting of the 4 output bits of each counter in the time_cnt schematic. The results can be found in the completed schematic.
68
www.xilinx.com
Design Entry
To add the buses sec_lsb(3:0),sec_msb(3:0) and minutes(3:0) to the schematic, perform the following steps: 1. 2. Select Add > Wire or click the Add Wires icon in the Tools toolbar. Click in the open space just above and to the right of the top CD4RE and then click again on pin of the sec_lsb(3:0) I/O marker. The wire should automatically be drawn as a bus with the name matching that of the I/O marker. To verify this, zoom in. The bus is represented visually by a thicker wire.
3.
Note: Zooming in on the schematic will enable greater precision when drawing the nets.
To tap off a single bit of each bus: 1. Select Add > Bus Tap or click the Add Bus Tap icon in the Tools toolbar.
www.xilinx.com
69
To connect each of the tap off bits: 1. 2. 3. 4. 5. 6. Select Add > Wire or click the Add Wire icon in the Tools toolbar. Draw a wire from each bus tap pin to the adjacent component pin. Select Add > Net Name or click the Add Net Name icon in the Tools toolbar. Type sec_lsb(0) in the Name field of the options tab. The net name is now at the end of your cursor. Select Increase the name in the Add Net Names Options dialog box. With the Increment Name option selected, start at the top net and continue clicking down until you have named the fourth and final net sec_lsb(3).
Note: The Schematic Editor names the bus taps incrementally as they are drawn. Alternatively, name the first net sec_lsb(3) and select Decrease the name in the Add Net Names Options dialog box, and nets are named from the bottom up.
7. 8. 9. Repeat Steps 4 through 6 for the sec_msb(3:0) bus and minutes(3:0). Press Esc to exit the Add Net Name mode. Compare your time_cnt schematic with Figure 3-16 to ensure that all connections are made properly.
Note: It is the name of the wire that makes the electrical connection between the bus and the wire (e.g sec_msb(2) connects to the third bit of sec(3:0)). The bus tap figure is for visual purposes only. The following section shows additional electrical connections by name association.
Note: The two wires named msb_en are now electrically connected. In this case, the nets do not need to be physically connected on the schematic to make the logical connection.
70
www.xilinx.com
Design Entry
Finally, connect the remaining AND5b2 inputs through net name association. 1. 2. Select Add > Net Name or click the Add Net Name icon in the Tools toolbar. Type sec_msb(0) in the Name box of the Add Net Name options dialog box.
Note: The Options window changes depending on which tool you have selected in the Tools
toolbar.
3. 4. 5.
Select Increase the name in the Add Net Names options dialog box. The net name sec_msb(0) is now attached to the cursor. Click on one of the AND5b2 input nets that does not have an inversion bubble. Click on the remaining AND5b2 input nets so that the wires named sec_msb(1) and sec_msb(3) are attached to the inputs with inversion bubbles. Refer to Figure 3-16.
Note: If the nets appear disconnected, select View > Refresh to refresh the screen.
www.xilinx.com
71
Figure 3-17: Save Icon Note: When you save a macro, the Schematic Editor checks the I/O markers against the corresponding symbol, if one exists. If there is a discrepancy, you can let the software update the symbol automatically, or you can modify the symbol manually. I/O markers connect signals between levels of hierarchy and specify the ports on top-level schematic sheets.
2. Close the time_cnt schematic.
To create a symbol that represents the time_cnt schematic using a Tools menu command: 1. 2. 3. 4. With a schematic sheet open, select Tools > Symbol Wizard. In the Symbol Wizard, select Using Schematic, and then select TIME_CNT in the schematic value field. Click Next, then Next, then Next, and then Finish to use the wizard defaults. View and then close the time_cnt symbol.
72
www.xilinx.com
Design Entry
3.
In the Symbol Browser, select the local symbols library (c:\xilinx\ISEexamples\wtut_sc), and then select the newly created time_cnt symbol. Place the time_cnt symbol in the schematic at approximately grid position [900,2100]. Grid position is shown at the bottom right corner of the Project Navigator window, and is updated as the cursor is moved around the schematic.
4.
Note: Do not worry about connecting nets to the pins of the time_cnt symbol. You will do this after adding other components to the stopwatch schematic.
5. Save the changes and close stopwatch.sch.
7.
Component Name: ten_cnt Defines the name of the module. Output Width: 4 Defines the width of the output bus. Count Restrictions: Step value: 1 Select Restrict Count Final Count to value: 9 (This dictates the maximum count value)
Count Mode: Up
www.xilinx.com
73
Synchronous Settings: None selected Clock Enable: Select CE Click Next. Load Options: None selected Threshold Options: Asynchronous Threshold Output: Selected Synchronous Threshold Output: Not selected Cycle Early Threshold Output: Not selected Threshold Value: 9
Signal goes high when the value specified has been reached.
74
www.xilinx.com
Design Entry
8.
Check that only the following pins are used (used pins will be highlighted on the symbol on the left side of the CORE Generator window):
9.
Click Finish. The module is created and automatically added to the project library.
Note: A number of files are added to the project directory. Some of these files are:
ten_cnt.sym This file is a schematic symbol file. ten_cnt.vhd or ten_cnt.v These are HDL wrapper files for the core and are used only for simulation. ten_cnt.edn This file is the netlist that is used during the Translate phase of implementation. ten_cnt.xco This file stores the configuration information for the Tenths module and is used as a project source.
Note: The State Diagram Editor is only available for Windows operating systems. A completed VHDL and Verilog file for the State Machine diagram in this section has been provided for you in the wtut_sc\wtut_sc_completed directory. To skip this section, copy either statmach.v or stamach.vhd from the c:\xilinx\ISEexamples\stut_sc\wtut_sc_completed directory to the c:\xilinx\ISEexamples\stut_sc directory, then proceed to Creating the State Machine Symbol.
To open the partially complete diagram, first add the statmach.dia file to the project by selecting Project > Add Source and selecting statmach.dia. Then, double-click statmach.dia in the Sources tab. The State Diagram Editor is launched with the partially completed state machine diagram. In the incomplete state machine diagram below: The circles represent the various states. The black expressions are the transition conditions, defining how you move between states.
www.xilinx.com
75
The output expressions for each state are found in the circles representing the states. The transition conditions and the state actions are written in language-independent syntax and are then exported to Verilog, VHDL, or ABEL.
76
www.xilinx.com
Design Entry
Note: The name of the state is for your use only and does not affect synthesis. Any name is
fine.
5.
Click OK.
To change the shape of the state bubble, click the bubble and drag it in the direction you wish to stretch the bubble.
Adding a Transition
A transition defines the movement between states of the state machine. Transitions are represented by arrows in the editor. You will add a transition from the clear state to the zero state in the following steps. Because this transition is unconditional, there is no transition condition associated with it. 1. Click the Add Transition icon in the vertical toolbar.
www.xilinx.com
77
4.
78
www.xilinx.com
Design Entry
The Edit State dialog box opens and you can begin to create the desired outputs.
4. 5.
Click OK to enter each individual value. Click OK to exit the Edit State dialog box. The outputs are now added to the state.
www.xilinx.com
79
80
www.xilinx.com
Design Entry
7. 8. 9.
A browser opens displaying the generated HDL file. Examine the code and then close the browser. Save your changes by selecting File > Save. Close the State Diagram Editor.
www.xilinx.com
81
4.
Select FPGA Features and Design > Clocking > Virtex-II Pro, Virtex-II, Spartan-3 > Single DCM in the Clocking hierarchy.
Phase Shift: None Clkin Source: External, Single Feedback Source: Internal Feedback Value: 1X Use Duty Cycle Correction: Selected
82
www.xilinx.com
Design Entry
= 100Hz
15. Click Next and then Finish. The file dcm1.xaw is added to the project.
www.xilinx.com
83
The hex2led component has a 4-bit input port named hex, and a 7-bit output port named led. To enter these ports: 1. 2. 3. 4. Click in the Port Name field and type HEX. Click in the Direction field and set the direction to in. Check the Bus designation box. In the MSB field enter 3, and in the LSB field enter 0. Refer to Figure 3-32.
84
www.xilinx.com
Design Entry
A description of the module displays. 7. Click Finish to open the empty HDL file in ISE Text Editor.
The VHDL file is displayed in Figure 3-33. The Verilog HDL file is displayed in Figure 3-34.
Figure 3-34:
www.xilinx.com
85
In the ISE Text Editor, the ports are already declared in the HDL file, and some of the basic file structure is already in place. Keywords are displayed in blue, comments in green, and values are black. The file is color-coded to enhance readability and recognition of typographical errors.
Note: You can add your own templates to the Language Templates for components or constructs that you use often.
To invoke the Language Templates and select the template for this tutorial: 1. From Project Navigator, select Edit > Language Templates. Each HDL language in the Language Templates is divided into five sections: Common Constructs, Device Primitive Instantiation, Simulation Constructs, Synthesis Constructs and User Templates. To expand the view of any of these sections, click the + next to the topic. Click any of the listed templates to view the template contents in the right pane. 2. Under either the VHDL or Verilog hierarchy, expand the Synthesis Constructs hierarchy, expand the Coding Examples hierarchy, expand the Misc hierarchy, and select the template called 7-Segment Display Hex Conversion. Use the appropriate template for the language you are using. Once the template is selected in the hierarchy, the contents display in the right pane.
86
www.xilinx.com
Design Entry
3. 4.
5.
(Verilog only) Replace the two <4-bit_hex_input> and the sixteen <7seg_output> entries with HEX and LED respectively. You now have complete and functional HDL code. Save the file by selecting File > Save. Select hex2led in the Sources tab. In the Processes tab, double-click Check Syntax. Close the ISE Text Editor.
6. 7. 8. 9.
You are now ready to place the hex2led symbol on the stopwatch schematic.
Placing the stmach, ten_cnt, clk_div_262k, DCM1, debounce, and hex2led Symbols
You can now place the stmach, ten_cnt, clk_div_262k, DCM1, debounce, and hex2led symbols on the stopwatch schematic (stopwatch.sch). In Project Navigator, doubleclick stopwatch.sch. The schematic file opens in the Workspace. 1. Select Add > Symbol or click the Add Symbol icon from the Tools toolbar.
www.xilinx.com
87
2. 3. 4.
View the list of available library components in the Symbol Browser. Locate the project-specific macros by selecting the project directory name in the Categories window. Select the appropriate symbol, and add it to the stopwatch schematic in the approximate location, as shown in Figure 3-37.
Note: Do not worry about drawing the wires to connect this symbol. You will connect components in the schematic later in the tutorial.
5. Save the schematic.
88
www.xilinx.com
Design Entry
Hierarchy Push/Pop
First, perform a hierarchy push down, which enables you to focus in on a lower-level of the schematic hierarchy to view the underlying file. Push down into the clk_div_262k macro--which is a schematic-based, user-created macro--and examine its components. To push down into clk_div_262k from the top-level, stopwatch schematic: 1. Click clk_div_262k symbol in the schematic, and select the Hierarchy Push icon. You can also right-click the macro and select Push into Symbol.
www.xilinx.com
89
Label the three input nets you just drew. Refer to the completed schematic below. To label the RESET net: 1. 2. 3. 4. 5. 6. Select Add > Net Name. Type RESET into the Name box. The net name is now attached to the cursor. Place the name on the leftmost end of the net, as illustrated in Figure 3-41. Repeat Steps 1 through 3 for the STRTSTOP and CLK pins. Once all of the nets have been labeled, add the I/O marker. Select Add > I/O Marker. Click and drag a box around the three labeled nets to place an input port on each net.
90
www.xilinx.com
Design Entry
Note: To turn off the Location constraint without deleting it, select the loc attribute, and click Edit Traits. Select VHDL or Verilog and deselect Write this attribute.
www.xilinx.com
91
4.
92
www.xilinx.com
Design Entry
5.
Note: Remember that nets are logically connected if their names are the same, even if the net is not physically drawn as a connection in the schematic. This method is used to make the logical connection of clk_int and several other signals.
6. 7. 8. 9. Draw wires between the sig_out pin of the debounce component and the strtstop pin of the statmach macro. (See Drawing Wires.) Label the net strtstop_debounced. Add hanging wires to the DCM_lock pin and the reset pin of the statmach macro. Name them locked and reset, respectively. Place an AND2 component to the left of the lower ten_cnt macro. See Adding Components to time_cnt.
10. Draw a wire to connect the output of the AND2 with the CE pin of the TEN_CNT macro. See Drawing Wires. 11. Draw a wire to connect the Q_THRES0 pin of the upper TEN_CNT macro to one of the inputs to the AND2. See Drawing Wires. 12. Draw a hanging wire to the clken output of the statmach component. Label the wire clk_en_int. 13. Draw a hanging wire to the ce pin of the upper TEN_CNT macro and another to the remaining input of the AND2 component. Name both wires clk_en_int. 14. Place a second AND2 component to the left of the TIME_CNT macro. See Adding Components to time_cnt. 15. Draw a wire to connect the output of the AND2 with the CE pin of the TIME_CNT macro. See Drawing Wires. 16. Draw a wire to connect the Q_THRES0 pin of the lower TEN_CNT macro to one of the inputs to the second AND2 component. See Drawing Wires. 17. Draw a wire from the other input of the second AND2 component to the wire connected to the output of the first AND2 component. 18. Draw a hanging wire from the output of the clk_div_262k component and label this net clk_100. 19. Draw a hanging wire from the clk pin of the time_cnt macro and the clk pins of the two ten_cnt macros. See Drawing Wires. Name the three newly added nets clk_100. 20. Draw hanging wires from the RST output pin of the STMACH macro, to the AINIT pins of the ten_cnt macros and the clr pin of the time_cnt macro. See Drawing Wires. Label all four wires RST_INT. 21. Draw wires from the bus outputs of the ten_cnt and time_cnt macros to the inputs of the adjacent hex2led macros. See Drawing Wires. Notice how the wire is automatically converted to a bus. 22. Draw hanging buses from each of the hex2led macro outputs. 23. Name the hex2led outputs nets as follows from top to bottom; hundredthsout(6:0), tenthsout(6:0), onesout(6:0), tensout(6:0), minutesout(6:0). The schematic is now complete. Save the design by selecting File > Save.
www.xilinx.com
93
94
www.xilinx.com
Chapter 4
Behavioral Simulation
This chapter contains the following sections. Overview of Behavioral Simulation Flow ModelSim Setup ISE Simulator Setup Getting Started Adding an HDL Test Bench Behavioral Simulation Using ModelSim Behavioral Simulation Using ISE Simulator
ModelSim Setup
In order to use this tutorial, you must install ModelSim on your computer. The following sections discuss requirements and setup for ModelSim PE, ModelSim SE, and ModelSim XE.
ModelSim PE and SE
ModelSim PE and ModelSim SE are full versions of ModelSim available for purchase directly from Mentor Graphics. In order to simulate with the ISE 8 libraries, use ModelSim 5.8 or later. Older versions may work but are not supported. For more information about purchasing ModelSim PE or SE version 5.8 or later, contact Mentor Graphics.
www.xilinx.com
95
Getting Started
The following sections outline the requirements for performing behavioral simulation in this tutorial.
Required Files
The behavioral simulation flow requires design files, a test bench file, and Xilinx simulation libraries.
96
www.xilinx.com
Getting Started
for each component. These models reflect the functions of each component, and provide the simulator with the information required to perform simulation. For a detailed description of each library, see Chapter 6 of the Synthesis and Verification Design Guide. This Guide is accessible from within ISE by selecting Help > Software Manuals, and from the web at http://www.xilinx.com/support/sw_manuals/xilinx8/.
When the models are updated, you must recompile the libraries. The compiled Xilinx simulation libraries are then available during the simulation of any design.
ModelSim PE or SE
If you are using ModelSim PE or SE, you must compile the simulation libraries with the updated models. See Chapter 6 of the Synthesis and Verification Design Guide. This Guide is accessible from within ISE by selecting Help > Software Manuals, or from the web at http://www.xilinx.com/support/sw_manuals/xilinx8/.
If the MODELSIM environment variable is not set, and the modelsim.ini file has not been copied to the working directory, the modelsim.ini file in the installation directory is used.
ModelSim PE or SE
If you are using ModelSim PE or SE, refer to the Synthesis and Verification Design Guide and use COMPXLIB to compile the libraries. While compiling the libraries, COMPXLIB also
www.xilinx.com
97
updates the modelsim.ini file with the correct mapping. Open the modelsim.ini file and make sure that the library mappings are correct. For future projects, you can copy the modelsim.ini file to the working directory and make changes that are specific to that project, or you can use the MODELSIM environment variable to point to the desired modelsim.ini file.
ISE Simulator
The modelsim.ini file is not applicable to the ISE Simulator.
Note: To create your own test bench file in ISE, select Project > New Source, and select either
VHDL Test Bench or Verilog Text Fixture in the New Source Wizard. An empty stimulus file is added to your project. You must define the test bench in a text editor.
VHDL Design
After downloading the file to your project directory, add the tutorial VHDL test bench to the project: 1. 2. 3. 4. 5. Select Project > Add Source. Select the test bench file stopwatch_tb.vhd. Click Open. In the Choose Source Type dialog box, select VHDL Test Bench File. Click OK.
ISE recognizes the top-level design file associated with the test bench, and adds the test bench in the correct order.
98
www.xilinx.com
Verilog Design
After downloading the file to your project directory, add the tutorial Verilog test fixture to the project: 1. 2. 3. 4. 5. Select Project > Add Source. Select the file stopwatch_tb.v. Click Open. In the Choose Source Type dialog box, select Verilog Test Fixture File. Click OK.
ISE recognizes the top-level design file associated with the test fixture, and adds the test fixture in the correct order.
If the ModelSim Simulator processes do not appear, either ModelSim is not selected as the Simulator in the Project Properties dialog box, or Project Navigator cannot find modelsim.exe. If ModelSim is installed but the processes are not available, the Project Navigator preferences may not be set correctly. To set the ModelSim location: 1. 2. 3. Select Edit > Preferences. Click the + next to ISE General to expand the ISE preferences Click Integrated Tools in the left pane.
www.xilinx.com
99
4.
In the right pane, under Model Tech Simulator, browse to the location of the modelsim.exe file. For example, c:\modeltech_xe\win32xoem\modelsim.exe
The following simulation processes are available: Simulate Behavioral Model This process starts the design simulation. Generate Expected Simulation Results This process is available only if you have a test bench waveform file from the ISE Simulators Test Bench Waveform Editor. If you double-click this process, ModelSim runs in the background to generate expected results and displays them in the ISE Simulators Test Bench Waveform Editor. See Creating a Test Bench Waveform Using the Waveform Editor.
100
www.xilinx.com
6.
For a detailed description of each property available in the Process Properties dialog box, click Help.
Performing Simulation
Once the process properties have been set, you are ready to run ModelSim. To start the behavioral simulation, double-click Simulate Behavioral Model. ModelSim creates the work directory, compiles the source files, loads the design, and performs simulation for the time specified. The majority of this design runs at 100 Hz and would take a significant amount of time to simulate. The first outputs to transition after RESET is released are the seg_dp and AN[3:0] at around 327 uS. This is why the counter may seem like it is not working in a short simulation. For the purpose of this tutorial, only the DCM signals are monitored to verify that they work correctly.
Adding Signals
To view signals during the simulation, you must add them to the Wave window. ISE automatically adds all the top-level ports to the Wave window. Additional signals are displayed in the Signal window based on the selected structure in the Structure window. There are two basic methods for adding signals to the Simulator Wave window. Drag and drop from the Signal/Object window. Highlight signals in the Signal/Object window, and select Add > Wave > Selected Signals.
www.xilinx.com
101
The following procedure explains how to add additional signals in the design hierarchy. In this tutorial, you will be adding the DCM signals to the waveform. If you are using ModelSim version 6.0 or higher, all the windows are docked by default. To undock the windows, click the Undock icon.
102
www.xilinx.com
5. 6.
Right-click in the Signal/Object window. Select Add to Wave > Selected Signals.
Adding Dividers
In ModelSim, you can add dividers in the Wave window to make it easier to differentiate the signals. To add a divider called DCM Signals: 1. 2. 3. 4. 5. Click anywhere in the signal section of the Wave window. If necessary, undock the window and maximize the window for a larger view of the waveform. Select Insert > Divider. Enter DCM Signals in the Divider Name box. Click OK. Click and drag the newly created divider to above the CLKIN_IN signal.
After adding the DCM Signals divider, the waveform will look like Figure 4-4.
Rerunning Simulation
To rerun simulation in ModelSim: 1. Click the Restart Simulation icon.
www.xilinx.com
103
104
www.xilinx.com
5.
Look at the bottom of the waveform for the distance between the two cursors. The measurement should read 20000 ps. This converts to 50 MHz, which is the input frequency from the test bench, which in turn should be the DCM CLK0 output.
6.
Measure CLKFX_OUT using the same steps as above. The measurement should read 38462 ps. This comes out to approximately 26 MHz.
After restarting the simulation, select File > Load in the Wave window to load this file. Your behavioral simulation is complete. To implement the design, follow the steps in Chapter 5, Design Implementation.
www.xilinx.com
105
The following simulation processes are available: Check Syntax This process checks for syntax errors in the test bench. Simulate Behavioral Model This process starts the design simulation. Generate Expected Simulation Results This process is available only if you have a test bench waveform file from ISE Simulators Test Bench Waveform Editor. If you run this process, the ISE Simulator runs in the background to generate expected results and displays them in the Waveform Editor. See Creating a Test Bench Waveform Using the Waveform Editor.
Note: For a detailed description of each property available in the Process Property dialog box, click
Help.
106
www.xilinx.com
Performing Simulation
Once the process properties have been set, you are ready to run the ISE Simulator. To start the behavioral simulation, double-click Simulate Behavioral Model. ISE Simulator creates the work directory, compiles the source files, loads the design, and performs simulation for the time specified. The majority of this design runs at 100 Hz and would take a significant amount of time to simulate. The first outputs to transition after RESET is released are the seg_dp and AN[3:0] at around 327 uS. This is why the counter may seem like it is not working in a short simulation. For the purpose of this tutorial, only the DCM signals are monitored to verify that they work correctly.
Adding Signals
To view signals during the simulation, you must add them to the Waveform window. ISE automatically adds all the top-level ports to the Waveform window. Additional signals are displayed in the Sim Hierarchy window. The following procedure explains how to add additional signals in the design hierarchy. For the purpose of this tutorial, add the DCM signals to the waveform. To add additional signals in the design hierarchy: 1. 2. In the Sim Hierarchy window, click the + next to stopwatch_tb stopwatch_tb to expand the hierarchy. Click the + next to uut stopwatch to expand the hierarchy.
www.xilinx.com
107
Figure 4-10 shows the Sim hierarchy window for the Verilog flow. The graphics and the layout of the window for a schematic or VHDL flow may be different.
To select multiple signals, hold down the Ctrl key. 6. Drag all the selected signals to the waveform.
Notice that the waveforms have not been drawn for the newly added signals. This is because ISE Simulator did not record the data for these signals. By default, ISE Simulator records data only for the signals that have been added to the waveform window while the simulation is running. Therefore, when new signals are added to the waveform window, you must rerun the simulation for the desired amount of time.
Rerunning Simulation
To rerun the simulation in ISE Simulation: 1. Click the Restart Simulation icon.
108
www.xilinx.com
2.
At the ISE Simulator command prompt in the Sim Console, enter run 2000 ns and press Enter.
The simulation runs for 2000 ns. The waveforms for the DCM are now visible in the Waveform window.
6.
Your behavioral simulation is complete. To implement the design, follow the steps in Chapter 5, Design Implementation.
Note: The ISE Simulator Waveform Editor is available on Windows platforms only.
www.xilinx.com
109
4. 5.
Note: In the Select dialog box, the time_cnt file is the default source file because it is selected in
the Sources tab (step 1).
6. 7.
Click Next. Click Finish. The Waveform Editor opens in ISE. The Initialize Timing dialog box displays, and enables you to specify the timing parameters used during simulation. The Clock Time High and Clock Time Low fields together define the clock period for which the design must operate. The Input Setup Time field defines when inputs must be valid. The Output Valid Delay field defines the time after active clock edge when the outputs must be valid.
8.
Clock Time High: 10 Clock Time Low: 10 Input Setup Time: 5 Output Valid Delay: 5
9.
10. Change the Initial Length of Test Bench to 3000. 11. Click Finish.
110
www.xilinx.com
Applying Stimulus
In the Waveform Editor, in the blue cell, you can apply a transition (high/low). The width of this cell is determined by the Input setup delay and the Output valid delay. Enter the following input stimuli: 1. 2. Click the CE cell at time 110 ns to set it high (CE is active high). Click the CLR cell at time 150 ns to set it high.
www.xilinx.com
111
3.
The new test bench waveform source (time_cnt_tb.tbw) is automatically added to the project. 5. 6. Select time_cnt_tb.tbw in the Sources tab. Double-click Generate Expected Simulation Results in the Process tab.
The selected simulator runs in the background and displays the expected output values in the Waveform Editor. 7. Select File > Save to save the test bench waveform with the generated simulation results.
Now, when either Behavioral or Timing simulation is run, the simulation output is automatically checked against the expected result.
112
www.xilinx.com
Chapter 5
Design Implementation
This chapter contains the following sections. Overview of Design Implementation Getting Started Specifying Options Creating Partitions Creating Timing Constraints Translating the Design Using the Constraints Editor Using the Pin-out Area Constraints Editor (PACE) Mapping the Design Using Timing Analysis to Evaluate Block Delays After Mapping Placing and Routing the Design Using FPGA Editor to Verify the Place and Route Evaluating Post-Layout Timing Changing HDL with Partition Creating Configuration Data Creating a PROM File with iMPACT Command Line Implementation
www.xilinx.com
113
Getting Started
The tutorial design emulates a runners stopwatch. There are three inputs to the system: CLK, RESET and SRTSTP. This system generates three seven-bit outputs for output to three seven-segment LED displays.
With a UCF in the project, you are now ready to begin this chapter. Skip to the Specifying Options section.
114
www.xilinx.com
Specifying Options
3.
Open ISE. a. b. On a workstation, enter ise & . On a PC, select Start > Programs > Xilinx ISE 8.2i > Project Navigator. Select File > New Project. Type EDIF_Flow for the Project Name. Select EDIF for the top_level SourceType. Select stopwatch.edn for the Input Design file. Select stopwatch.ucf for the Constraints file. Click Next. i. j. k. Spartan3 for the Device Family xc3s200 for the Device -4 for the Speed Grade, ft256 for the Package
4.
d. Click Next.
Click Next. Click Finish. Copy the ten_cnt.edn file into the EDIF_Flow directory.
In the Sources tab, select the top-level module, stopwatch.edf or stopwatch.edn. This enables the design to be implemented.
Specifying Options
This section describes how to set some properties for design implementation. The implementation properties control how the software maps, places, routes, and optimizes a design. To set the implementation property options for this tutorial: 1. 2. 3. In the Sources tab, select the stopwatch top-level file. In the Processes tab, right-click the Implement Design process. Select Properties from the right-click menu.
www.xilinx.com
115
The Process Properties dialog box provides access to the Translate, Map, Place and Route, Simulation, and Timing Report properties. You will notice a series of categories, each contains properties for a different aspect of design implementation.
116
www.xilinx.com
Creating Partitions
This option increases the overall effort level of Place and Route during implementation.
Creating Partitions
A partition is created for an instance in your logical design to indicate that the implementation for that instance should be reused when possible. Partitions can be nested hierarchically and be defined on any HDL module instance in the design. In Verilog, the partition is set on the module instance and for VHDL, the partition is set on the entity architecture. A module with multiple instances can have multiple partitionsa partition on each instance. The top level of the HDL design has a default partition. Partitions do not need ranges for implementation re-use, and logic can be at the top level partition. Partitions automatically detect input source changes, including HDL changes and certain constraint changes. Partitions also detect command line changes, such as effort levels on implementation tools, and only the effected partitions are re-implemented. To enable partitions for this design: 1. 2. 3. 4. In the Sources tab, select TIMECNT_1 module and right-click on it. Select New Partition from the menu. Select the LEDCONTROL_1 module. Right-click and select New Partition. The Preserve status is set to inherit, which gets the status from the top level partition. The top level partition is set to routing by default. The preserve status can be changed to Routing, Placement, or Synthesis.
www.xilinx.com
117
118
www.xilinx.com
Input files to the Constraints Editor are: NGD (Native Generic Database) File The NGD file serves as input to the mapper, which then outputs the physical design database, an NCD (Native Circuit Description) file. Corresponding UCF (User Constraint File) By default, when the NGD file is opened, an existing UCF file with the same base name as the NGD file is used. Alternatively, you can specify the name of the UCF file. The Constraints Editor generates a valid UCF file. The Translate step (NGDBuild) uses the UCF file, along with design source netlists, to produce a newer NGD file, which incorporates the changes made. The Map program (the next section in the design flow) then reads the NGD. In this design, the stopwatch.ngd and stopwatch.ucf files are automatically read into the Constraints Editor. In the following section, a PERIOD and TIMEGRP OFFSET IN constraint will be written in the UCF and used during implementation. The Global tab appears in the foreground of the Constraints Editor window. This window automatically displays all the clock nets in your design, and enables you to define the associated period, pad to setup, and clock to pad values. Note that many of the internal names will vary depending on the design flow and synthesis tool used.
www.xilinx.com
119
In the Constraints Editor, edit the constraints as follows: 1. 2. 3. 4. Double-click the Period cell on the row associated with the clock net CLK. The Clock Period dialog box opens. For the Clock Signal Definition, verify that Specific Time is selected. This enables you to define an explicit period for the clock. Enter a value of 20.0 in the Time field. Verify that ns is selected from the Units drop-down list.
120
www.xilinx.com
11. In the Group Name field, type display_grp, and click Create Group to create the group.
www.xilinx.com
121
17. Select File > Save. The changes are now saved in the stopwatch.ucf file in your current working directory. 18. Select File > Exit.
Note: For an EDIF project, double-click Assign Package Pins, located under the User Constraints process.
122
www.xilinx.com
SEG_A E14 SEG_B G13 SEG_C N15 SEG_D P15 SEG_DP P16 SEG_E R16 SEG_F F13 SEG_G N16
www.xilinx.com
123
Figure 5-13: Drag and Drop IOs in the Package Pins View Note: If you are using a third-party synthesis tool, change LOC values for AN<0>, AN<1>, AN<2> and AN<3> to d14, g14, f14, and e13, respectively.
9. Once the pins are locked down, select File > Save. The changes are saved in the stopwatch.ucf file in your current working directory.
124
www.xilinx.com
10. In the Bus Delimiter dialog box, select the XST Defaults and select OK.
Note: If you are using EDIF, this dialog will not appear.
11. To exit PACE, select File > Exit.
Each step generates its own report as shown in the following table.
Map Report
For detailed information on the Map reports, refer to the Development System Reference Guide. This Guide is available All NGDBUILD and with the collection of software manuals and is accessible from ISE by selecting Help > Software Manuals, or from the MAP Reports web at http://www.xilinx.com/support/sw_manuals/xilinx8/.
www.xilinx.com
125
To view a report: 1. 2. Expand the Translate or Map hierarchy. Double-click a report, such as Translation Report or Map Report.
126
www.xilinx.com
3.
To open the Post-Map Static Timing Report, double-click Analyze Post-Map Static Timing Report. Timing Analyzer automatically launches and displays the report.
Even if you do not generate a timing report, PAR still processes a design based on the relationship between the block delays, floors, and timing specifications for the design. For example, if a PERIOD constraint of 8 ns is specified for a path, and there are block delays of 7 ns and unplaced floor net delays of 3 ns, PAR stops and generates an error message. In this example, PAR fails because it determines that the total delay (10 ns) is greater than the constraint placed on the design (8 ns). The Post-Map Static Timing Report will list any pre-PAR timing violations.
www.xilinx.com
127
To review the reports that are generated after the Place & Route process is completed: 2. 3. Click the + next to Place & Route to expand the process hierarchy. Double-click Place & Route Report.
Note: You can also display and examine the Pad Report and Asynchronous Delay Report. Table 5-3: Reports Generated by PAR
Report Place & Route Report Description Provides a device utilization and delay summary. Use this report to verify that the design successfully routed and that all timing constraints were met. Contains a report of the location of the device pins. Use this report to verify that pins locked down were placed in the correct location. Lists all nets in the design and the delays of all loads on the net. For detailed information on the PAR reports, refer to the Development System Reference Guide. This Guide is available with the collection of software manuals and is accessible from ISE by selecting Help > Online Documentation, or from the web at http://www.xilinx.com/support/sw_manuals/xi linx8/.
Pad Report
128
www.xilinx.com
To view the actual design layout of the FPGA: 1. Click the + next to Place & Route to expand the process hierarchy, and double-click View/Edit Routed Design (FPGA Editor).
www.xilinx.com
129
3.
Select the clk_int (Clock) net to see the fanout of the clock net.
The minimum period value increased due to the actual routing delays. After the Map step, logic delay contributed to about 80% of the minimum period attained. The post-layout report indicates that the logical delay value decreased somewhat. The total unplaced floors estimate changed as well. Routing delay after PAR now equals about 31% of the period. The post-layout result does not necessarily follow the 50/50 rule previously described because the worst case path primarily includes component delays. After the design is mapped, block delays constitute about 80% of the period.
130
www.xilinx.com
After place-and-route, the worst case path is mainly made up of logic delay. Since total routing delay makes up only a small percentage of the total path delay spread out across two or three nets, expecting this to be reduced any further is unrealistic. In general, you can reduce excessive block delays and improve design performance by decreasing the number of logic levels in the design. 3. Select File > Exit to close the Timing Analyzer.
If you are using Verilog: On line 56, change the code from mins_cnt <= 0; to mins_cnt <= 1; If you are using VHDL: On line 70, change the code from mins_cnt <= 0000; to mins_cnt <= 0001;
3. 4.
In the Processes tab, right-click on Place & Route. Select Run from the menu. Notice that the implementation is faster with partitions, since the implementation tools only need to re-implement the TIMECNT_1 module. The rest of the design is reused.
5.
Select the Synthesis Report, then select Partitions Report. Notice which partitions were preserved and which partitions were re-used. Select the MAP Report, then select Guide Report. Notice which partitions were preserved and which partitions were re-used. Select the PAR Report, then select Partition Status. Notice which partitions were preserved and which partitions were re-used.
www.xilinx.com
131
Note: You can use CCLK if you are configuring Select Map or Serial Slave.
132
www.xilinx.com
8.
In the Processes tab, double-click Generate Programming File to create a bitstream of this design. The BitGen program creates the bitstream file (in this tutorial, the stopwatch.bit file), which contains the actual configuration data.
9.
Click the + next to Generate Programming File to expand the process hierarchy.
10. To review the Programming File Generation Report, double-click Programming File Generation Report. Verify that the specified options were used when creating the configuration data.
For this tutorial, create a PROM file in iMPACT as follows: 1. 2. 3. In the Processes tab, double-click Generate PROM, ACE, JTAG File, located under the Generated Programming File process hierarchy. In the Welcome to iMPACT dialog box, select Prepare A PROM File. Click Next.
www.xilinx.com
133
4.
In the Prepare PROM Files dialog box, set the following values:
Under I want to target a:, select Xilinx PROM. Under PROM File Format, select MCS. For PROM file name, type stopwatch1.
Note: You will receive a warning that the startup clock is being changed from jtag to CCLK.
10. Click No when you are asked if you would like to add another design file to the datastream.
134
www.xilinx.com
11. When asked to generate a file now, click Yes. iMPACT displays the PROM associated with your bit file. 12. To close iMPACT, select File > Exit. This completes the Design Implementation chapter of the tutorial. For more information on this design flow and implementation methodologies, see the ISE Help, available from the ISE application by selecting Help > Help Topics. With the resulting stopwatch.bit, stopwatch1.mcs and a MSK file generated along with the BIT file, you are ready for programming your device using iMPACT. For more information on programming a device, see the iMPACT Help, available from the iMPACT application by selecting Help > Help Topics.
www.xilinx.com
135
136
www.xilinx.com
Chapter 6
Timing Simulation
This chapter includes the following sections. Overview of Timing Simulation Flow Getting Started Timing Simulation Using ModelSim Timing Simulation Using Xilinx ISE Simulator
Getting Started
The following sections outline the requirements to perform this part of the tutorial flow.
Required Software
To simulate with ModelSim, you must have Xilinx ISE 8.2i and ModelSim simulator installed. Refer to Chapter 4, Behavioral Simulation for information on installing and setting up ModelSim. Simulating with the Xilinx ISE simulator requires that the ISE 8.2i software is installed
www.xilinx.com
137
Required Files
The timing simulation flow requires the following files: Design Files (VHDL or Verilog) This chapter assumes that you have completed Chapter 5, Design Implementation, and thus, have a placed and routed design. The NetGen tool will be used in this chapter to create a simulation netlist from the placed and routed design which will be used to represent the design during the Timing Simulation. Test Bench File (VHDL or Verilog) In order to simulate the design, a test bench is needed to provide stimulus to the design. You should use the same test bench that was used to perform the behavioral simulation. Please refer to the Adding an HDL Test Bench in Chapter 4 if you do not already have a test bench in your project. Xilinx Simulation Libraries For timing simulation, the SIMPRIM library is needed to simulate the design. To perform timing simulation of Xilinx designs in any HDL simulator, the SIMPRIM library must be set up correctly. The timing simulation netlist created by Xilinx is composed entirely of instantiated primitives, which are modeled in the SIMPRIM library. If you completed Chapter 4, Behavioral Simulation, the SIMPRIM library should already be compiled. For more information on compiling and setting up the Xilinx simulation libraries, see to Xilinx Simulation Libraries in Chapter 4.
Specifying a Simulator
To select either the desired simulator to simulate the stopwatch design, complete the following: 1. 2. In the Sources tab, right-click the device line (xc3s200-4ft256) and select Properties. In the Project Properties dialog box click the down arrow in the Simulator value field to display a list of simulators.
Note: ModelSim simulators and the ISE Simulator are the only simulators that are integrated with Project Navigator. Selecting a different simulator (e.g. NC-Sim or VCS) will set the correct options for Netgen to create a simulation netlist for that simulator but Project Navigator will not directly open the simulator.
3. Select ISE Simulator (VHDL/Verilog) or Modelsim with the appropriate version and language in the Simulator value field.
Note: To simulate with the ISE Simulator, skip to Timing Simulation Using Xilinx ISE Simulator. Whether you choose to use the ModelSim simulator or the ISE Simulator for this tutorial, the end result is the same.
138
www.xilinx.com
Note: If the ModelSim Simulator processes do not appear, it means that either ModelSim is not selected as the Simulator in the Project Properties dialog box, or Project Navigator cannot find modelsim.exe.
If ModelSim is installed but the processes are not available, the Project Navigator preferences may not be set correctly. To set the ModelSim location, select Edit > Preferences, click the + next to ISE General to expand the ISE preferences, and click Integrated Tools in the left pane. In the right pane, under Model Tech Simulator, browse to the location of modelsim.exe file. For example,
c:\modeltech_xe\win32xoem\modelsim.exe.
4. 5. 6.
Right-click Simulate Post-Place & Route Model. Select Properties. The Process Properties dialog box displays. Select the Simulation Model Properties category. The properties should appear as shown in Figure 6-1. These properties set the options that NetGen uses when generating the simulation netlist. For a description of each property, click the Help button.
7.
Ensure that you have set the Property display level to Advanced. This global setting enables you to see all available properties.
www.xilinx.com
139
For this tutorial, the default Simulation Model Properties are used.
140
www.xilinx.com
10. In the Simulation Properties tab, set the Simulation Run Time property to 2000 ns.
Performing Simulation
To start the timing simulation, double-click Simulate Post-Place and Route Model in the Processes tab. ISE will run NetGen to create the timing simulation model. ISE will then call ModelSim and create the working directory, compile the source files, load the design, and run the simulation for the time specified.
Note: The majority of this design runs at 100 Hz and would take a significant amount of time to simulate. This is why the counter will seem like it is not working in a short simulation. For the purpose of this tutorial, only the DCM signals will be monitored to verify that they work correctly.
Adding Signals
To view signals during the simulation, you must add them to the Wave window. ISE automatically adds all the top-level ports to the Wave window. Additional signals are displayed in the Signal window based on the selected structure in the Structure window. There are two basic methods for adding signals to the Simulator Wave window. Drag and drop from the Signal/Object window. Highlight signals in the Signal/Object window and then select Add > Wave > Selected Signals.
www.xilinx.com
141
The following procedure explains how to add additional signals in the design hierarchy. In this tutorial, you will be adding the DCM signals to the waveform.
Note: If you are using ModelSim version 6.0 or higher, all the windows are docked by default. All windows can be undocked by clicking the Undock icon.
Figure 6-4 shows the Structure/Instance window for the Verilog flow. The graphics and the layout of the Structure/Instance window for a schematic or VHDL flow may appear different.
142
www.xilinx.com
8.
Click and drag the following signals from the Signal/Object window to the Wave window:
Note: Multiple signals can be selected by holding down the Ctrl key. In place of using the drag and drop method select Add to Wave > Selected Signals.
Adding Dividers
Modelsim has the capability to add dividers in the Wave window to make it easier to differentiate the signals. To add a divider called DCM Signals: 1. 2. 3. 4. 5. Click anywhere in the Wave window. If necessary, undock the window and then maximize the window for a larger view of the waveform. Select Insert > Divider. Enter DCM Signals in the Divider Name box. Click and drag the newly created divider to above the CLKIN signal.
Note: Stretch the first column in the waveform to see the signals clearly. The hierarchy in the signal name can also be turned off by selecting Tools > Options > Wave Preferences. In the Display Signal Path box, enter 2 and click OK.
The waveform should look as shown in Figure 6-5.
www.xilinx.com
143
Notice that the waveforms have not been drawn for the newly added signals. This is because ModelSim did not record the data for these signals. By default, ModelSim will only record data for the signals that have been added to the Wave window while the simulation is running. Therefore, after new signals are added to the Wave window, you need to rerun the simulation for the desired amount of time.
Rerunning Simulation
To restart and re-run the simulation: 1. Click the Restart Simulation icon.
144
www.xilinx.com
To measure the CLK0: 1. 2. 3. 4. Select Add > Cursor twice to place two cursors on the wave view. Click and drag the first cursor to the rising edge transition on the CLK0 signal after the LOCKED signal has gone high. Click and drag the second cursor to a position just right of the first cursor on the CLK0 signal. Click the Find Next Transition icon twice to move the cursor to the next rising edge on the CLK0 signal.
After restarting the simulation, you can select File > Load in the Wave window to reload this file. Your timing simulation is complete and you are ready to program your device by following Chapter 7, iMPACT Tutorial.
www.xilinx.com
145
146
www.xilinx.com
9.
In the Simulation Properties tab, set the Simulation Run Time property to 2000 ns.
Performing Simulation
To start the timing simulation, double-click Simulate Post-Place and Route Model in the Processes tab. When a simulation process is run, Project Navigator automatically runs NetGen to generate a timing simulation model from the placed and routed design. The ISE Simulator will then compile the source files, load the design, and run the simulation for the time specified.
Note: The majority of this design runs at 100 Hz and would take a significant amount of time to simulate. This is why the counter will seem like it is not working in a short simulation. For the purpose of this tutorial, only the DCM signals will be monitored to verify that they work correctly.
Adding Signals
To view signals during the simulation, you must add them to the waveform window. ISE automatically adds all the top-level ports to the waveform window. All available external (top-level ports) and internal signals are displayed in the Sim Hierarchy window.
www.xilinx.com
147
The following procedure explains how to add additional signals in the design hierarchy. In this tutorial, you will be adding the DCM signals to the waveform.
Note: The Xilinx ISE Simulator 8.2 does not include signal search capability. This limitation makes locating internal signals difficult.
1. 2. 3. Select any signal in the Sim Hierarchy window. Press the L key on your keyboard. The signal selection should find the next signal that begins with the letter L. Continue pressing the L key until the LOCKED signal under the X_DCM component is selected.
Figure 6-12 shows the Sim Hierarchy window for the VHDL flow. The signal names and layout in the Sim Hierarchy window for a schematic or VHDL flow may appear different.
148
www.xilinx.com
5.
Click and drag the following X_DCM signals from the SIM Hierarchy window to the waveform window:
Note: Multiple signals can be selected by holding down the Ctrl key.
Note: Stretch the first column in the waveform to see the signals clearly.
The waveform should appear as shown in Figure 6-13.
www.xilinx.com
149
Rerunning Simulation
To restart and re-run the simulation: 1. Click the Restart Simulation icon.
150
www.xilinx.com
3.
Click and drag the second marker to the next rising edge on the CLK0 signal.
Figure 6-16: Adding Timing Markers Note: You may need to Zoom In to place the markers precisely on the clock edge.
View the time value between the two markers to see the distance between the two clock edges. The measurement should read 20.0 ns. This converts to 50 Mhz, which is the input frequency from the testbench, which in turn should be the DCM CLK0 output. Measure CLKFX using the same steps as above. The measurement should read 38.5 ns, this equals approximately 26 Mhz. Your timing simulation is complete and you are ready to program your device by following Chapter 7, iMPACT Tutorial.
www.xilinx.com
151
152
www.xilinx.com
Chapter 7
iMPACT Tutorial
This chapter takes you on a tour of iMPACT, a file generation and device programming tool. iMPACT enables you to program through several parallel cables, including the Platform USB cable. iMPACT can create bit files, System ACE files, PROM files, and SVF/XSVF files. The SVF/XSVF files can be played backed without having to recreate the chain. This tutorial contains the following sections: Device Support Download Cable Support Configuration Mode Support Getting Started Creating a iMPACT New Project File Using Boundary Scan Configuration Mode Troubleshooting Boundary Scan Configuration Creating an SVF File Other Configuration Modes
Device Support
The following devices are supported. Virtex/-E/-II/-II PRO/4/5 Spartan/-II/-IIE/XL/3/3E XC4000/E/L/EX/XL/XLA/XV CoolRunnerXPLA3/-II XC9500/XL/XV XC18V00P XCF00S XCF00P
www.xilinx.com
153
MultiPRO Cable
The MultiPro cable connects to the parallel port and can be used to facilitate Desktop Configuration Mode functionality. For more information, go to http://www.xilinx.com/support, select Documentation > Data Sheets > Configuration Solutions > Configuration Hardware > MultiPRO Desktop Tool.
Getting Started
Generating the Configuration Files
In order to follow this chapter, you must have the following files for the stopwatch design: a BIT filea binary file that contains proprietary header information as well as configuration data. a MCS filean ASCII file that contains PROM configuration information. a MSK filea binary file that contains the same configuration commands as a BIT file, but that has mask data in place of configuration data. This data is not used to configure the device, but is used for verification. If a mask bit is 0, the bit should be verified against the bit stream data. If a mask bit is 1, the bit should not be verified. This file generated along with the BIT file.
154
www.xilinx.com
Getting Started
These files are generated in Chapter 5, Design Implementation. The Stopwatch tutorial projects can be downloaded from http://www.xilinx.com/support/techsup/tutorials/tutorials8.htm. Download the project files for either the VHDL, Verilog or Schematic design flow.
www.xilinx.com
155
This creates a new project file in iMPACT. You are prompted to define the project, as described in the next section.
Note: The selection box also gives you the option to Enter a Boundary Scan Chain, which enables you to then manually add devices to create chain. This option enables you to generate an SVF/XSVF programming file, and is discussed in a later section in this chapter. Automatically detecting and initializing the chain should be performed whenever possible.
156
www.xilinx.com
2.
Click Finish.
iMPACT will pass data through the devices and automatically identify the size and composition of the boundary scan chain. Any supported Xilinx device will be recognized and labeled in iMPACT. Any other device will be labeled as unknown. The software will then highlight each device in the chain and prompt you to assign a configuration file or BSDL file.
Note: If you were not prompted to select a configuration mode or automatic boundary scan mode, right-click in the iMPACT window and select Initialize Chain. The software will identify the chain if the connections to the board are working. Go to Troubleshooting Boundary Scan Configuration if you are having problems.
www.xilinx.com
157
When the software prompts you to select a configuration file for the first device (XC3S200): 1. 2. Select the BIT file from your project working directory. Click Open.
You should receive a warning stating that the startup clock has been changed to JtagClk. 3. Click OK.
Figure 7-4: Selecting a Configuration File Note: If a configuration file is not available, a Boundary Scan Description File (BSDL or BSD) file can be applied instead. The BSDL file provides the software with the necessary Boundary Scan information that allows a subset of the Boundary Scan Operations to be available for that device. To have ISE automatically select a BSDL file (for both Xilinx and non-Xilinx devices), select Bypass in the Assign New Configuration File dialog box.
158
www.xilinx.com
4. 5. 6.
When the software prompts you to select a configuration file for the second device (XCF02S): Select the MCS file from your project working directory. Click Open.
Note: Previous versions of ISE use Configuration Data Files (CDF). These files can still be opened and used in iMPACT. iMPACT Project Files can also be exported to a CDF.
Editing Preferences
To edit the preferences for the Boundary Scan Configuration, select Edit > Preferences. This selection opens the window shown in Figure 7-5. Click Help for a description of the Preferences. In this tutorial, keep the default values and click OK.
www.xilinx.com
159
When you select a device and perform an operation on that device, all other devices in the chain are automatically placed in BYPASS or HIGHZ, depending on your iMPACT Preferences setting. (For more information about Preferences, see Editing Preferences.) To perform an operation, right-click on a device and select one of the options. In this section, you will retrieve the device ID and run the programming option to verify the first device. 1. 2. Right-click on the XC3S200 device. Select Get Device ID from the right-click menu.
160
www.xilinx.com
5.
Select the Verify option. The Verify option enables the device to be readback and compared to the BIT file using the MSK file that was created earlier.
6.
Figure 7-8: Program Options for XC3S200 Device Note: The options available in the Program Options dialog box vary based on the device you have selected.
After clicking OK, the Program operation begins and an operation status window displays. At the same time, the log window reports all of the operations being performed.
www.xilinx.com
161
When the Program operation completes, a large blue message appears showing that programming was successful (see Figure 7-10). This message disappears after a couple of seconds.
162
www.xilinx.com
When a connection is found, the bottom of the iMPACT window will display the type of cable connected, the port attached to the cable, and the cable speed (see Figure 7-11).
www.xilinx.com
163
164
www.xilinx.com
Note: The boundary scan chain that you manually create in the software must match the chain on the board, even if you intend to program only some of the devices. All devices must be represented in the iMPACT window.
www.xilinx.com
165
To write the device ID: 1. 2. Right-click the first device (XC3S200). Select Get Device ID from the right-click menu.
Figure 7-14: SVF File that Gets a Device ID from the First Device in the Chain
166
www.xilinx.com
To write further instructions to the SVF for the second device: 1. 2. Right-click the second device (XCF02S). Select Program from the right-click menu.
The instructions and configuration data needed to program the second device are added to the SVF file.
www.xilinx.com
167
Note: These modes cannot be used with the Spartan-3 Starter Kit.
168
www.xilinx.com