ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i...

52
SACP - José Miguel Vieira dos Santos - V2005 1 VHDL Linguagem para Síntese de Circuitos Digitais José Miguel Vieira dos Santos

Transcript of ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i...

Page 1: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

051

VH

DL

Lin

guag

em p

ara

Sín

tese

de C

ircu

itos

Dig

itai

s

José

Mig

uel V

ieir

a do

s S

anto

s

Page 2: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

052

VH

DL

•L

ingu

agem

de

prog

ram

ação

que

per

mite

:–

Sin

tetiz

ar d

escr

içõe

s de

cir

cuito

s di

gita

is–

Doc

umen

tar

circ

uito

s–

Sim

ular

cir

cuito

s

•H

isto

rial

–V

ery

Hig

h S

peed

Int

egra

ted

Cir

cuits

(V

HS

IC)

- 19

80

–V

HSI

C H

ardw

are

Des

crip

tion

Lan

guag

e (V

HD

L)

-198

x

–N

orm

a IE

EE

: 107

6 e

1164

(19

87-R

1993

)

•B

iblio

graf

ia:

–“T

he D

esig

ner's

Gui

de to

VH

DL

”, P

eter

J. A

shen

den,

Mor

gan

Kau

fman

n P

ublis

hers

, IS

BN

1-5

5860

-270

-4

Page 3: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

053

Sín

tese

•S

ínte

se é

a r

ealiz

ação

de

desc

riçõ

es d

e ci

rcui

tos

–i.e

. a c

riaç

ão d

e um

cir

cuito

.

•V

HD

L p

erm

ite

sint

etiz

ar c

ircu

itos

a 2

níve

is–

Est

rutu

ral-

esq

uem

átic

o ( ≈

grá

fico

)

–C

ompo

rtam

enta

l- f

unci

onal

, abs

trac

to (

alt

o-n

ível

)•

Inde

pend

ente

dos

cir

cuito

s ló

gico

s

•Pa

rtic

ular

men

te ú

til p

ara

CPL

D/F

PG

A

•U

m c

ircu

ito é

des

crito

em

VH

DL

por

:–

En

tity

- d

escr

eve

o co

mpo

nent

e co

mo

enti

dade

(pe

rife

ria)

–A

rch

itec

ture

- d

escr

eve

o co

nteú

do (

funç

ão, i

nter

ior)

Page 4: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

054

Ex.

1: C

ompa

rado

r de

4 b

its

-- C

OM

P4

é um

com

p de

4 b

its

En

tity

CO

MP

4 is

Por

t (

a, b

: in

bit_

vect

or (

3 d

ownt

o 0

) ;

igua

l: ou

t bit

) ;

En

d C

OM

P4;

Arc

hit

ectu

re E

stru

t_C

4 of

CO

MP

4 is

Beg

in igua

l <=

‘1’

whe

n (a

= b

) el

se ‘

0’;

--

Log

pos

itiv

a (a

ctiv

a/1)

En

d E

stru

t_C

4

Page 5: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

055

Ent

ity

•D

escr

eve

a “c

aixa

” (o

s pi

nos)

•A

info

rmaç

ão é

tran

spor

tada

por

SIG

NA

LS

–C

ada

Sig

nal é

dec

lara

do c

om u

m ti

po (

Typ

e)

–P

orts

são

cas

os p

artic

ular

es d

e S

igna

ls

•P

ort

s -

cada

con

exão

ao

exte

rior

é u

m P

ort,

e te

m:

–N

ome

- ún

ico

(den

tro)

–L

ista

de

prop

ried

ades

•M

OD

E -

iden

tific

a a

dire

cção

(in

, out

, bid

)

•T

YP

E -

iden

tifi

ca o

s va

lore

s qu

e o

Port

pod

e as

sum

ir (

0, 1

, Z, e

tc)

–E

m r

egra

, um

Por

t cor

resp

onde

a u

m p

ino

(ou

grup

o de

)

Page 6: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

056

Por

ts -

pro

prie

dade

s

•O

s M

OD

E p

odem

ser

4:

–IN

- e

ntra

ape

nas

–O

UT

- a

pena

s sa

i

–IN

OU

T -

bid

irec

cion

al

–B

UF

FE

R -

sai

e é

tam

bém

rea

limen

tado

par

a o

inte

rior

•T

ypes

–B

IT -

pod

e to

mar

os

valo

res

0 e

1

–B

it-V

ecto

r -

grup

o de

bits

, cad

a um

pod

endo

ser

0 o

u 1.

–In

tege

r -

inte

iros

, útil

par

a co

ntag

ens,

dec

isõe

s de

flu

xo

–B

olea

n -

pode

tom

ar v

alor

es T

RU

E o

u FA

LS

E

–E

num

erat

ed -

pod

e se

r de

fini

do p

elo

utili

zado

r.

Page 7: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

057

IEE

E 1

076

TY

PE

S•

Ex:

SIGNAL

a: BIT_VECTOR(0 TO 3); -- e.g. ascending range

SIGNAL

b: BIT_VECTOR(3 DOWNTO 0); -- e.g. descending range

a <= "0101";

b <= "0101";

Equivalente a:

a(0) = '0'; a(1) = '1'; a(2) = '0'; a(3) = '1';

b(0) = '1'; b(1) = '0'; b(2) = '1'; b(3) = '0';

