Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist [email protected]...

24
Vending machine William Sandqvist [email protected] Design-exempel by Ingo Sander

Transcript of Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist [email protected]...

Page 1: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Vending machine

William Sandqvist [email protected]

Design-exempel by Ingo Sander

Page 2: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

System Control

COINRECEIVER

COIN_PRESENT

GT_1_EURO

EQ_1_EURO

LT_1_EURO

DEC_ACC

CLR_ACC

SYSTEMCONTROL

DROP

DROP_READY

CHANGER_READY

RETURN_10_CENT

DROP BOTTLE

COIN RETURN

William Sandqvist [email protected]

ACCUMU-LATOR

We will design the block,

System Control

Return only 10 cents coin.

Page 3: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Coin Reciever

COINRECEIVER

COIN_PRESENT

GT_1_EURO

EQ_1_EURO

LT_1_EURO

DEC_ACC

CLR_ACC

SYSTEMCONTROL

William Sandqvist [email protected]

The System Control unit controls a number of subsystems

from other suppliers. Coin Reciever. Drop Bottle. Coin

Return.

ACCUMU-LATOR

An ACCUMULATOR counts up the amount of paid coins.

• Signal COIN_PRESENT indicates that there are coins and the ”amount” is

indicated by the signals GT_1_EURO, EQ_1_EURO, LT_1_EURO.

• With the signals DEC_ACC and CLR_ACC the systemcontrol unit can

reduce the amount by 10 cents, or reset the ACCUMULATOR.

Page 4: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Coin Return

William Sandqvist [email protected]

SYSTEMCONTROL

CHANGER_READY

RETURN_10_CENT COIN RETURN

With a pulse on RETURN_10_CENT the coin return unit

will eject 10 cent, and signal CHANGER_READY when

this is done and the unit is ready for the next command.

Page 5: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Drop Bottle

William Sandqvist [email protected]

With a pulse on DROP the drop bottle unit will eject a

bottle, and signals DROP_READY when this is done and

the unit is ready for the next command.

SYSTEMCONTROL

DROP

DROP_READY

DROP BOTTLE

Page 6: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Block diagram

COINRECEIVER

COIN_PRESENT

GT_1_EURO

EQ_1_EURO

LT_1_EURO

DEC_ACC

CLR_ACC

System-styrning(SYSTEM

CONTROL)

DROP

DROP_READY

CHANGER_READY

RETURN_10_CENT

DROP BOTTLE

COIN RETURN

• Signal propertieso DROP_READY is active for a clockperiod after the bottle is ejected

o CHANGER_READY is active for a clockperiod after a 10 Cent coin is ejected

◦ Because of the mechanical properties the following signals are active and inactive for several clock periods: COIN_PRESENT (active for several clockperiods after the coin is inserted) DROP_READY (active for several clockperiods at bottle ejection) CHANGER_READY (inactive for several clockperiods at coin ejection )

Page 7: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Use a Moore-machine

William Sandqvist [email protected]

NEXT STATEDECODER STATE REGISTER

OUTPUTDECODER

State)

Clk

Inputsignals

Output signals

Construction of a state machine for the controller of a

vending machine

Assumptions

- Moore-Machine

- - Stateregister implemented with D-flip-flops

Page 8: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Function diagram for vending machine

William Sandqvist [email protected]

• Myntinkast

– 10 Cent, 50 Cent, 1 Euro

• Myntutkast

– 10 Cent

• Flaskpris

– 1 Euro

Page 9: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

State diagram

We draw a

state diagram

from the

functional

diagram :

(a)

(b)

(c)

(d)

(e)

(f)

(g)

READYCHANGER _

CENTRETURN _10_

READYCHANGER_

EUROGT _1_

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

EUROLT _1_

EUROEQ _1_

READYDROP_

DROP

READYDROP _

ACCCLR _

ACCDEC _

Page 10: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

State diagram

William Sandqvist [email protected]

Page 11: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Block schematic

William Sandqvist [email protected]

D

D

D

Next State Decoder

COIN_PRESENT

LT_I_EURO

EQ_I_EURO

GT_I_EURO

DROP_READY

CHANGER_READY

A

B

C

DA

DB

DC

A

B

C

Output

Decoder

DROP

CLR_ACC

