FPGA Prototyping by VHDL Examples - Pong P. Chu - E-Book

FPGA Prototyping by VHDL Examples E-Book

Pong P. Chu

4,5
110,99 €

oder
-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

This book uses a "learn by doing" approach to introduce the concepts and techniques of VHDL and FPGA to designers through a series of hands-on experiments. FPGA Prototyping by VHDL Examples provides a collection of clear, easy-to-follow templates for quick code development; a large number of practical examples to illustrate and reinforce the concepts and design techniques; realistic projects that can be implemented and tested on a Xilinx prototyping board; and a thorough exploration of the Xilinx PicoBlaze soft-core microcontroller.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 414

Veröffentlichungsjahr: 2011

Bewertungen
4,5 (16 Bewertungen)
10
4
2
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



CONTENTS

Preface

Acknowledgments

PART I BASIC DIGITAL CIRCUITS

1 Gate-level combinational circuit

1.1 Introduction

1.2 General description

1.3 Structural description

1.4 Testbench

1.5 Bibliographic notes

1.6 Suggested experiments

2 Overview of FPGA and EDA software

2.1 Introduction

2.2 FPGA

2.3 Overview of the Digilent S3 board

2.4 Development flow

2.5 Overview of the Xilinx ISE project navigator

2.6 Short tutorial on ISE project navigator

2.7 Short tutorial on the ModelSim HDL simulator

2.8 Bibliographic notes

2.9 Suggested experiments

3 RT-Ievel combinational circuit

3.1 Introduction

3.2 RT-level components

3.3 Routing circuit with concurrent assignment statements

3.4 Modeling with a process

3.5 Routing circuit with if and case statements

3.6 Constants and generics

3.7 Design examples

3.8 Bibliographic notes

3.9 Suggested experiments

4 Regular Sequential Circuit

4.1 Introduction

4.2 HDL code of the FF and register

4.3 Simple design examples

4.4 Testbench for sequential circuits

4.5 Case study

4.6 Bibliographic notes

4.7 Suggested experiments

5 FSM

5.1 Introduction

5.2 FSM code development

5.3 Design examples

5.4 Bibliographic notes

5.5 Suggested experiments

6 FSMD

6.1 Introduction

6.2 Code development of an FSMD

6.3 Design examples

6.4 Bibliographic notes

6.5 Suggested experiments

PART II I/O MODULES

7 UART

7.1 Introduction

7.2 DART receiving subsystem

7.3 DART transmitting subsystem

7.4 Overall DART system

7.5 Customizing a DART

7.6 Bibliographic notes

7.7 Suggested experiments

8 PS2 Keyboard

8.1 Introduction

8.2 PS2 receiving subsystem

8.3 PS2 keyboard scan code

8.4 PS2 keyboard interface circuit

8.5 Bibliographic notes

8.6 Suggested experiments

9 PS2 Mouse

9.1 Introduction

9.2 PS2 mouse protocol

9.3 PS2 transmitting subsystem

9.4 Bidirectional PS2 interface

9.5 PS2 mouse interface

9.6 Bibliographic notes

9.7 Suggested experiments

10 External SRAM

10.1 Introduction

10.2 Specification of the IS61LV25616AL SRAM

10.3 Basic memory controller

10.4 A safe design

10.5 More aggressive design

10.6 Bibliographic notes

10.7 Suggested experiments

11 Xilinx Spartan-3 Specific Memory

11.1 Introduction

11.2 Embedded memory of Spartan-3 device

11.3 Method to incorporate memory modules

11.4 HDL templates for memory inference

11.5 Bibliographic notes

11.6 Suggested experiments

12 VGA controller I: graphic

12.1 Introduction

12.2 VGA synchronization

12.3 Overview of the pixel generation circuit

12.4 Graphic generation with an object-mapped scheme

12.5 Graphic generation with a bit-mapped scheme

12.6 Bibliographic notes

12.7 Suggested experiments

13 VGA controller II: text

13.1 Introduction

13.2 Text generation

13.3 Full-screen text display

13.4 The complete pong game

13.5 Bibliographic notes

13.6 Suggested experiments

PART III PICOBLAZE MICROCONTROLLER XILINX SPECIFIC

14 PicoBlaze Overview

14.1 Introduction

14.2 Customized hardware and customized software

14.3 Overview of PicoBlaze

14.4 Development flow

14.5 Instruction set

14.6 Assembler directives

14.7 Bibliographic notes

15 PicoBlaze Assembly Code Development

15.1 Introduction

15.2 Useful code segments

15.3 Subroutine development

15.4 Program development

15.5 Processing of the assembly code

15.6 Syntheses with PicoBlaze

15.7 Bibliographic notes

15.8 Suggested experiments

16 PicoBlaze I/O Interface

16.1 Introduction