•V

HD

L é

um

a lin

guag

em r

estr

itiv

a–

stro

ngly

typ

ed l

anguage

•U

m s

igna

l não

pod

e se

r lig

ado/

atri

buíd

o a

outr

o si

gnal

de

type

dif

eren

te

Page 8: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

058

IEE

E 1

164

TY

PE

S

•O

sta

nda

rd l

og

ic p

ack

age d

efin

e 9

type

–U

nre

solv

ed_lo

gic

TY

PE

std

_ulo

gic

IS (

‘U

’,--

Uni

nitia

lised

‘X’,

-- F

orci

ng U

nkno

wn

‘0’,

-- F

orci

ng 0

‘1’,

-- F

orci

ng 1

‘Z’,

-- H

igh

Impe

danc

e‘W

’,--

Wea

k U

nkno

wn

‘L’,

-- W

eak

0‘H

’,--

Wea

k 1

‘-’

-- D

on’t

car

e

);

Page 9: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

059

IEE

E 1

164

TY

PE

S (

cont

.)•

Os

segu

inte

s ty

pes

deri

vam

de

std_

ulog

ic:

–st

d_ul

ogic

_vec

tor

•G

rupo

de

sina

is s

td_u

logi

c

–st

d_lo

gic

•A

ver

são

“res

olvi

da”/

defi

nida

de

std_

ulog

ic

•R

esol

ução

: def

ine

caso

de

sina

is a

limen

tado

s po

r m

ais

que

1 sa

ída

–st

d_lo

gic_

vect

or•

Gru

po d

e st

d_lo

gic

•V

HD

L é

inde

pend

ente

dos

car

acte

res

M/m

(ca

se i

nd

ep/)

Page 10: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0510

Exe

mpl

o2 -

Ent

idad

e•

Des

criç

ão V

HD

L d

e um

a “b

lack

-box

”:

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY black_box IS PORT (

clk, rst:

IN

std_logic;

d:

IN std_logic_vector(7 DOWNTO 0);

q:

OUTstd_logic_vector(7 DOWNTO 0);

co:

OUT std_logic);

END black_box;

BL

AC

K_B

OX

rst

d[7

:0]

clk

q[7

:0]

co

MO

DE

TY

PE

Page 11: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0511

Exe

mpl

o 5

•E

scre

va u

ma

enti

ty d

ecla

rati

on p

ara

o ci

rcui

to in

dica

do:

Por

t D is

a 1

2-bi

t bus

, inp

ut o

nly

Por

t OE

and

CL

K a

re e

ach

inpu

t bit

sP

ort A

D is

a 1

2-bi

t, th

ree-

stat

e bi

dire

ctio

nal b

usP

ort A

is a

12-

bit b

us, o

utpu

t onl

yP

ort I

NT

is a

thre

e-st

ate

outp

utP

ort A

S is

an

outp

ut a

lso

used

inte

rnal

ly

Cir

cu

ito

_a

d[1

1:0

]

oe

clk

ad

[11

:0]

a[1

1:0

]

int

as

Page 12: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0512

Exe

mpl

o.5

- so

luçã

o

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY

Cir

cuito_

a IS PORT (

d:

IN std_logic_vector(11 DOWNTO 0);

oe, clk:IN std_logic;

ad:

INOUT std_logic_vector(11 DOWNTO 0);

a:

OUT std_logic_vector(11 DOWNTO 0);

int:

OUT std_logic;

as:

BUFFER std_logic);

END

Cir

cuito_

a ;

-- Palavras reservadas a bold.

-- VHDL não distingue m/M

-- (not case sensitive)

-- clock, Clock, CLOCK são

-- o mesmo signal

Cir

cu

ito

_a

d[1

1:0

]

oe

clk

ad

[11

:0]

a[1

1:0

]

int

as

Page 13: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0513

Exe

mpl

o 6

•E

scre

ver

a enti

ty d

ecla

rati

on p

ara

o se

guin

te:

Por

t EN

, LD

and

CL

K a

re in

put o

nly

Por

t A is

a 4

-bit

bus,

inpu

t onl

yP

ort W

is a

n ou

tput

onl

yP

ort X

is a

12-

bit t

hree

-sta

te b

idir

ectio

nal b

usP

ort Y

is a

n ou

tput

that

is a

lso

used

inte

rnal

lyP

ort Z

is a

thre

e-st

ate

outp

utC

irc

_e

x1

en

a[3

:0]

ld clk

w

x[1

1:0

] y z

Page 14: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0514

Exe

mpl

o 6:

Sol

ução

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY

Cir

c_ex1 IS PORT (

clk, ld, en:

IN std_logic;

a:

IN std_logic_vector(3 DOWNTO 0);

w:

OUT std_logic;

x:

INOUT std_logic_vector(11 DOWNTO 0);

y:

BUFFER std_logic;

z:

OUT std_logic);

END

Cir

c_ex1 ;

en

a[3

:0]

ld clk

w

x[1

1:0

] y z

Page 15: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0515

Dec

lara

ção

de P

orts

•T

er e

m c

onta

a le

gibi

lidad

e; o

rigi

nalm

ente

lógi

ca d

iscr

eta

•M

OD

E–

Por

def

eito

: IN

–N

ão li

gar

dois

OU

T

–B

UF

FE

R s

emel

hant

e a

OU

T•

