Docsity

VHDL Programming: Process Statements & FSM in PMIPS Synchronous Components, Assignments of Microprocessors

Partial preview of the text

Download VHDL Programming: Process Statements & FSM in PMIPS Synchronous Components and more Assignments Microprocessors in PDF only on Docsity!

LABORATORY ASSIGNMENT # 5^ pMIPS Synchronous Components IpMIPS Synchronous Components I Flip Flops, Registers, and Finite State Machines (FSM)

Spring 2009

ECE 371: Microprocessor Systems Department of Electrical and Computer EngineeringSchool of Engineering, Mathematics, and Science

Purdue University – Calumet

VHDL

PROCESS

Statement I

-^ Another way to model digital circuits behaviorally•^ The

PROCESS

construct is itself concurrent

  • Multiple

PROCESS

statements are concurrent

  • VHDL statements

inside

a process construct execute

line by line, like C++/Javaline by line, like C++/Java

-^ What statements are permitted within aprocess?

Only sequential

statements like…

  • Synchronous assignment

statements

-^ A <= B

AND

C

  • Flow control

statements

  • conditional execution (

IF-ELSE

,^ CASE

  • repeat (

FOR

... LOOP

,^ WHILE

… LOOP

VHDL

PROCESS

Statement III

-^ Once a

PROCESS

statement activates

-^ process evaluation

starts at point of last suspension

(usually at the “top”).^ • All RHS expressions are evaluated – signal assignments

made

only at end of

evaluation

-^ Example

:

--Assume
A,^
B,^ C,
and
D^ are
unsigned
--Assume
before
the
Process
evaluates,
A^ =
1,^
B^ =^
2,^ C
=^3
--Assume
now,
that
B^ changes
from
2 to
0 at
time
5ns.
PROCESS
(^ B,
C,^
D^ )
BEGIN
A <=
B;^
--The
new
value
for
A^ is
evaluated
C <=
A;^
--The
new
value
for
C^ is
evaluated
D <=
C;^
--The
new
value
for
D^ is
evaluated
END^
PROCESS;
--Signals
are
assigned
AFTER
process
finishes
evaluating
--^
A^ assigned
B_Old,
C assigned
A_Old,
D^ assigned
D_old

PROCESS

for Combinational Logic

-^ Comb. Logic outputs are function of all inputs -^ Outputs always evaluated any time inputs change -^ Implementing comb. logic using

PROCESS

es:

-^ Sensitivity list must have all input values. Why? -^ Process must evaluate any time any of the inputs change -^ Outputs must be assigned a

new value

every time

PROCESS

finishes evaluation. Why?

ARCHITECTURE

Behavior

OF^

Example

IS

BEGINPROCESS

( A,

B, C )

BEGIN

X <= (A

AND

B)^

OR^ C;

Y <= (A

OR^

C )^

AND^

B;

END PROCESS

;

END ARCHITECTURE

Behavior;

PROCESS

finishes evaluation. Why?

-^ Don’t forget to assign a “final” value when using^ CASE

or^

IF-ELSE

statements.^ ARCHITECTURE

Behavior

OF^

Example

IS

BEGINPROCESS

( A, B )

BEGIN

IF^ A = B

THEN AEqB <= ‘1’; END IF; END PROCESS

;

END ARCHITECTURE

Behavior;

Most Useful Flip Flops

Truth Tables

-^ Pop Quiz: - What is the

functional

difference between a D Latch

and a D Flip Flop?

D-FF with Asynchronous Reset

VHDL Code

LIBRARY
IEEE;
USE^
IEEE.STD_LOGIC_1164.ALL
ENTITY

DFlipFlop

IS
PORT
(^ D,

Reset,

Clock

:^ IN
STD_LOGIC;
Q^ :^
OUT^
STD_LOGIC);
END^
ENTITY

DFlipFlop;

(^ )

ARCHITECTURE

Behavior

OF^

flipflop

IS
BEGINPROCESS

(^ Reset,

Clock

)^ BEGIN

IF^ Reset

=^ ‘1'
THEN
Q^ <=
ELSIF

Clock'EVENT

AND

Clock

=^ '1'
THEN
Q^ <=
D^ ;
END^
IF^ ;
END^
PROCESS
END^
ARCHITECTURE

Behavior

Clk^

D x ↓ ↑ (^0) ↑ 1

Q^ t^^1 +(^ ) Q^ t ( )^01

Reset^100

x 0

0 x

n-bit Register

with DFFswith DFFs

Finite State Machines (FSM)

Hardware Organization Next StateComb. Logic

Inputs

Present State

Next State

OutputComb. Logic

Mealy Outputs = F(input, Preset State)

Present StateRegister

clockreset

Moore Outputs = F(Present State)

Mealy

Moore

Finite State Machines

Design Using VHDL

-^ Next State Combinational Logic - Use a

PROCESS

statement

  • Sensitivity List: External inputs, Present State from State Reg. -^ Output Logic (2 Options) -^ Use Conditional or Selected Signal Assignment–^ Use Conditional or Selected Signal Assignment – Use PROCESS statement -^ Sensitivity List Depends on Mealy or Moore FSM - Remember -^ Moore FSM: Outputs = F(Present State)•^ Mealy FSM:

Outputs = F(Inputs, Present State)

-^ State Register - Use a Process Statement -^ If synch. Reset, PROCESS sensitive only to Clock•^ If asynchronous Reset, PROCESS sensitive to Reset and Clock

FSM: Design Example

 - S - S 
  • X = 0 / Y =
  • X = 1 / Y = - X = 1 / Y = - S0 Z = - S1 Z = - X = 1 / Y = - X = 0 / Y =

Memory Controller

BusID[7:0]

Address

Data

Address Bus

ReadWriteBurstReadyReset^ Clock^ Memory Controller

Memory Array

WriteEnOutEn Offset[1:0]^ Done

Memory Controller FSM

IDLE

WRITE

READ

Reset (

synchronous

)

Ready / Done

Ready · Burst / Done

Ready / WriteEn

Ready / OutEn

(BusID == 0xFC) · Ready · ReadWrite / OutEn

(BusID == 0xFC) · Ready · ReadWrite / WriteEn

BURSTREAD 1

BURSTREAD 2

BURSTREAD 3

Ready · Burst / OutEn, Offset = 0x1^ Ready / OutEn, Offset = 0x

Ready / OutEn, Offset = 0x

Ready / OutEn, Offset = 0x

Ready / OutEn, Offset = 0x

Ready / OutEn, Offset = 0x

Ready / Done