16.2 Output port

16.3 Input port

16.4 Square program with a switch and seven-segment LED display interface

16.5 Square program with a combinational multiplier and DART console

16.6 Bibliographic notes

16.7 Suggested experiments

17 PicoBlaze Interrupt Interface

17.1 Introduction

17.2 Interrupt handling in PicoBlaze

17.3 External interface

17.4 Software development considerations

17.5 Design example

17.6 Bibliographic notes

17.7 Suggested experiments

Appendix A: Sample VHDL templates

A.l General VHDL constructs

A.2 Combinational circuits

A.3 Memory Components

A.4 Regular sequential circuits

A.5 FSM

A.6 FSMD

A.7 S3 board constraint file (83. lief)

References

Topic Index

Copyright © 2008 by John Wiley & Sons, Inc. All rights reserved.

Published by John Wiley & Sons, Inc., Hoboken, New Jersey.Published simultaneously in Canada.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 7486008, or online at http://www.wiley.com/go/permission.

Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 5723993 or fax (317) 572-4002.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic format. For information about Wiley products, visit our web site at www.wiley.com.

Library of Congress Cataloging-in-Publication Data:

Chu, Pong P., 1959–FPGA prototyping by VHDL examples/Pong P. Chu.p.cm.Includes bibliographical references and index.ISBN 978-0-470-18531-5 (cloth: alk. paper)1. Field programmable gate arrays-Design and construction. 2. Prototypes, Engineering. 3.VHDL (Computer hardware description language) I. Title.TK7895.G36C485 2008621.39’5-dc222007029063

To my parents, Chia-Chi and Chi-Te, my wife, Lee, and my daughter, Patricia

PREFACE

HDL (hardware description language) and FPGA (field-programmable gate array) devices allow designers to quickly develop and simulate a sophisticated digital circuit, realize it on a prototyping device, and verify operation of the physical implementation. As these technologies mature, they have become mainstream practice. We can now use a PC and an inexpensive FPGA prototyping board to construct a complex and sophisticated digital system. This book uses a “learning by doing” approach and illustrates the FPGA and HDL development and design process by a series of examples. A wide range of examples is included, from a simple gate-level circuit to an embedded system with an 8-bit soft-core microcontroller and customized I/O peripherals. All examples can be synthesized and physically tested on a prototyping board.

Focus and audience

Focus The main focus of this book is on the effective derivation of hardware, not the syntax of HDL. Instead of explaining every language construct, the book is limited to a small synthesizable subset and uses about a dozen code templates to provide the skeletons of various types of circuits. These templates are general and can easily be integrated to construct a large, complex system. Although this approach limits the “freedom” of syntactic expression, it will not prevent us from developing innovative hardware architecture. Because of the generality and flexibility of HDL, the same circuit can usually be described by a wide variety of language constructs and coding styles. Many of these codes are intended for modeling. They may lead to unnecessarily complex hardware implementation and sometimes cannot be synthesized at all. The template approach actually forces us to think more about hardware and develop a good coding practice for synthesis. Since we are more interested in hardware, it is more beneficial to spend time on developing 10 different hardware architectures with the same code template rather than describing the same circuit with 10 different versions of codes.

There are two popular HDLs, VHDL and Verilog. Both languages are used widely and are IEEE standards. This book uses VHDL, and a separate book with a similar title uses Verilog. Despite the drastic syntactic differences in the two languages, their capabilities are very similar, particularly for our purposes. After we comprehend the design practice and coding methodology in one language, learning the other language is rather straightforward.

Although the book is intended for beginning designers, the examples follow strict design guidelines and prepare readers for future endeavors. The coding and design practice is “forward compatible,” which means that:

The same practice can be applied to large design in the future.The same practice can aid other system development tasks, including simulation, timing analysis, verification, and testing.The same practice can be applied to ASIC technology and different types of FPGA devices.The code can be accepted by synthesis software from different vendors.

In summary, the book is a hands-on, hardware-centric text that involves minimal HDL overhead and follows good design and coding practice to achieve maximal forward comparability.

Audience and perquisites The book contains three major parts: basic digital circuits, peripheral modules, and embedded microcontroller. The intended audience is students in an introductory or advanced digital system design course as well as practicing engineers who wish to learn FPGA-and HDL-based development. For the materials in the first two parts, readers need to have a basic knowledge of digital systems, usually a required course in electrical engineering and computer engineering curricula. For the materials in the third part, prior exposure to assembly language programming will be helpful.

Logistics

Although a major goal of this book is to teach readers to develop software-independent and device-neutral HDL codes, we have to choose a software package and a prototyping board to synthesize and implement the design examples. The synthesis software and FPGA devices from Xilinx, a leading manufacture in this area, are used in the book.