Obr

iga

a us

ar s

aída

s qu

e pe

rmit

am r

eali

men

taçã

o (i

nter

na)

•T

odas

nas

Alt

era

3064

, 712

8 e

10K

XX

. Úti

l par

a co

ntad

ores

.

–B

UF

FE

R n

ão p

erm

ite b

idir

ecci

onal

idad

e (n

o V

HD

L o

rigi

nal)

•T

em d

e se

r ut

iliz

ada

nos

dois

sen

tido

s

–IN

OU

T p

ode

subs

titui

r B

UFF

ER

em

toda

s as

dec

lara

ções

•Im

pede

opt

imiz

ação

de

recu

rsos

e d

ific

ulta

leit

ura.

•T

YP

E–

std_

ulog

ic; s

td_l

ogic

; arr

ays

(vec

tore

s)

Page 16: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0516

Sta

ndar

d V

HD

L o

pera

tors

•L

ogic

al -

def

ined

for

type

ST

D_L

OG

IC, S

TD

_LO

GIC

_VE

CT

OR

, B

OO

LE

AN

–A

ND

–O

R–

XO

R–

NO

T

•R

elat

iona

l - d

efin

ed f

or ty

pes

STD

_LO

GIC

,

S

TD

_LO

GIC

_VE

CT

OR

, IN

TE

GE

R–

=

(equ

al to

)–

/=(n

ot e

qual

to)

–<

(les

s th

an)

–<

=(l

ess

than

or

equa

l to)

–>

(gre

ater

than

)–

>=

(gre

ater

than

or

equa

l to)

Page 17: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0517

Sta

ndar

d V

HD

L o

pera

tors

(co

nt.)

•U

nary

Ari

thm

etic

- d

efin

ed f

or ty

pe IN

TE

GE

R

-(a

rith

met

ic n

egat

e)

•A

rith

met

ic -

def

ined

for

type

INT

EG

ER

, ST

D_L

OG

IC

+(a

ddit

ion)

-(s

ubtr

actio

n)

•C

onca

tena

tion

-de

fine

d fo

r ty

pes

ST

RIN

G

& ST

RIN

G is

any

seq

uenc

e of

cha

ract

ers

–B

IT_V

EC

TO

R is

an

exam

ple

of a

ST

RIN

G

Page 18: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0518

VH

DL

: Ope

rado

res

Lóg

icos

•O

pera

dore

s ló

gico

s nã

o tê

m p

rece

dênc

ia

•A

or

B a

nd C

-- o

rigi

na e

rro

•S

ão n

eces

sári

os p

arên

tesi

s–

A o

r (B

and

C)

–(A

or

B)

and

C

Page 19: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0519

Arc

hite

ctur

e

•A

Arc

hite

ctur

e é

asso

ciad

a a

uma

Ent

ity

•V

HD

L p

erm

ite

2 es

tilos

de

desc

riçã

o fu

ncio

nal

–S

tru

ctu

ral -

est

rutu

ral,

desc

reve

a e

stru

tura

inte

rna

da “

caix

a”•

Ten

de a

rec

orre

r ao

s co

mpo

nent

es ló

gico

s, li

gaçõ

es, b

loco

s

–B

ehavio

ral -

com

port

amen

tal,

enun

cia

func

iona

men

to e

sper

ado

•Fo

rma

algo

rítm

ica,

abs

trac

ta.

•E

vita

lida

r co

m o

s co

mpo

nent

es

•M

ais

com

pact

a

•M

ais

legí

vel

•M

elho

r po

rtab

ilida

de

–P

erm

ite

com

bin

açã

o d

os

esti

los

•E

x:•

Abs

trac

t (“h

igh-

leve

l”)

desc

ript

ions

IF a = b THEN state <= state5;

•B

oole

an e

quat

ions

x <= (a OR b) AND c;

Page 20: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0520

Ex7

: Com

p-4

bits

- F

luxo

de

dado

s

•F

luxo

de

dado

s (R

TL

ou

Dat

a-fl

ow)

EN

TIT

Y c

omp4

IS

PO

RT

(a, b

:IN

BIT

_VE

CT

OR

(3

DO

WN

TO

0);

igua

l:O

UT

BIT

);

EN

D c

omp4

;

AR

CH

ITE

CT

UR

E c

4_df

OF

com

p4 I

S

BE

GIN ig

ual <

= “

1” W

HE

N (

a=b)

EL

SE “

0”;

-- ig

uald

ade

activ

a “i

gual

EN

D c

4_df

;

Page 21: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0521

Ex8

: Com

p-4b

- to

dos

esta

dos

defi

nido

s

EN

TIT

Y c

omp4

IS

PO

RT

(a,

b:I

NST

D_L

OG

IC_V

EC

TO

R (

3 D

OW

NT

O 0

);

igua

l:O

UT

STD

_LO

GIC

);

EN

D c

omp4

;

AR

CH

ITE

CT

UR

E c

4_de

talh

e O

F c

omp4

IS

BE

GIN

com

p: P

RO

CE

SS (

a, b

)B

EG

IN IF a

=b

TH

EN

igua

l <=

“1”

;

EL

SEig

ual <

= “

0;

-- to

dos

os c

ompo

rtam

ento

s es

peci

fica

dos

EN

D I

F;

EN

D P

RO

CE

SS

com

p;

EN

D c

