vhdl basics1

64
VHDL BASICS By T V S RAM Email: [email protected] [email protected]  

Upload: kishan-prajapati

Post on 06-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 1/64

VHDL BASICS

ByT V S RAM

Email: [email protected]

[email protected] 

Page 2: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 2/64

VHDL BASICS

VHDL(VHSIC) It is very high speed integratedcircuit hardware descriptive language.

What for it is used?

Used to model digital system.What are its characterstics?

It is case- in sensitive, means Ram,RAM rAM allequal it VHDL.

-- is used for comments.

language is similar to ADA,

If you know C++ or PASCAL it is easy.

Page 3: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 3/64

VHDL Basics

what it is ?

It is a hardware description language that can be

used to model a digital system at many levels of abstraction language, ranging from algorithm

level to gate level.

Page 4: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 4/64

VHDL BASICS

What It has?

It has an amalgamation of 

.sequential language.concurrent language

.net-list language

.timing specifications.waveform generation language

Page 5: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 5/64

VHDL HISTORY

What is its History?

DOD of USA had started in 1981.

They thought that it could act asmedium for information

Exchange between chip foundries andCAD tool operations.

Because of Defence it was keptclassified till 1985.

Page 6: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 6/64

VHDL HISTORY

Then lot of private industry participatedfor development of this language

In 1985 DOD had granted permission tohand over to spec to IEEE.

IEEE released the number as IEEE

1076 /A. standard in dec 1987.IEEE revised in 1993.

Page 7: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 7/64

VHDL IS CUNNING

Advantage of this language is

Same language is used for analysis andsynthesis

But, Be careful, some are only simulatableand not synthesisable.

Pl, Note

At the present moment, what can besynthesizable is very vague, and much aretool Dependable. 

Page 8: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 8/64

VHDL IS CUNNING

Still IEEE is worming on a synthesisablesubset of VHDL which will be supplied

by all the Synthesis vendors. 

Page 9: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 9/64

VHDL CAPABILITIES

It is a language, hence it can be used as anexchange medium between chip vendors andCAD tool users.

Means, chip vendors can provide VHDLdescriptions of their components to systemdesigners. CAD tool users can use them tocapture the behavior of the design at a high

level of abstraction for function simulation.

Page 10: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 10/64

VHDL CAPABILITIES

It supports hierarchy,

A Digital system can be modelled as a set of

interconnected components, eachcomponents in turn can be modelled as someof interconnection subcomponents.

Simillar to other languages this also supports

flexible design methrodologies top-downbottom - up or mixed.

Page 11: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 11/64

VHDL CAPABILITIES

It is a Language hence it can also beused as a common medium between

different CAD and CAE tools. Eg:.Schematic capture program may beused to generate a VHDL descriptionfor the design, which can be used as aninput to a simulation program.

It supports hierarchy,

Page 12: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 12/64

VHDL CAPABILITIES

A Digital system can be modeled as a set ofinterconnected components, eachcomponents in turn can be modeled as someof interconnection sub-components.

Similar to other languages this also supportsflexible design methodologies top-down

bottom - up or mixed.The language is not technology specific 

Page 13: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 13/64

VHDL CAPABILITIES

but is capable of supporting technologyspecific feature, supports various handwaretechnology. Eg: You may define new logictypes and new components. You can alsomodel technology dependent components.

By being technology independent the same

model can be synthesized in to differentvendor libraries.

Page 14: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 14/64

VHDL CAPABILITIES

Supports both synchronous andasynchronous timing models.

You can use, FSMs, state tables, algorithm

descriptions, Boolean, wave form entry, etc,Nowadays the new tools like VISUAL HDL

are available using them even flowchart,block level, also can be used as design entry.

It is similar to English language.

Page 15: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 15/64

VHDL SUPPORTS

.structural,

.data-flow,

.behavior

A combination of all the three alsopossible.

Wide range of abstraction levels fromabstract behavior description to veryprecise gate level.

But, below transistor level not possible.

Page 16: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 16/64

VHDL SUPPORTS

It has elements, that make large scaledesign modeling easier.

HOW?

Using this you can create

components, functions, procedures,

and packages, test benches,

you can model Propagation delay, Min-max delay, setup and hold time etc., 

Page 17: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 17/64

VHDL SUPPORTS

One can use generics, and attributeswhich are useful in describing