Software The synthesis software used in the book is the Web version of the Xilinx ISE package. The functionality is of this version is similar to that of the full version but supports only a limited number of devices. Most introductory development boards use FPGA devices from the inexpensive Spartan-3 family. Since the Web version supports the Spartan-3 device, it fits our need. The simulation software used in the book is the starter version of Mentor Graphics’ ModelSim XE III package. It is a customized edition of ModelSim. Both software packages are free and can be downloaded from Xilinx’s Web site.

FPGA prototyping board This book is prepared to be used with several entry-level FPGA prototyping boards manufactured by Digilent Inc., including the Spartan-3 Starter, Nexys-2, and Basys boards, all of which contain a Spartan-3/3E FPGA device and have similar I/O peripherals. The design examples in the book are based on the Spartan-3 Starter board (or simply the S3 board), but most of them can be used directly in other boards as well. The applicability of the HDL codes is summarized below.

Spartan-3 Starter 3 (S3) board. The S3 board contains all the peripherals and no additional accessory module is needed. All HDL codes and discussions can be applied to this board directly.Nexys-2 board. The Nexys-2 board is a newer board, which contains a larger FPGA device and a larger memory chip. Its peripherals are similar to those in the 53 board. There are two differences. First, the “color depth” of its VGA interface is expanded from 3 bits to 8 bits. The the output of the VGA interface circuits discussed in Chapters 12 and 13 needs to be modified accordingly. Second, it contains a more sophisticated external memory device. Although the device can be configured as an asynchronous SRAM, the timing characteristics is different from that of the S3 board’s memory device, and thus the HDL codes for the memory controller in Chapter 10 cannot be used directly. However, the same design principle can be applied to construct a new controller.Basys board. The Basys board is a simpler board. It lacks the RS-232 connector. To implement the DART module and the serial interface discussed in Chapter 7, we need Digilent’s RS-232 converter peripheral module. The Basys board has no external memory devices, and thus the discussion of the memory controller in Chapter 10 is not applicable.Other FPGA boards. Most peripherals discussed in this book are de facto industrial standards, and the corresponding HDL codes can be used as long as a board provides proper analog interface circuits and connectors. Except for the Xilinx-specific portions, the codes can be applied to the boards based on the FPGA devices from other manufacturers as well.

PC Accessories The design examples include interfaces to several PC peripheral devices. A keyboard, a mouse, and a VGA monitor are required for the respective modules, and a “straight-through” serial cable (the most commonly used type) is required for the DART module. These accessories are widely available and can probably be obtained from an old PC.

Book organization

The book is divided into three major parts. Part I introduces the elementary HDL constructs and their hardware counterparts, and demonstrates the construction of a basic digital circuit with these constructs. It consists of six chapters:

Chapter 1 describes the skeleton of an HDL program, basic language syntax, and logical operators. Gate-level combinational circuits are derived with these language constructs.Chapter 2 provides an overview of an FPGA device, prototyping board, and development flow. The development process is demonstrated by a tutorial on Xilinx ISE synthesis software and a tutorial on Mentor Graphics ModelSim simulation software.Chapter 3 introduces HDL’s relational and arithmetic operators and routing constructs. These correspond to medium-sized components, such as comparators, adders, and multiplexers. Module-level combinational circuits are derived with these language constructs.Chapter 4 covers the codes for memory elements and the construction of “regular” sequential circuits, such as counters and shift registers, in which the state transitions exhibit a regular pattern.Chapter 5 discusses the construction of a finite state machine (FSM), which is a sequential circuit whose state transitions do not exhibit a simple, regular pattern.Chapter 6 presents the construction of an FSM with data path (FSMO). The FSMO is used to implement register transfer (RT) methodology, in which the system operation is described by data transfers and manipulations among registers.

Part II applies the techniques from Part I to design an array of peripheral modules for the prototyping board. Each chapter covers the development, implementation, and verification of an individual peripheral. These modules can be incorporated to a larger project. Part II consists of seven chapters:

Chapter 7 discusses the design of a universal asynchronous receiver and transmitter (VART), which provides a serial link to receive and transmit data via the prototyping board’s RS-232 port.Chapter 8 covers the design of a keyboard interface, which reads scan code from a keyboard. The keyboard is connected via the prototyping board’s PS2 port.Chapter 9 covers the design of a mouse interface, which obtains the button and movement information from a mouse. The mouse is also connected via the prototyping board’s PS2 port.Chapter 10 discusses the implementation and timing issues of a memory controller. The controller is used to read data from and write data to the two static random access memory (SRAM) devices on the S3 board.Chapter 11 discusses the inference and application of Spartan-3 device-specific components. The focus is on the FPGA’s internal memory blocks and the digital clock management (OCM) circuit.Chapter 12 presents the design and implementation of a video controller. The discussion covers the generation of video synchronization signals and shows the construction of simple bit-and object-mapped graphical interface. The monitor is connected to the prototyping board’s VGA port.Chapter 13 continues development of the video controller. The discussion illustrates the construction of text interface and general tile-mapped scheme.

