Introduction To VHDL Programming

3y ago
59 Views
6 Downloads
1.82 MB
55 Pages
Last View : 5d ago
Last Download : 3m ago
Upload by : Olive Grimm
Transcription

Introduction to VHDL programmingJuan Antonio ClementeTranslation to the English of the material written by: Marcos Sánchez-Élez(Introducción a la programación en VHDL)November 13, 2014

Contents1Introduction12Basic Elements of VHDL32.1Entity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32.2Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42.3VHDL objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52.4VHDL types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62.4.1Prede ned types62.4.2User-de ned types2.4.3Examples2.4.43. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9Basic Structure of a Source File in VHDL113.1Concurrent statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113.1.1WHEN-ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113.1.2WITH-SELECT-WHEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12Conditional statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133.2.1IF-THEN-ELSE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133.2.2CASE-WHEN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133.2.3FOR-LOOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143.2.4WHILE-LOOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143.24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3.3Process3.4Structural description3.5Examplesstatement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22Simulation of a VHDL Code254.125Steps of simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .i

CONTENTSii54.2Simulation statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4.3Simulation templates in VHDL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2627Description of Sequential Logic315.1Sequential hardware. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .315.2Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345.3Examples37. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5.3.18-bit register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375.3.28-bit register built using 1-bit ip- ops . . . . . . . . . . . . . . . . . . . . . . . . .376Design of a Finite State Machine (FSM)397Functions, Procedures and Packages437.1Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .437.2Procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .447.3Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .448Design of a RAM Memory479Appendixes499.1Discussion about using signals vs. variables. . . . . . . . . . . . . . . . . . . . . . . . . .9.2Discussion about the e ect of incorrectly coding the sensitivity list in aprocess. . . . .4950

Chapter 1IntroductionVHDL is a description language for digital electronic circuits that is used in di erent levels of abstraction.The VHDL acronym stands forLanguage.VHSIC (Very High Speed Integrated Circuits) Hardware DescriptionThis means that VHDL can be used to accelerate the design process.It is very important to point out that VHDL is NOT a programming language. Therefore, knowingits syntax does not necessarily mean being able to designing digital circuits with it. VHDL is an HDL(Hardware Description Language), which allows describing both asynchronous and synchronous circuits.For this purpose, we shall: Think in terms of gates and ip- ops, not in variables or functions. Avoid combinatorial loops and conditional clocks. Know which part of the circuit is combinatorial and which one is sequential.Why to use an HDL? To discover problems and faults in the design before actually implementing it in hardware. The complexity of an electronic system grows exponentially. For this reason, it is very convenientto build a prototype of the circuit previously to its manufacturing process. It makes easy for a team of developers to work together.In particular, VHDL allows not only describing the structure of the circuit (description from moresimple subcircuits), but also the speci cation of the functionality of a circuit using directives, in a similarway as most standard programming languages do.The most important aim of an HDL is to be able to simulate the logical behavior of a circuit by meansof a description language that has many similarities with software description languages.Digital circuits described in VHDL can be simulated using simulation tools that reproduce the operation of the involved circuit. For this purpose, developers use a set of rules standardized by the IEEE,which explain the syntax of the language, as well as how to simulate it.In addition, there are manytools that transform a VHDL code into a downloadable le that can be used to program a recon gurabledevice. This process is namedsynthesis.The way a given tool carries out the synthesis process is veryparticular, and it greatly di ers from what other synthesis tools do.1

Chapter 1. Introduction2For XilinxTM users:TM dex.htmmay include any coding that is speci c from the ollowingbyURL:All the examples in this manual thatTM tool will be highlighted in a box like thisone.TIP: Throughout this manual, boxes like this one will be used to better highlight tips for ane cient programming in VHDL. These tips are a set of basic rules that make the simulation resultsindependent of the programming style. Hence, these rules make the developed code synthesizable,so it can be easily implemented in any platform.Webs and news related to VHDL programming and its simulation and synthesis tools:www.edacafe.com:Web page dedicated to spread news related to the world of circuit design. Ithas a forum of VHDL programming (troubleshooting, free tools .).www.eda.org/vasg/: Welcome to the VHDL Analysis and Standardization Group (VASG). Thepurpose of this web site is to enhance the services and communications between members of the VASGand users of VHDL. We've provided a number of resources here to help you research the current andpast activities of the VASG and report language bugs, LRM ambiguities, and suggest improvements toVHDL."www.cadence.com: Cadence Design Systems is the world's largest supplier of EDA technologiesand engineering services. Cadence helps its customers break through their challenges by providing a newgeneration of electronic design solutions that speed advanced IC and system designs to volume."www.xilinx.com: In the world of digital electronic systems, there are three basic kinds of devices:memory, microprocessors, and logic. Memory devices store random information such as the contents ofa spreadsheet or database. Microprocessors execute software instructions to perform a wide variety oftasks such as running a word processing program or video game. Logic devices provide speci c functions,including device-to-device interfacing, data communication, signal processing, data display, timing andcontrol operations, and almost every other function a system must perform."