4_de

talh

e;

Page 22: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0522

Ex9

: Com

p-4b

- v

alor

por

def

eito

EN

TIT

Y c

omp4

IS

POR

T (

a, b

:IN

ST

D_L

OG

IC_V

EC

TO

R (

3 D

OW

NT

O 0

);

igua

l:O

UT

ST

D_L

OG

IC )

;

EN

D c

omp4

;

AR

CH

ITE

CT

UR

E c

4_at

rib

OF

com

p4 I

S

BE

GIN

com

p: P

RO

CE

SS (

a, b

)

BE

GIN ig

ual <

= “

0 ;

-- a

trib

uiçã

o po

r de

feito

; loc

aliz

ação

ríg

ida

IF a

=b

TH

EN

igua

l <=

“1”

;

EN

D I

F;

EN

D P

RO

CE

SS

com

p;

EN

D c

4_at

rib

;

Page 23: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0523

Pro

cess

: exe

mpl

o

•E

xam

ple

of s

tate

men

ts w

ithin

a P

roce

ss:

mux: PROCESS (a, b, s)

BEGIN

IF s = '0' THEN

x <= a;

ELSE

x <= b;

END IF;

END PROCESS mux;

µT

he lo

gic

with

in a

pro

cess

can

be

regi

ster

ed o

r co

mbi

nato

rial

x(3 DOWNTO 0)

s

a(3 DOWNTO 0)

b(3 DOWNTO 0)

Page 24: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0524

VH

DL

: pro

cess

amen

to te

mpo

ral

•D

ois

tipos

de

“sta

tem

ents

” -

esse

ncia

lmen

te p

ara

sim

ulaç

ão

•S

equ

enti

al

–S

tate

men

ts w

ith

in a

pro

cess

are

“se

quen

tial s

tate

men

ts”

• a

nd e

valu

ate

sequ

entia

lly in

term

s of

sim

ulat

ion

•C

on

curr

ent

–S

tate

men

ts o

uts

ide

of

a p

roce

ss e

valu

ate

“con

curr

ently

” (e

m //

)

=>

mor

e th

an o

ne p

roce

ss c

an b

e “a

ctiv

e” a

t any

giv

en ti

me

–A

ctiv

e pr

oces

ses

are

eval

uate

d co

ncur

rent

ly

–E

x:in

c <

= ‘

0’in

c <

= ‘

1’

Page 25: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0525

Pro

cess

os: a

trib

uiçã

o se

quen

cial

•E

x:in

c <

= ‘

0’in

c <

= ‘

1’

•F

ora

de P

roce

ss–

Se

type

bit:

err

o na

sín

tese

•S

e ty

pe s

td_l

ogic

–in

c <

= ‘

X’

para

sim

ulaç

ão

–E

rro

para

sín

tese

•D

entr

o de

Pro

cess

–S

e ty

pe b

it:in

c =

‘1’

Page 26: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0526

Con

curr

ent s

tate

men

ts

•C

oncu

rren

t sta

tem

ents

incl

ude

–bo

olea

n eq

uati

ons

–co

nditi

onal

ass

ignm

ents

(i.e

., w

hen.

..els

e...)

–in

stan

tiat

ions

-- Examples of boolean equations

x <= (a AND (NOT sel1)) OR (b AND sel1);

g(0) <= NOT (y AND sel2);

-- Examples of conditional assignments

y <= d WHEN (sel1 = '1') ELSE c;

g(1) <= '0' WHEN (x = '1' AND sel2 = '0') ELSE '1';

-- Example of instantiation

inst1: mand GENERIC MAP (1, 2) PORT MAP (g, h);

inst2: minv GENERIC MAP (1) PORT MAP (h, f);

Page 27: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0527

Seq

uent

ial s

tate

men

ts: T

he P

roce

ss

•S

tate

men

ts w

ithin

a p

roce

ss a

re e

valu

ated

seq

uent

ially

–in

term

s of

sim

ulat

ion

•A

Pro

cess

can

be

eith

er a

ctiv

e (a

wak

e) o

r in

act

ive (

asle

ep)

•A

Pro

cess

typi

cally

has

a s

ensi

tivit

y l

ist

–ex

: PROCESS (clock, enable)

–N

orm

ally

ass

yncr

onou

s si

gnal

s

–U

sual

ly d

etec

t tra

nsiti

ons

(clk

’eve

nt)

–W

hen

a si

gnal

in th

e se

nsiti

vity

list

cha

nges

val

ue, t

he p

roce

ss b

ecom

es a

ctiv

e

•A

ll si

gnal

ass

ignm

ents

occ

ur a

t EN

D P

RO

CE

SS

sta

tem

ent

–in

term

s of

sim

ulat

ion

time

–T

he P

roce

ss th

en b

ecom

es in

activ

e

Page 28: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0528

Con

trol

o de

pro

gram

a

•C

ontr

olo

de f

luxo

–W

ITH

- S

EL

EC

T-

WH

EN

–W

HE

N -

EL

SE

(E

LS

IF)

•D

ecis

ões

–If

-TH

EN

-EL

SE

–C

AS

E-W

HE

N

Page 29: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0529

Ex1

0: C

ontr

olo

flux

o- W

ITH

-SE

LE

CT

-WH

EN

EN

TIT

Y s

elsi

g IS

PO

RT