DEC_ACC

Clk

Clk

Clk

RETURN_I0_CENT

Input signals Output signalsState register

Page 12: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

State encoding

William Sandqvist [email protected]

Idea: Let the states that are close together in the state

diagram have codes with unit distance.

(b) next to (c)

(d) next to (e)

(a) next to (b)

(f) next to (g)AB

00 01 11 10

C

0 a Ø d f

1 b c e g

7 states 3 state variables A, B,

C are needed

The number of inputs is large, 6,

total there may be nine variables

in Karnaugh maps ???

(Ø = don’t care)

Page 13: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

State encoding

(a)

(b)

(c)

(d)

(e)

(f)

(g)

READYCHANGER _

CENTRETURN _10_

READYCHANGER_

EUROGT _1_

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

EUROLT _1_

EUROEQ _1_

READYDROP_

DROP

READYDROP _

ACCCLR _

ACCDEC _

000

001

011

100110

111 101

State variables ABC, eg. in

state (c) is A = 0, B = 1 and

C = 1

CBAAB

00 01 11 10

C

0 a Ø d f

1 b c e g

(Ø = don’t care)

Page 14: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Coded state table?

William Sandqvist [email protected]

From the state diagram, you

can set up the following coded

state table.

How do we avoid the

complexity of nine variables?

Page 15: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Variable-Entered Mapping (VEM)

William Sandqvist [email protected]

A+ DA AB

00 01 11 10

C

0 0 Ø 1 1

1 0 EQ + GT 0 0

Variable-Entered Mapping can be helpful when you need Karnaugh diagrams with many

variables. You write functional expressions in the Karnaugh map.

Variables

Page 16: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Next state - DA

William Sandqvist [email protected]

A+ DA AB

00 01 11 10

C

0 0 Ø 1 1

1 0 EQ + GT 0 0

EQ : EQ_1_EURO

GT : GT_1_EURO

CAGTBAEQBADA A

Page 17: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Next state - DB

William Sandqvist [email protected]

B+ DB AB

00 01 11 10

C

0 0 Ø 1 0

1 CP EQ 0 1

EQ : EQ_1_EURO

CP : COIN_PRESENT

CBACPCBCBEQBADB B

Easy to miss!

Page 18: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Next state - DC

William Sandqvist [email protected]

C+ DC AB

00 01 11 10

C

0 CP Ø DR CR

1 1 0 0 1

CP : COIN_PRESENT

DR: DROP_READY

CR: CHANGER_READY

CBCRBA

DRCBCPCADC C

Page 19: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Output signals

William Sandqvist [email protected]

CBAACCDEC

CBACENTRETURN

ABCACCCLR

CABDROP

_

_10_

_

The output signals are

"pulses" which are

generated when passing

through the states d, f, e, g.

Page 20: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

Implementation of the vending machine

William Sandqvist [email protected]

When they call from CocaCola, it's just for you all

”Digital Designers” to adopt the mission ...

”students must master the the design of simple

combinational and sequential digital systems”

You do that now!

Page 21: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

William Sandqvist [email protected]

Page 22: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

What will happen in state Φ?

William Sandqvist [email protected]

AB

00 01 11 10

C

0 a Ø d f

1 b c e g

ABC)010(

GTEQGTEQACAGTBAEQBAA ABC 101111)010(

ecdCBA ,,,111,011,110,0101

1...1111)010( EQBCBACPCBCBEQBAB ABC

DRCPCRDRCPC

CBCRBADRCBCPCAC

ABC

00001111)010(

Page 23: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

What will happen in state Φ?

William Sandqvist [email protected]

ecdCBA ,,,111,011,110,0101

In Φ-state we are stuck, or

we go to (c) and then on. Or

we go to (d) and offers soft

drinks, or we go to (e) and

resets any previous payment.

Obviously, we need to purchase a reset circuit that ensures

that the machine always starts in (a) 000! Otherwise

we will have legitimate complaints from the customers!

RESET-generator

Page 24: Design-exempel by Ingo Sander - KTHVariable-Entered Mapping (VEM) William Sandqvist william@kth.se A+ D A AB 00 01 11 10 C 0 0 Ø 1 1 1 0 EQ + GT 0 0 Variable-Entered Mapping can be

William Sandqvist [email protected]