Chapter 2Basic Elements of VHDLA digital system is basically described by its inputs and its outputs, as well as how these outputs areobtained from the inputs.The VHDL code of any circuit is divided into two separate parts:entityarchitecture describes theentity. It is also possible toOn the one hand, thespeci es the input and output ports of the circuit. On the other hand, thebehavior of that circuit.Anarchitectureassociate several architectures to the samemust be associated with anentity,so the programmer can select one of the availableones. This point is explained below in Chapter 2, Section 2.3.For XilinxTM users: The IEEE library and the following three packets (whose meaning is explainedbelow) appear by default in any source VHDL code created with the Xilinx13TM ISE tool.l i b r a r y IEEE ;use IEEE . std logic 1164 . a l l ;use i e e e . s t d l o g i c a r i t h . a l l ;use i e e e . std logic unsigned . a l l ;2.1 EntityAnAnentity is an abstraction of a circuit, either from a complexentity externally describes the I/O interface of the circuit.The ports of aninputentityelectronic system or a single logic gate.can be inputs (in), outputs (out), input-outputs (inout) orports can only be read, and they cannot be modi ed inside thehand, theoutputports can only be written, but not read.(for instance, to make a decision about its value) or anIn case aninputbuffer. Thearchitecture. On the otheroutput port needs to be readport needs to be written, they must beinout or a buffer port. However, in this course we will try to avoid these situations,of inout and buffer ports are beyond the learning outcomes of this course.instantiated as anso the utilizationThe interface described by anentity may also include a set of generic values that are used to declarearchitecture. Generics can have multipleproperties and constants of the circuits, independently of itsuses: On the one hand, they can be used to de ne delays in signals and clock cycles (these de nitionswill not be taken into account at the synthesis level, as explained later throughout this manual). On theother hand,genericscan also be used as constants that will be used inside the3architecture.These