paramaterised model.

Page 18: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 18/64

digital systemeg:

micro processor

int lines,

control bus

add bus

data bus

aludevice

entity

external view

acculator

deviceentity

memorydevice

entity

inthandlingdeviceentity

architecutre

2

architecture1

only 1architecture

only 1architecture

architecture2

architecture3

architecture

1

Page 19: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 19/64

VHDL Terminology

Digital system can be as simple as logic

gate to complex system.

Hardware abstraction of this system calledentity ( component) .

An entity X when used in entity Y becomes

a component for the entity Y.

Page 20: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 20/64

VHDL Terminology

VHDL provides five different types of 

primary constructs, called design units

1. Entity declaration2. Architecture body

3. Configuration Delcaration

4. Package declaration

5. Package body

Page 21: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 21/64

VHDL Terminology

Entity E1 Entity E2

Entity E3

E3_A1 E3_A2 E3_A3

M1:...

E2_A1 E2_A2

E1_A3E1_A2E1_A1

BX:... CX:...

   B   I   N   D

   I   N  G

Page 22: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 22/64

Once an entity is modeled,it needs to be

analyzed and finally it has to be simulated.

Then we can say a component is created.So Next step is analyzer and simulator

analyzer reads in one or more design units

contained in a single file and compiles theminto a design library after validating syntax

VHDL Analyzer

Page 23: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 23/64

VHDL Analyzer

and performing some static semantic

checks. This design library is your library,

means your project library.design library is a place in the host

environment where compiled design units

are stored.

Page 24: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 24/64

VHDL Simulator

The simulator simulates

entity

we know that each “entity” is represented by an “entity-architecture” pair or by a

configuration, by reading in its compiled

description from the design library and thenperforming the following steps.

Page 25: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 25/64

VHDL Simulator

Elaboration

initialization

simulation

Page 26: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 26/64

Entity

Entity declaration specifies the name of the

design ( component) being modeled and the

set of interface ports.Ports are signals through which entity

communicates with the other models in its

external environment.

Page 27: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 27/64

Entity Example

x1

A1

sum

carry

A

B

-- start of entity

entity HALF_ADDER is

-- port declaration starts

port(A,B:inBIT;SUM,CARRY:out BIT);

--port declaration ends

end HALF_ADDER;

--end of entity declaration

Page 28: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 28/64

VHDL Architecture Body

What does architecture does?

It describes the internal details of an entity.

How it does?

Using any of the following modeling styles:

A set of interconnected components ( to

represent structure)

Page 29: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 29/64

VHDL Architecture Body

A set of concurrent assignment statements(

to represent dataflow)

A set of sequential assignments ( torepresent behavior)

As any combination of the above three.

Page 30: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 30/64

VHDL Structural style

Here entity is described as a set of 

interconnected component. Example for

Half_adder is

Page 31: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 31/64

VHDL Structural style example

architecture HA_STRUCTURE of HALF_ADDER is

component xor2

port (in1,in2: in Bit; o1:out BIT);

end component;

component AND2

port (X,Y: in Bit; Z:out BIT);

end component;begin

u1: xor2 portmap(HAPPY1,HAPPY2,ALLHAPPY);

U2: and2 portmap ( sad1,sad2,allsad);

end HA_Structure;

Page 32: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 32/64

VHDL Structural style

HA_STRUCTURE is the name of the architecture.

HALF_ADDER is an entity

BEGIN and END are key words used to say start

and end of the architecture.

The two components xor2,and2 are declared in the

declarative part of the architecture body.

Between Begin and End is the statement part.

Page 33: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 33/64

VHDL Structural style

Where these xor2, and and2 exists?

They may be predefined components in a

library or, if they do not exist, they maylater be bound to other components in alibrary.

The declared components are instantiated in

the statement part of the architecture bodyusing component instantiation statements.

Page 34: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 34/64

VHDL Structural style

U1, u2 are components labels for the

components.

Signals in the port map of a componentinstantiation and the port signals in the port

map of a component instantiation and the