( d

0, d

1, d

2, d

3: I

N S

TD

_LO

GIC

;

s: I

N I

NT

EG

ER

RA

NG

E 0

TO

3;

outp

ut: O

UT

ST

D_L

OG

IC )

;

EN

D s

elsi

g;

AR

CH

ITE

CT

UR

E m

axpl

d O

F s

elsi

g IS

BE

GIN

WIT

H s

SE

LE

CT

-- c

ria

mux

4-1

outp

ut <

=d0

WH

EN

0,

d1 W

HE

N 1

,

d2 W

HE

N 2

,

d3 W

HE

N 3

;

EN

D m

axpl

d;

Page 30: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0530

Ex1

1: D

esco

difi

cado

r B

CD

-7se

g: E

ntid

ade

•--

file

: dec

oder

.vhd

•--

•L

IBR

AR

Y ie

ee;

•U

SE

ieee

.std

_log

ic_1

164.

AL

L;

•E

NT

ITY

dec

oder

IS

PO

RT

(

dig

it: I

N s

td_l

ogic

_vec

tor(

3 D

OW

NT

O 0

);

leds

: OU

T s

td_l

ogic

_vec

tor(

7 D

OW

NT

O 0

));

•E

ND

dec

oder

;

Page 31: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0531

EX

11: D

ecod

.BC

D-7

seg

- A

rqui

tect

ura

AR

CH

ITE

CT

UR

E a

rchd

ecod

er O

F d

ecod

er I

SB

EG

IN--

7 s

egm

ent d

ispl

ay d

ecod

er, t

he s

egm

ent o

rder

is a

,b,c

,d,e

,f,g

,dp

d

ec:P

RO

CE

SS

(di

git)

BE

GIN

C

AS

E d

igit

IS

WH

EN

"00

00"

=>

leds

<=

"11

1111

00";

WH

EN

"00

01"

=>

leds

<=

"01

1000

00";

WH

EN

"00

10"

=>

leds

<=

"11

0110

10";

WH

EN

"00

11"

=>

leds

<=

"11

1100

00";

WH

EN

"01

00"

=>

leds

<=

"01

1001

10";

WH

EN

"01

01"

=>

leds

<=

"10

1101

10";

WH

EN

"01

10"

=>

leds

<=

"10

1111

10";

WH

EN

"01

11"

=>

leds

<=

"11

1000

00";

WH

EN

"10

00"

=>

leds

<=

"11

1111

10";

WH

EN

"10

01"

=>

leds

<=

"11

1001

10";

WH

EN

"10

10"

=>

leds

<=

"11

1011

10";

W

HE

N "

1011

" =

> le

ds <

= "

0011

1110

";W

HE

N "

1100

" =

> le

ds <

= "

1001

1100

";

WH

EN

"11

01"

=>

leds

<=

"01

1110

10";

WH

EN

"11

10"

=>

leds

<=

"10

0111

10";

W

HE

N "

1111

" =

> le

ds <

= "

1000

1110

";W

HE

N O

TH

ER

S =

> le

ds <

= "

----

----

";

EN

D C

AS

E;

E

ND

PR

OC

ES

S d

ec;

EN

D a

rchd

ecod

er;

Page 32: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0532

Ex1

2: C

omp4

- A

rch.

Beh

avio

ral

-- C

OM

P4

é um

com

p de

4 b

itsE

nti

ty C

OM

P4 i

s Po

rt (

a, b

: in

std_

logi

c_ve

ctor

(3

dow

nto

0) ;

igua

l: o

ut s

td_l

ogic

) ;

En

d C

OM

P4;

Arc

hit

ectu

re C

ompo

rt_C

4 of

CO

MP

4 is

Beg

in com

p: p

roce

ss (

a,b)

begi

n if a

=b

then

igua

l <=

‘1’

else ig

ual <

= ‘

0’;

end

if;

end

proc

ess

com

p;E

nd

Com

port

_C4

-- C

OM

P4

é um

com

p de

4 b

its

En

tity

CO

MP

4 is

Por

t (

a, b

: in

bit_

vect

or (

3 d

ownt

o 0

) ;

igua

l: o

ut b

it )

;

En

d C

OM

P4;

Arc

hit

ectu

re E

stru

t_C

4 of

CO

MP

4 is

Beg

in igua

l <=

‘1’

whe

n (a

= b

) el

se ‘

0’;

--

Log

pos

itiva

En

d E

stru

t_C

4

Page 33: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0533

Pro

ject

o co

m R

egis

tos

•H

á do

is m

étod

os d

e cr

iar

flip

-flo

ps–

Inst

anci

ar (

defi

nir,

dec

lara

r) o

flip

-flo

p•

Ou

outr

o co

mpo

nent

e qu

e co

nten

ha o

flip

-flo

p

–U

sar

um p

roce

sso

sens

ível

à tr

ansi

ção

(edg

e) d

o cl

ock

q

clockd

Page 34: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0534

FF

act

ivo

por

níve

l CL

K (

Lat

ch)

EN

TIT

Y r

egin

f IS

PO

RT

(

d, c

lk, [

clr,

pre

, loa

d, d

ata]

: IN

ST

D_L

OG

IC;

q: O

UT

ST

D_L

OG

IC )

;

EN

D r

egin

f;

-- R

egis

to c

om C

lock

act

ivo-

a-1

PR

OC