Chapter 2. Basic Elements of VHDL4constants help to make the code more understandable, portable and maintainable.length of a register (in number of bits) can be de ned by means of agenericFor instance, theparameter. This meansthat another VHDL code can instantiate this register several times, even if this code instantiates registerswith di erent number of bits.Generic parameters are not necessary. Hence, a circuit that does not needgeneric statement in the entity declaration.them, it simply does not instantiate anyentity of a circuit. This circuit has two N-bit inputsB) and a single output (Y). Thus, in this case the entity description includes a generic statementde ning a parameter named N whose value is set to 8. This parameter is also used in the declaration ofThe example below shows a description of the(A andthe circuit inputs.24entity F isg e n e r i c (N: n a t u r a l : 8) ;port (A, B: i n b i t v e c t o r (N 1 downto 0) ; Y: out b i t ) ;end F ;2.2 Architectureentity-architecture are used in VHDL to completely describe the operation of a circuit. Anarchitecture de nes how the circuit operates, by including a set of inner signals, functions, procedures,The pairsfunctions. and its description can be either structural or behavioral (details about this will be given inChapter 3.4).The code below shows an example of anand theentityarchitecture.architecturearch name of entity name is).The association between thisit refers to is made in the rst line (architectureNext, the code must include the signals, customized types, and components (whose I/O is known) thatwill be used inside thearchitecture.2468101214Thebeginand theenda r c h i t e c t u r e arch name o f entity name i s a r c h i t e c t u r e d e c l a r a t i o n s : types s i g n a l s componentsbegin c o n c u r r e n t statements c o n d i t i o n a l statements componentsp r o c e s s ( s e n s i t i v i t y l i s t ) begin codeend p r o c e s s ;end arch name ;reserved words mark the boundaries of the VHDL code that will actuallydescribe the operation of the circuit. As shown in the example, this code may include: concurrent and

VHDL objects 2.35conditional statements,componentsandprocesses.Chapter 3 will get into deeper details about thesestatements.It is also possible to de ne several architectures for the sameChapter 9, Section?.entity.This is better explained in2.3 VHDL objectsVHDL source codes can include objects. There are three types of objects: Constant:Objects that have an initial value that is assigned before the simulation. This value shallnever be modi ed during the synthesis or the operation of the circuit. They can be declared beforethebeginof anarchitecture,and/or before thebeginof aprocess.A constant declarationMUST assign a value to it.c o n s t a n t i d e n t i f i e r : type : value ; Variable:Objects that take a single value that can change during the simulation/execution bymeans of an assignment statement. Variables are usually used as indexes, mainly in loops, or to takevalues that allow to model other components. Variables DO NOT represent physical connectionsor memory elements. They can be declared before thethebeginof aprocess.beginof anarchitecture,1v a r i a b l e i d e n t i f i e r : type [ : value ] ;The assignment of a value to a variable is done by means of the operator: name variable : value ;i : 1 0 ;1 Signal:and/or beforeA variable declaration MAY or MAY NOT assign a value to it.Objects that represent memory elements or connections between subcircuits. Contrarily toconstants and variables, signals can be synthesized. In other words, a signal in a VHDL source codecan be physically translated into a memory element ( ip- op, register.) in the nal circuit. Theymust be declared before thebeginof thearchitecture.The ports of anentityare implicitlydeclared as signals upon declaration, since they represent physical connections in the circuit.s i g n a l i d e n t i f i e r : type ;The assignment of a value to a signal is done by means of the operator1 name signal value ;A 1 0 ;TIP: If the developed VHDL code only uses constant and signal objects, it will not show anymalign e ect in the operation of the circuit (see Chapter 9, Sections 9.1 and 9.2). In addition, theobtained code will be easily portable to any other tool. For this reason, unless otherwise stated, allthe objects referenced in this manual will be signals.

Chapter 2. Basic Elements of VHDL62.4 VHDL typesIn the previous de nitions, as well as in the de nition of theentityports , it is necessary to de ne thetype of the object. VHDL allows to use prede ned types, as well as other user-de ned ones.2.4.1 Prede ned typesThe most commonly used prede ned types are the following ones: bit:It only admits the values 0 and 1. In order to make an assignment between the object and itsvalue, the latter must be written between single quotes ('0' or'1'). bit vector (range): The range, always written between brackets, indicates the number of bitsof the bit vector, which is an array of 0's and 1's. For an n-bit bit vector, its range must bewritten in the format N-1 downto 0. The bit located to the far left is the most signi cant one(Most Signi cant Bit, or MSB), whereas the bit located to the far right is the least signi cant one(Least Signi cant Bit or LSB). In order to make an assignment between the object and its value,the latter must be written between quotation marks (i.e., boolean:It only can take the values character: string:trueor 0011 ).false.It can take any ASCII value.Any chain consisting of ASCII characters. integer range:Any integer number within thebrackets. For instance, natural range: std logic:Therangerange,range.Any positive number within theAny real number within thewhich in this case is not written betweenis optional.Any natural number within the positive range: real range:0 to MAX.range.Therange.TherangeTherangeis optional.rangeis optional.is optional.Type prede ned in the IEEE 1164 standard. This type represents a multivalued logiccomprising 9 di erent possible values. The most commonly used ones are:impedance ), 'X'(foruninitialized )and'U'(forunde ned ),'0', '1', 'Z'(forhighamong others. In order to make anassignment between the object and its value, the latter must be written between single quotes ('0','1', 'X',.). std logic vector (range):It represents a vector of elements of typeand de nition rules are the same ones as theFor Xilinxstd logicstd logic.Its assignmentones.TM users: For XilinxTM ISE, all the ports of the entity must be of type std logic orstd logic vector.The reason is that these two types allow simulating a circuit realistically. Forinstance, when a signal is instantiated but never initialized in the VHDL code, it will always take'U' (unde ned ) value. In addition, XilinxTM ISE translates natural and integerstd logic vector with the number of bits needed for its complete representation.theIn order to use the typestd logic,it is necessary to include the following library:signals into

VHDL types 2.47use i e e e . std logic 1164 . a l l ;In order to use the pre-de ned arithmetic and logic functions:use i e e e . s t d l o g i c a r i t h . a l l ;1For vectors that are represented as unsigned binary:use i e e e . std logic unsigned . a l l ;1For vectors that are represented as signed binary:use i e e e . std logic unsigned . a l l ;1For vectors that are represented in 2's complement:use i e e e . s t d lo gi c s ig ne d . a l l ;1TIP: It is strongly recommended to always use thestd logic vectoroperations that will be made on the involved objects.thanks to thetype independently of theThey can be used as integers or naturalsieee.std logic arith.all and ieee.std logic unsigned.all libraries. De ningstd logic or std logic vector does not complicate the nal VHDLall the signals in the code asTM ISE.code and helps a los in its integration with Xilinx2.4.2 User-de ned typesAn enumerated type is a data type that comprises a number of user-de ned values. Enumerated typesare used mainly for the de nition of nite state machines.1type name i s ( value1 , value2 , . . . ) ;A has been de ned as an enumerated type, the assignment willvaluei must be one of the enumerated values in the type de nition.Assuming thatvaluei;wherebe as follows:A Enumerated types are sorted according to their values. Typically, synthesis tools automatically codethe enumerated values in such a way that they can fe further synthesized. For that purpose, they usuallyselect an ascending sequence or a coding that minimizes the circuit or that maximizes its operatingfrequency. It may also be possible to directly type the coding by means of ad-hoc directives.A composed type is a data type comprised by elements of other data types. Composed types can beeither arraysAnandarrayrecords.is a data object that comprises a set of elements of the same type.1type name i s array ( range ) o f type ;

Chapter 2. Basic Elements of VHDL8The assignment of a value on a position of thearrayis done by means of integer numbers (seeexamples at Subsection 2.4.3). Arecordis a data object that comprises a set of elements of di erent types.13type name i s r e c o r delement1 : data type1 ;element2 : data type2 ;end r e c o r d ;The assignment of a value on an element from arecordis done by means of a dot (see examplesat Chapter 4, Subsection 4.2.3).Once de ned the composed and/or enumerated data type, any signal in the design can be declared ofbelonging to this new type and this will be done by using the operator de ned for signals .2.4.3 ExamplesThis subsection presents some examples showing how to de ne and to assign values to signals and variables.24681012141618202224262830

VHDL is a description language for digital electronic circuits that is used in di erent levels of abstraction. The VHDL acronym stands for VHSIC (Very High Spdee Integrated Circuits) Hardware Description Language . This means that VHDL can be used to accelerate the design process.

Related Documents:

The VHDL Golden Reference Guide is a compact quick reference guide to the VHDL language, its syntax, semantics, synthesis and application to hardware design. The VHDL Golden Reference Guide is not intended as a replacement for the IEEE Standard VHDL Language Reference Manual. Unlike that document, the Golden Reference guide does not offer a

VHDL/PLD design methodology VHDL is a programming language for designing and modeling digital hardware systems. Using VHDL with electronic design automation (EDA) software tools and user programmable logic devices (PLDs), we can quickly design, verify, and implement a digital system. W

I CIRCUIT DESIGN 1 Introduction 1.1 About VHDL 1.2 Design Flow 1.3 EDA Tools 1.4 Translation of VHDL Code into a Circuit 1.5 Design Examples 2 Code Structure 2.1 Fundamental VHDL Units 2.2 LIBRARY Declarations 2.3 ENTITY 2.4 ARCHITECTURE 2.5 Introductory Examples 2.6 Problems 3 Data Types 3.1 Pre-Defined Data Types

exposed to VHDL modeling of digital circuits, they learn the concepts and non-VHDL design of the digital circuits. Additionally, they spend two hours (or more) per week in the lab to go over the lab assignments and do the lab assignments in which VHDL and FPGAs are used from week 3 through week 10.

Language Reference Manual Cosponsors Design Automation Standards Committee (DASC) of the IEEE Computer Society and Automatic Test Program Generation Subcommittee of the IEEE Standards Coordinating Committee 20 (SCC 20) Approved 30 January 2000 IEEE-SA Standards Board Abstract: VHSIC Hardware Description Language (VHDL) is defined. VHDL is a .

VHDL Retrospective zVHDL is an IEEE and ANSI standard for describing digital systems zCreated in 1981 for the DoD VHSIC program - First version developed by IBM, TI, and Intermetric - First release in 1985 - Standardized in 1987 and revised several times thereafter zStandard 1076, 1076.1 (VHDL-AMS), 1076.2, 1076.3 zStandard 1164, VHDL-2006 - Inherits many characteristics of ADA: Strong .

-1999:V HDL -AMS (Analog & Mixed-Signal Extensions) 1076.2 -1996: StdV .HDL Mathematics Packages 1076.3-1997: Std. VHDL Synthesis Packages 1076.4-1995: Std. VITAL Modeling Specification (VHDL Initiative Towards ASIC Lbri aresi ) 1076.6-1999: Std. for VHDL Register Transfer Level (RTL) Synthesis 1164

AAMI HE75, Human factors engineering – Design of medical devices, Clause 9, Usability Testing, provides an excellent guide to the types of formative evaluations that are useful in early device UI development such as cognitive walkthroughs, heuristic evaluations, and walk-through-talk-through usability tests. Annex D of IEC 62366 also provides descriptions of these formative techniques .