port signals in the component declarationare associated by position (called positional

association.

Page 35: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 35/64

VHDL Structural style

The structural representation for the

HALF_ADDER does not say anything

about its functionality. Separate entitymodels would be described for the

compoenents xor2 and and2, each having its

own entity declaration and architecture

body.

Page 36: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 36/64

VHDL Data Flow style

Here the flow of data through the entity is

expressed primarily using concurrent signal

assignment statements. The structure of theentity is not explicitly specified in this

modeling style, but it can be implicitly

deduced. Look at this example.

Page 37: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 37/64

VHDL Structural style

architecture HA_CONCURRENT of 

HALF_ADDER is

beginsum <= A xor B after 8 ns;-- concurrent stat

Carry <= A and B after 4 ns ;-- concurrent

stat end HA_CONCURRENT;

Page 38: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 38/64

VHDL Structural style

The data flow model for the HALF_ADDER is

described using two concurrent signal assignment

statements.

In a signal assignment statement, the symbol <=

implies an assignment of a value to a signal. The

value of the expression on the right hand side of 

the statement is computed and is assigned to thesignal on the left hand side, called target signal.

Page 39: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 39/64

VHDL Structural style

Remember, a concurrent signal assignment

statement is executed only when any signal used

in the expression on the right hand side has an

event on it that is, the value for the signal changes.

Concurrent signal assignment statements are

concurrent statements, the ordering of these

statements in an architecture body is not important

Page 40: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 40/64

VHDL Structural style

“After” clauses needed to incorporate the delay. 

Here both signal assignments statements execute

concurrently.

Means, here we have two signals

Signal A or B, which are input port signals of our

Half_Adder, It has an event, say at time T,

 

Page 41: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 41/64

VHDL Structural style

the right hand side expressions of both

signal assignment statements are evaluated

Signal SUM is scheduled to get the newvalue after 8 ns.

while signal CARRY is scheduled to get the

new value after 4 ns. CARRY will get its

new value,and when simulation time

advances to (T+8)ns, SUM will get its new

value.

Page 42: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 42/64

VHDL Structural style

The after clause may be used to generate a

clock signal

clk <= not CLK after 10ns;this statement creates a periodic waveform

on the signal CLK with a time period of 20

ns,

CLK

10 20 30 40 50 60 70

Page 43: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 43/64

VHDL Behavioral style

This modeling is in contrast to earlier

modelings.

The behavioral style modeling specifies thebehavior of an entity as a set of statements

that are executed sequentially in the

specified order. This set of sequential

statements, which are specified inside a

process statement, do not explicitly specify

Page 44: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 44/64

Page 45: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 45/64

VHDL Behavioral style

Page 46: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 46/64

VHDL Behavioral style

A process statement also has a declarative part(before keyword begin) and statement part (between the keyword begin and end process). Thestatements appearing within the statement part aresequential statements and are executedsequentially. The list of signals specified withinthe parentheses after the keyword processconstitutes a sensitivity list, and the process

statement is invoked whenever there is an event onany

Page 47: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 47/64

VHDL Behavioral style

signal in this list. In the previous example when

an event occurs on signals A, B, or Enable, the

statements appearing within the process statement

are executed sequentially.

Variables declared in the processes have their

scope limited to that process. Variables can also

be declared in sub programs. It is possible to use case or loop statements within

a process.

Page 48: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 48/64

VHDL process

We can use case, loop etc within process.

Normally they are similar as C or pascal.

An explicit wait statement can also be usedto suspend a process. It can be used to wait

for a certain amount of time, until a certain

condition becomes true, or until an event

occurs on one or more signals.

Page 49: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 49/64

 

Eg: process

begin

  clk <= „0‟;wait for 20 ns; 

  clk <= „1‟;wait for 12 ns; 

end process;

0 20 32 52 64 84 96

clk

Page 50: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 50/64

VHDL process

This process does not sensitivity list pl. observe

the code.

Because explicit wait statements are present inside

the process. It is important to remember that a

process never terminates. It is always either being

executed or in suspended state. All processes are

executed once during the initialization phase of simulation until they get suspended. 

Page 51: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 51/64

VHDL process

A process with no sensitivity list and no

explicit wait statement will never suspend

itself.Eg: of DFF.

Entity DFF IS

Port (Q:out BIT; D,clk: in BIT);End DFF;

Page 52: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 52/64

VHDL process

 Architecture DFF_beh of DFF is

Begin

Process ( D,clk)

Begin

If clk = '1' then

Q <= D;

End if; End process;

End Dff_beh;

Page 53: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 53/64

VHDL process

This process executes whever there is an even

on signal D or CLK. If the value of CLK is '1' ,

the value of D is assigned to Q. If CLK is '0',then no assignment to Q takes place. Thus, as

long as CLK is '1' any change on D will appear 

on Q. Once clk becomes '0', the value in Q is

retained.

Page 54: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 54/64

VHDL Mixed style modeling

Within architecture All three can be mixed.

Ie.,

we can use component instantiation(structure)

concurrent signal assignments(dataflow)

process statements ( behavior).

Page 55: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 55/64

VHDL FULL ADDER MIXEDEntity FA isPort ( a,b,cin:in bit; sum,cout:out bit);End FAArchitecture FA_mixed of FA isComponent xor2

Port(p1,p2:in bit; pz :out BIT);End component;Signal s1:bit;

BeginX1:xor2 portmap (A,B,S1); -- - structureProcess ( A,B,CIN) -- - behavior Variable t1,t2,t3:bit;Begin

T1 := A and B;T2 := B and cin;T3 := a and cin;

Cout <= t1 or t2 or t3;End process;Sum <= s1 xor cin; -- -- dataflowEnd FA;

Page 56: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 56/64

EXAMPLE FOR MIXED

MODELINGx1

A

B

x1CIN

SUM

BEHAVIOR

CARRY

This FA is done with one component instantiation

one process statement ,

one concurrent signal assignment.Note all these statements are concurrent statements.

Therefore their order of appearance within the architecture

body is not important.

Page 57: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 57/64

 

This is done using one component instantiation

one process statement and ond concurrent

signal assignment. Note all these statementsare concurrent statements. Therefore their order 

of appearance within the architecture body is not

important.

Page 58: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 58/64

VHDL configuration

declaration

As discussed earlier, an entity can consists

of any no of architectures but, while

compilation only one architecture should bethere. This can be dictated by configuration

file .

So, a configuration is used to select one of 

the possiblly many architecture bodies that

an entity may, have, and to bind coponents,

Page 59: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 59/64

VHDL configuration

declaration

Used to represent structure in that architecture

body, to entities represented by an entity-

architecture pair or by a configuration which

reside in a design library, 

eg:

Page 60: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 60/64

VHDL configuration

declarationLibrary cmos_lib,my_lib; -- - library clause both library visible in configurationConfiguration Ha_binding of half_adder is - -configuration name Ha_binding and specifies

For ha_structure -- specifies that the architecture body it has two components-- threfore two configuration. X1 repesents entity architecture pair,

For x1:xor2 -- - xor gate and dataflow architecture which resides com_lib-- - design library.

Use entity cmos_lib.xor_gate(dataflow);End for;For A1:and2 -- similarly for and2 also.

Use configuration My_lib,and_config;End for;

End for;

End Ha_binding;

Page 61: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 61/64

Package declaration

  A package declaration is used to store a set of commondeclarations such as components,types, procedures, andfunctions. These declarations can then be imported into other design units using a "use" clause.

Package ex_traffic_light is ---- name of package it has type,component, function

 see that int2bit_Vec does not appear in thepackage

 -- only interface appears,Type color is (red,green,yello);

Component D_myFFPort (D,CK: in bit; Q :out BIT); End component;

Constant pin2pin_delay :time := 125ns;Function int2bit_vec ( int_value:integer)

Return bit_vector;

End ex_traffic_light;

Page 62: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 62/64

Package declaration

Used to store the definitions of functions and procedures thatwere declared in the corresponding package declaration, andalso the complete constant declarations for any declarationsof any deferred constants that appear in the packagedeclaration.Package body is always associated with package declaration.Package declaration can have at most one package bodyassociated with it. Contrast this with an architecture body andan entity declaration, where multiple architecture bodies maybe associated wit a single entity declaration

Page 63: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 63/64

Package declaration

Package body exam_pack is - - name of the package is same aspackage declarations

Function int2bit_vec ( int_value:integer)Return bit_vector is

Begin - -behavior of function described here.

End int2bit_vec;End exam_pack;

THANK YOU ALL

Page 64: vhdl basics1

8/2/2019 vhdl basics1

http://slidepdf.com/reader/full/vhdl-basics1 64/64

THANK YOU ALL

SIRS You Need Not Read Heavy Books

 Just refer them

 Just Practice,

It makes you Perfect

 Wish you 

all the Best.