ES

S

BE

GIN

W

AIT

UN

TIL

clk

= '1

';

q

<=

d;

EN

D P

RO

CE

SS

;

-- R

egis

to c

om C

lock

act

ivo-

a-0

PR

OC

ES

S

BE

GIN

W

AIT

UN

TIL

clk

= '0

';

q

<=

d;

EN

D P

RO

CE

SS

;

q

clkd

Page 35: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0535

Ex1

3: F

F -

D

(des

criç

ão c

ompo

rtam

enta

l)LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY registo1 IS PORT (

d, clock:

IN std_logic;

q:

OUT std_logic);

END registered;

ARCHTECTURE arc_reg OF registo1 IS

BEGIN ff1: PROCESS (clock)

BEGIN

IF clock'EVENT AND clock = '1’

--

veri

fica

noTHEN

q <= d;

--

flan

co a

scen

dent

eEND IF;

END PROCESS ff1;

END arc_reg;

Page 36: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0536

Ex1

4: C

onta

dor

AR

CH

ITE

CT

UR

E a

OF

cou

nter

s IS

BE

GIN

-- E

na

ble

cou

nte

r

PR

OC

ESS

(cl

k)

VA

RIA

BL

Ecn

t : I

NT

EG

ER

RA

NG

E 0

TO

255

;

BE

GIN IF

(cl

k'E

VE

NT

AN

D c

lk =

'1')

TH

EN

IF e

nabl

e =

'1' T

HE

Ncn

t :=

cnt

+ 1

;

EN

D I

F;

EN

D I

F;

qa<

= c

nt;

EN

D P

RO

CE

SS;

Page 37: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0537

Ex1

5: S

ynch

rono

us c

lear

cou

nter

PR

OC

ESS

(cl

k)

VA

RIA

BL

Ecn

t: I

NT

EG

ER

RA

NG

E 0

TO

255

;

BE

GIN IF

(cl

k'E

VE

NT

AN

D c

lk =

'1')

TH

EN

IF c

lear

= '0

' TH

EN

cnt :

= 0

;

EL

SE cn

t :=

cnt

+ 1

;

EN

D I

F;

EN

D I

F;

qc<

=cn

t;

EN

D P

RO

CE

SS;

Page 38: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0538

Ex1

6: S

ynch

rono

us lo

ad c

ount

erP

RO

CE

SS (

clk)

VA

RIA

BL

Ecn

t: I

NT

EG

ER

RA

NG

E 0

TO

255

;

BE

GIN IF

(cl

k'E

VE

NT

AN

D c

lk =

'1')

TH

EN

IF ld

= '0

' TH

EN

cnt :

= d

;

EL

SE cn

t :=

cnt

+ 1

;

EN

D I

F;

EN

D I

F;

qb<

=cn

t;

EN

D P

RO

CE

SS;

Page 39: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0539

Ex1

7: U

p/do

wn

coun

ter

PRO

CE

SS

(clk

)

VA

RIA

BL

Ecn

t: I

NT

EG

ER

RA

NG

E 0

TO

255

;

VA

RIA

BL

Edi

rect

ion

: IN

TE

GE

R;

BE

GIN IF

(up

_dow

n =

'1')

TH

EN

dire

ctio

n :=

1;

EL

SE di

rect

ion

:= -

1;

EN

D I

F;