Part III introduces an FPGA-based soft-core microcontroller, known as Picolilaze, and demonstrates the integration of a general-purpose processor and customized circuit. It includes four chapters:

Chapter 14 provides an overview of the organization and instruction set of PicoBlaze.Chapter 15 introduces the basic assembly programming and provides an overview of the development process.Chapter 16 discusses PicoBlaze’s I/O feature and illustrates the procedure to derive customized circuits to interface other I/O peripherals.Chapter 17 discusses PicoBlaze’s interrupt capability and demonstrates the construction of a customized interrupt-handling circuit.

In addition to regular chapters, the appendix summarizes and lists all code templates.

Special marksXilinx specific While the examples of this book are implemented on a Xilinx-based prototyping board and the codes are synthesized by Xilinx ISE software, we try to make the HDL codes device-independent and software-neutral as much as possible. Most discussions and codes can be applied to different target devices and different synthesis software as well. However, certain codes or device features are unique to Xilinx ISE software or Spartan-3 FPGA devices. We use the Xilinx specific superscript, as in the heading of this section, to indicate that the discussion in the corresponding section or chapter is unique to Xilinx.

Similarly, we use marginal notes, such as the one shown on the outer edge, to indicate that the discussion in the paragraph is unique to Xilinx. This note indicates that the code or design is no longer portable and needs to be revised when a different software package or target device is used.

Instructional use

The book can be a good companion text for an introductory digital systems course or an advanced project-oriented course. In an introductory digital systems course, the book supplies the lab portion of the curriculum. The chapters in Part I basically follow the sequence of a typical curriculum and can be presented along with regular lectures. One or two peripheral modules can be selected as case studies, and corresponding experiments can be used as term projects.

In an advanced project-oriented course, the book provides a base for independent projects. The materials in Part I should be treated as an overview or refresher, which provides a general background on HDL, synthesis, and FPGA boards. Some modules in Part II can be used to demonstrate the design of more complex circuits. These modules can also be considered as building blocks (i.e., IPs) or subsystems to be integrated into final projects. The PicoBlaze microcontroller in Part III can be used as general-purpose processor if an embedded-system type of project is desired.

Companion Web site

An accompanying Web site (http://academic.csuohio.edu/chu_p/rtl) provides additional information, including the following materials:

ErrataCode templatesHDL code listing and relevant filesLinks to synthesis and simulation softwareLinks to referenced materialsAdditional project ideas

Errata The book is self-prepared, which means that the author has produced all aspects of the text, including illustrations, tables, code listings, indexing, and formatting. As errors are always bound to happen, the accompanying Web site provides an updated errata sheet and a place to report errors.

P. P. CHU

Cleveland, OhioOctober 2007

ACKNOWLEDGMENTS

The author would like to express his gratitude to Professor George L. Kramerich for his encouragement and help.

The author also thanks John Wiley & Sons, Inc. for giving permission to use Figures 3.1, 3.2, 4.2, 4.10, 4.11, and 6.5 from my text RTL Hardware Design Using VHDL: Coding for Efficiency, Portability, and Scalability, and Xilinx, Inc. for giving permission to use Figures 2.3 and 8.3 from the Spartan-3 Starter Kit Board User Guide.

All trademarks used or referred to in this book are the property of their respective owners.

P. P. Chu

PART I BASIC DIGITAL CIRCUITS

CHAPTER 1

GATE-LEVEL COMBINATIONAL CIRCUIT

1.1 INTRODUCTION

VHDL stands for VHSIC (very high-speed integrated circuit) hardware description language. It was originally sponsored by the U.S. Department of Defense and later transferred to the IEEE (Institute of Electrical and Electronics Engineers). The language is formally defined by IEEE Standard 1076. The standard was ratified in 1987 (referred to as VHDL 87), and revised several times. This book mainly follows the revision in 1993 (referred to as VHDL93).

VHDL is intended for describing and modeling a digital system at various levels and is an extremely complex language. The focus of this book is on hardware design rather than the language. Instead of covering every aspect ofVHDL, we introduce the key VHDL synthesis constructs by examining a collection of examples. Detailed VHDL coverage may be explored through the sources listed in the Bibliography.

In this chapter, we use a simple comparator to illustrate the skeleton of a VHDL program. The description uses only logical operators and represents a gate-level combinational circuit, which is composed of simple logic gates. In Chapter 3, we cover the more sophisticated VHDL operators and constructs and examine module-level combinational circuits, which are composed of intermediate-sized components, such as adders, comparators, and multiplexers.

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!