IF (

clk'

EV

EN

T A

ND

clk

= '1

') T

HE

N

cnt :

= c

nt +

dir

ectio

n;

EN

D I

F;

qd<

=cn

t;

EN

D P

RO

CE

SS;

Page 40: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0540

Ex1

8: C

onta

dor

Up-

Loa

d 4b

itslib

rary

ieee

;

use

ieee

.std

_log

ic_1

164.

all;

entit

y co

un

ter

is p

ort(

clk,

res

et, l

oad:

in s

td_l

ogic

;

data

:in

std

_log

ic_v

ecto

r(3

dow

nto

0);

coun

t:bu

ffer

std

_log

ic_v

ecto

r(3

dow

nto

0));

end

coun

ter;

use

wor

k.st

d_ar

ith.a

ll;arc

hit

ectu

re a

rch

cou

nte

r of

cou

nte

r is

begi

nup

coun

t: pr

oces

s (c

lk)

begi

nif

(cl

k'ev

ent a

nd c

lk=

'1')

then

if lo

ad =

'1' t

hen

coun

t <=

dat

a;el

seco

unt <

= c

ount

+ 1

;en

d if

;en

d if

;en

d pr

oces

s up

coun

t;en

d ar

chco

unte

r;

Page 41: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0541

Ex1

9: S

ynch

rono

us lo

ad e

nabl

e co

unte

rP

RO

CE

SS (

clk)

VA

RIA

BL

Ecn

t: I

NT

EG

ER

RA

NG

E 0

TO

255

;

BE

GIN IF

(cl

k'E

VE

NT

AN

D c

lk =

'1')

TH

EN

IF ld

= '0

' TH

EN

cnt :

= d

;

EL

SE IF

ena

ble

= '1

' TH

EN

cnt :

= c

nt +

1;

EN

D I

F;

EN

D I

F;

EN

D I

F;

qe<

=cn

t;

EN

D P

RO

CE

SS;

Page 42: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0542

Ex2

0: E

nabl

e up

/dow

n co

unte

rPR

OC

ES

S (c

lk)

VA

RIA

BL

Ecn

t: I

NT

EG

ER

RA

NG

E 0

TO

255

;

VA

RIA

BL

Edi

rect

ion

: IN

TE

GE

R;

BE

GIN IF

(up

_dow

n =

'1')

TH

EN

dire

ctio

n :=

1;

EL

SE di

rect

ion

:= -

1;

EN

D I

F;

IF (

clk'

EV

EN

T A

ND

clk

= '1

') T

HE

N

IF e

nabl

e =

'1' T

HE

Ncn

t :=

cnt

+ d

irec

tion

;

EN

D I

F;

EN

D I

F;

qf<

=

cnt;

EN

D P

RO

CE

SS;

Page 43: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0543

VH

DL

- R

esum

o•

VH

SIC

* H

ardw

are

Des

crip

tion

Lan

guag

e–

Ver

y H

ard

Dif

ficu

lt L

anguage

–L

ingu

agem

mod

ular

de

prog

ram

ação

em

alto

nív

el

•P

ode

ser

cria

da c

om q

ualq

uer

edit

or d

e te

xto

–E

dito

r do

MA

X+

PL

US

II

sens

ível

ao

cont

exto

e u

sa c

ores

•V

HD

L D

esig

n F

iles

(*.v

hd)

com

sin

taxe

s 19

87 o

u de

199

3

•V

HD

L D

esig

n F

iles

perm

item

pro

gram

ar o

s U

PL

D–

Dep

ois

de c

ompi

lada

s, s

imul

adas

e d

epur

adas

*- V

ery H

igh S

pee

d I

nte

gra

ted C

ircu

it

Page 44: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0544

Mod

os d

e es

crit

a:

•V

HD

L n

ão d

istin

gue

mod

os–

Tod

as a

s de

clar

açõe

s le

gais

são

trat

adas

•O

pro

ject

ista

pod

e ut

iliza

r o

que

for

mai

s co

nven

ient

e

•D

escr

içõe

s:–

Est

rutu

rais

: lóg

icas

–C

ompo

rtam

enta

is: m

aior

abs

trac

ção

e po

rtab

ilid

ade

•R

TL

: Reg

iste

r T

rans

fer

Lev

el

Page 45: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0545

Sín

tese

e S

imul

ação

•S

ínte

se =

Pro

ject

ar (

Des

igni

ng)

•S

imul

ação

= M

odel

ar (

Mod

ellin

g)

•C

ódig

o pa

ra p

roje

cto

é se

mpr

e si

mul

ável

–In

vers

o nã

o é

verd

ade

•A

lgum

as d

irec

tiva

s te

mpo

rais

ou

de s

eque

ncia

men

to n

ão s

ão a

plic

ávei

s.

–C

ompi

lado

r ig

nora

-as

na s

ínte

se•

Res

ulta

do g

loba

l pod

e nã

o se

r o

dese

jado

(te

mpo

s de

sim

ulaç

ão d

ifer

ente

s re

ais)

Ex:

AR

CH

ITE

CT

UR

E m

odel

o1 O

F 2

_gat

es I

Sx

<=

a A

ND

b A

FT

ER

5ns

;

y <

= N

OT

b;

EN

D m

odel

o1;

Page 46: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0546

RA

M (

e R

OM

)•

Impl

emen

tada

nas

FL

EX

10K

a p

artir

da

libra

ria

para

met

riza

da (

LP

M=

Lib

. of

Par

amet

rize

Mod

ules

)–

Dep

ende

ntes

da

tecn

olog

ia

–E

scal

ávei

s (p

aram

etri

záve

is)

•N

outr

as f

amíl

ias

util

izar

FF

(D

)

•A

s L

PM

são

con

stru

ídas

com

meg

afun

ctio

ns

Page 47: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0547

Meg

afun

ções

par

a R

AM

/RO

M n

o M

P2

•N

ome

Des

criç

ão

•lp

m_r

am_d

qS

ynch

rono

us o

r as

ynch

rono

us R

AM

with

sep

arat

e in

put a

nd o

utpu

t por

ts

•lp

m_r

am_i

oS

ynch

rono

us o

r as

ynch

rono

us R

AM

with

a s

ingl

e I/

O p

ort

•lp

m_r

omS

ynch

rono

us o

r as

ynch

rono

us R

OM

•cs

dpra

mC

ycle

-sha

red

dual

-por

t RA

M

•cs

fifo

Cyc

le-s

hare

d fi

rst-

in f

irst

-out

(F

IFO

) bu

ffer

•O

s pa

râm

etro

s de

fine

m a

s ca

ract

erís

ticas

fin

ais

Page 48: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0548

Ex:

RA

M 2

56x8

dua

l-po

rt

EN

TIT

Y r

am25

6x8

IS

P

OR

T(

data

: IN

ST

D_L

OG

IC_V

EC

TO

R (

DA

TA

_WID

TH

-1 D

OW

NT

O 0

);

addr

ess:

IN

ST

D_L

OG

IC_V

EC

TO

R (

AD

DR

_WID

TH

-1 D

OW

NT

O 0

);

we,

incl

k, o

utcl

k: I

N S

TD

_LO

GIC

;

q: O

UT

ST

D_L

OG

IC_V

EC

TO

R (

DA

TA

_WID

TH

- 1

DO

WN

TO

0))

;

EN

D r

am25

6x8;

AR

CH

ITE

CT

UR

E e

xam

ple

OF

ram

256x

8 IS

BE

GIN

in

st_1

: lpm

_ram

_dq

GE

NE

RIC

MA

P (

lpm

_wid

thad

=>

AD

DR

_WID

TH

, lpm

_wid

th =

> D

AT

A_W

IDT

H)

PO

RT

MA

P (d

ata

=>

dat

a, a

ddre

ss =

> a

ddre

ss, w

e =

> w

e, in

clk

=>

incl

k, o

utcl

k =

> o

utcl

k, q

=>

q);

EN

D e

xam

ple;

LIB

RA

RY

ieee

;

US

E ie

ee.s

td_l

ogic

_116

4.A

LL

;

LIB

RA

RY

lpm

;

US

E lp

m.lp

m_c

ompo

nent

s.A

LL

;

LIB

RA

RY

wor

k;

US

E w

ork.

ram

_con

stan

ts.A

LL

;

Page 49: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0549

Meg

afun

ções

e L

PM

sG

ate

s

lpm

_and

lpm

_inv

lpm

_bus

tri

lpm

_mux

lpm

_cls

hift

lpm

_or

lpm

_con

stan

tlp

m_x

or

lpm

_dec

ode

mux

busm

ux

Sto

rage

Co

mp

on

ents

csfi

folp

m_r

am_d

q

csdp

ram

lpm

_ram

_io

lpm

_ff

lpm

_rom

lpm

_lat

chlp

m_d

ff

lpm

_shi

ftre

glp

m_t

ff

Ari

thm

etic

Com

pon

ents

lpm

_abs

lpm

_cou

nter

lpm

_add

_sub

lpm

_mul

t

lpm

_com

pare O

utr

as

Fu

nçõ

es

clkl

ock

pll

ntsc

Meg

aC

ore

Fu

nct

ion

s

a164

50

a825

5

a640

2 ff

t

a685

0 rg

b2yc

rcb

a823

7yc

rcb2

rgb

a825

1

Page 50: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0550

Com

pone

ntes

F

ile:

P

ack

ag

eL

ibra

ryC

on

teú

do

max

plus

2.vh

d

max

plus

2al

tera

MP

II

prim

itiv

as, a

lgum

as m

egaf

unct

ions

de

VH

DL

.

meg

acor

e.vh

d

meg

acor

eal

tera

Meg

afun

ctio

ns p

re-t

esta

das

(div

erso

s pr

ojec

tos)

std1

164.

vhd

std_

logi

c_11

64ie

eeN

orm

a qu

e de

scre

ve li

gaçõ

es e

“da

ta ty

pes”

par

a m

odel

ação

em

VH

DL

std1

164b

.vhd

bem

com

o S

TD

_LO

GIC

e S

TD

_LO

GIC

_VE

CT

OR

type

s.

lpm

_pac

k.vh

d

lpm

_com

pone

nts

lp

mL

PM

meg

afun

ctio

ns d

efin

idas

em

VH

DL

.

arit

h.vh

d

s

td_l

ogic

_ari

th

ieee

Typ

es S

IGN

ED

e U

NS

IGN

ED

, ar

itm

étic

a e

funç

ões

de c

ompa

raçã

o

arit

hb.v

hdpa

ra ty

pes

SIG

NE

D e

UN

SIG

NE

D. F

unçõ

es d

e co

nver

são

CO

NV

_

INT

EG

ER

, CO

NV

_SIG

NE

D, C

ON

V_U

NS

IGN

ED

.

sign

ed.v

hd

st

d_lo

gic_

sign

ed

ieee

Fun

ções

q p

erm

item

ao

MP

2 ac

eder

a ty

pes

ST

D_L

OG

IC_V

EC

TO

R

sign

edb.

vhd

com

o S

IGN

ED

type

s.

unsi

gned

.vhd

std_

logi

c_un

sign

ed i

eee

Fun

ções

q p

erm

item

ao

MP

2 ac

eder

a ty

pes

ST

D_L

OG

IC_V

EC

TO

R

unsi

gned

b.vh

dco

mo

UN

SIG

NE

D ty

pes.

Page 51: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0551

Page 52: ave.dee.isep.ipp.ptave.dee.isep.ipp.pt/~jvs/aulas/LABSI/3_VHDL/2_vhdl.pdf · S A C P - J o s é M i g u e l V i e i r a d o s S a n t o s - V 20 0 5 1 2 E x e m p l o. 5 - s o l u

SA

CP

- J

osé

Mig

uel V

ieir

a do

s S

anto

s -

V20

0552

Behavioural

Structural

g1

a(0

)

a(1

) b

c

d

LOGIC

Ex.

4: E

ntit

y+A

rchi

tect

ure

•LIBRARY ieee;

•USE ieee.std_logic_1164.ALL;

•ENTITY logic IS PORT (

•a: IN std_logic_vector(1 DOWNTO 0);

•b: IN std_logic;

•d: OUT std_logic);

•END logic;

•USE my_WORK.ALL;

•ARCHITECTURE archlogic OF logic IS

•SIGNAL c: std_logic_vector(0 TO 0);

•BEGIN

•g1: and GENERIC MAP (1, 2)

• PORT MAP (a, c);

•d <= b NOR c(0);

•END archlogic;