experiment 6 labs 9 - 13 outline presentation

162
Digital Logic and State Machine Design Labs 9, 10, 11, 12, 13 CS 2204 CS 2204 Experiment 6 Spring Spring 2014 2014

Upload: vivian

Post on 06-Jan-2016

39 views

Category:

Documents


0 download

DESCRIPTION

Experiment 6 Labs 9 - 13 Outline Presentation Design of Block 6 of the Ppm Digital System (using Term Project pages 38 – 48 and Digital System Design Example ) Individual work Developing Ppm Block 6. Analysis of the Term Project Polytechnic Playing Machine, Ppm - PowerPoint PPT Presentation

TRANSCRIPT

Page 2: Experiment 6 Labs 9 - 13 Outline Presentation

Experiment 6 Labs 9 - 13 Outline Presentation

Design of Block 6 of the Ppm Digital System (using Term Project pages 38 – 48 and Digital System Design Example)

Individual workDeveloping Ppm Block 6

Experiment 6Labs 9-13

Page 2CS 2204 Spring 2014

Page 3: Experiment 6 Labs 9 - 13 Outline Presentation

Analysis of the Term Project Polytechnic Playing Machine, Ppm

The term project is human vs. machine

The black-box view

Page 3

From page 2 of the Term Project Handout

Figure 1. The Ppm black box view.

Ppm13 19

From the input devices To the output devices

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 4: Experiment 6 Labs 9 - 13 Outline Presentation

Page 4

PpmInput/outputrelationship

Ppmoperationdiagram

Fro

m p

ag

e 8

of

the T

erm

Pro

ject

Han

dou

tLD0-LD2 on the FPGA board show the current state

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 5: Experiment 6 Labs 9 - 13 Outline Presentation

The Ppm Digital System Partitioning

Experiment 6 Labs 9-13

Page 5CS 2204 Spring 2014

From page 9 of the Term Project Handout

Page 6: Experiment 6 Labs 9 - 13 Outline Presentation

Page 6

Digital Systems A digital system performs microoperations

A digital system consists of digital circuitsA digital system consists of

A data unit (datapath) It performs microoperations

A control unit It controls the datapath

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 7: Experiment 6 Labs 9 - 13 Outline Presentation

Page 7

Digital Systems This first partitioning of a digital system is

universal

A microprocessor is a digital system An iPhone is a digital system A computer is a collection of digital systems

control signalsstatus signals

Sequencer

Registers ALUs buses Data Unit

Control Unit

Figure 7. A large scale view of a digital system.

Other digital systems/Input/Output devices (Datapath)

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 8: Experiment 6 Labs 9 - 13 Outline Presentation

Page 8

Digital Systems The Data Unit has registers, ALUs and

buses to perform microoperationsRegisters keep (store) data (operands and

results)Arithmetic Logic Units (ALUs) perform

additions, subtractions, multiplications, ANDS, ORs, etc.

Buses interconnect registers and ALUs

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 9: Experiment 6 Labs 9 - 13 Outline Presentation

Page 9

Digital Systems The Control Unit (Sequencer)

The control unit determines the sequence of microoperations based on the current state and status signals

In each state, it enables the microoperations of that state to happen in the data unit based on the status signals

• Microoperations must start at the right time with correct inputs and end at the right time with correct outputs

We should not lose data and we should not use old data

• Glitches, gate delays must be accounted for When we design it, we account for every possible gate delay

The control unit also determines which state is next : Next State

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 10: Experiment 6 Labs 9 - 13 Outline Presentation

Page 10

State

Status signals Control signals

CurrentState

NextState

Control signal andnext state valuegeneration circuits

Figure 8. A general view of the sequencer.

Register

(To the Data Unit)(From the Data Unit)

Digital Systems The Control Unit (Sequencer)

The state register indicates the current state Logic to generate the control signals and the next state

more irregular than the Data Unit

Fro

m p

ag

e 1

1 o

f th

e T

erm

Pro

ject

Han

dou

t

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 11: Experiment 6 Labs 9 - 13 Outline Presentation

Page 11

Random

Status signals Control signals

Figure 9. Digital system sequencers.

a. A general view of a hardwired sequencer.

NextState

CurrentState

Memory

Status signals Control signals

NextState

CurrentState

b. A general view of a microprogrammed sequencer.

StateRegister

StateRegister

Logic

Digital Systems The Control Unit (Sequencer) design

Hardwiring vs microprogramming

Since our Ppm system is simple, we use hardwiring and so we will concentrate on hardwiring from this point on

Gate/FF networks = random logic = irregular

Highlyregularbut slower

Memory bits generate control signals and NS

Not as regularas the datapath

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 12: Experiment 6 Labs 9 - 13 Outline Presentation

Page 12

State

Status signals Control signals

CurrentState

NextState

Control signal andnext state valuegeneration circuits

Figure 8. A general view of the sequencer.

Register

(To the Data Unit)(From the Data Unit)

Digital Systems The Control Unit (Sequencer) design

Hardwired Control Unit design First partitioning on the Control Unit

•Control Signal generation Subblock•Next State Generation Subblock

Often a counter is used instead of a register since we frequently trace the states sequentially

Often a decoder is used to generate the control and next state signals

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 13: Experiment 6 Labs 9 - 13 Outline Presentation

Page 13

Digital Systems The Control Unit (Sequencer) design

Hardwired Control Unit design Often a counter+decoder combination is used in the

sequencer

n-b

it u

p c

ou

nte

r

n

clock n-t

o-2

n D

ecod

er D0

D1

D3

S0

S1

.....S2(n-1)

Load

Data

nControlsignals

NextState

ControlSignals

&NextState

Circuits

Next state Current stateIf it is state 0, S0 is 1

Status signals

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 14: Experiment 6 Labs 9 - 13 Outline Presentation

Page 14

The Ppm Control Unit Block 1, the Control Unit (the sequencer)

It controls the Data Unit It determines the sequence of microoperations

Which microoperation happens when

Block 120 23

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 15: Experiment 6 Labs 9 - 13 Outline Presentation

Page 15

The Ppm Control Unit Block 1, the Control Unit (the sequencer)

The control unit determines the sequence of microoperations based on the status signals Implemented by using the finite-state machine

(FSM) technique Uses hardwiring

• Gate and flip-flip networks generate control signals Partitioned into

• Control Signal generation Subblock • Next State Generation Subblock

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 16: Experiment 6 Labs 9 - 13 Outline Presentation

Page 16

The Ppm Control Unit Block 1, the Control Unit (the sequencer)

ControlSignalGenerationSubblock

Gate and flip-flop networks generate control and next state signals

HardwiredControl Unit

NextStateGenerationSubblock

Controlsignals

Counter-Decodercombinationto keep trackof the currentstate

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 17: Experiment 6 Labs 9 - 13 Outline Presentation

Page 17

Digital Systems How can we design a digital

system ? If the digital system is complex

It is the case with real chips, such as microprocessors

• Write an HDL program ► VHDL program ► Verilog HDL program

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 18: Experiment 6 Labs 9 - 13 Outline Presentation

Page 18

Digital Systems How can we design a digital system ?

If the digital system is simple It is the case with our term project

• Use the finite state machine (FSM) technique ► We draw a finite-state diagram

• One obtains the operation diagram then converts it to a FSM state diagram with same number of states ► Get a finite-state diagram directly from the operation

diagram

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 19: Experiment 6 Labs 9 - 13 Outline Presentation

Page 19

Digital Systems How can we design a digital system ?

If the digital system is simple It is the case with our term project

• Use the finite state machine (FSM) technique ► Obtain a high-level state diagram directly from the operation diagram

Use the Register-Transfer Level (RTL) notation

► Obtain the datapath from the high-level state diagram ► Obtain the low-level state diagram from the datapath and high-level

state diagram ► Obtain the Control Unit Register ← Source

Wire/bus = Source

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 20: Experiment 6 Labs 9 - 13 Outline Presentation

Page 20

Digital System Design Using FSM The Data Unit (Datapath)

The data unit performs microoperations based on the control signals

The data unit goes through states• The high-level state diagram indicates the microoperations

► Each state indicates the microoperations to perform in that clock period

The Data Unit generates status signals as it performs microoperations

► In each state, the control signals indicate which microoperations

should happen The low-level state diagram indicates which

control signals should be active

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 21: Experiment 6 Labs 9 - 13 Outline Presentation

Page 21

Digital System Design Using FSM The Control Unit (Sequencer)

The control unit determines the sequence of microoperations based on the status signals

The control unit goes through states• Each state has a unique number to identify

► The state register value is the current state number

• In each state, it enables the microoperations of that state to happen in the data unit based on the status signals

• It generates the control signals and next state signals timely

State

Status signals Control signals

CurrentState

NextState

Control signal andnext state valuegeneration circuits

Figure 8. A general view of the sequencer.

Register

(To the Data Unit)(From the Data Unit)

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 22: Experiment 6 Labs 9 - 13 Outline Presentation

Page 22

State

Status signals Control signals

CurrentState

NextState

Control signal andnext state valuegeneration circuits

Figure 8. A general view of the sequencer.

Register

(To the Data Unit)(From the Data Unit)

Digital System Design Using FSM The Control Unit (Sequencer)

The sequencer is treated as a state machine A low-level state diagram (with finite number of

states) shows which microoperation happens when in terms of control signals

• Each state shows ► Which control signal is active ► Which state to go to next based on status signals

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 23: Experiment 6 Labs 9 - 13 Outline Presentation

Page 23

Digital System Design Using FSM On paper

1. Start with the black box view and the textual input/output relationship of the digital system

2. Convert the textual input/output relationship to an operation diagram

3. Convert the operation diagram to a high-level state diagram with microoperations with the same number of states A diagram with finite number of states

4. From the high-level state diagram, obtain the datapath

5. From the high-level state diagram and the datapath, obtain the low-level state diagram

6. Decide about how to implement the control unit (sequencer) Hardwiring or microprogramming

• Hardwiring is acceptable if it is not a complex digital system• It is the case with the Ppm term project

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 24: Experiment 6 Labs 9 - 13 Outline Presentation

Page 24

Digital System Design Using FSM On paper

7. Implement the sequencer which is treated as a state machine The low-level state diagram (a state diagram with finite

number of states) shows which microoperation happens when• Each state shows ► Which control signal is active ► Which state to go to next based on status signals• Each state has a unique number to identify ►The state register value is the current state

Convert control signal and next state information of the low-level state diagram to sequencer hardware• Place the counter (state register) + decoder combination if

hardwiring is used• Obtain Expressions ► Obtain gate networks of the sequencer

Start implementing the circuits on computer7. Start drawing the schematics by using the design on

paperExperiment 6

Labs 9-13CS 2204 Spring 2014

Page 25: Experiment 6 Labs 9 - 13 Outline Presentation

Page 25

Machine Play Block, Block 6 The implementation at the course web site

Fro

m p

ag

e 4

0 o

f th

e T

erm

Pro

ject

Han

dou

t

Block 670 15

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 26: Experiment 6 Labs 9 - 13 Outline Presentation

Page 26

Machine Play Block, Block 6 The implementation at the course web site

M2

M3

M4

SequencingInformation gathering

Decision making

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 27: Experiment 6 Labs 9 - 13 Outline Presentation

Page 27

Machine Play Block, Block 6 The implementation at the course web site

The inputs

P1PT is Player 1 pointsP2PT is Player 2 points

RWD is the regular reward points

RD is the random digit

DISP is the four displays

NSD is the adjacency

R1D is the next random digit

BRWD is the digit played

CODERWD is the code reward points

PSEL indicates on which position the current player played

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 28: Experiment 6 Labs 9 - 13 Outline Presentation

Page 28

Machine Play Block, Block 6 The implementation at the course web site

The inputs

P2sturn is 1 when it is Player 2 to playStp2pt stores Player 2 points, here used to increment a counter to check if Player 2 has played 3 times or lessClearp2ffs stores 0 on registers, counters and FFs after Player 2 plays

Clear stores 0 on registers, counters and FFs after reset

Sysclk is the system clock at 6 HzP2clk is the Player2 clock at 48 Hz

Means must be used

Means at least one of them must be used

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 29: Experiment 6 Labs 9 - 13 Outline Presentation

Page 29

Machine Play Block, Block 6 The implementation at the course web site

The outputs

P2CODE outputs the code digits that are discovered by the machine player

Block 670 15

Students have to generate these 7 lines no matter what the playing strategy is

P2CODE outputs are all zero if the code digits are not discoveredExperiment 6

Labs 9-13CS 2204 Spring 2014

Page 30: Experiment 6 Labs 9 - 13 Outline Presentation

Page 30

Machine Play Block, Block 6 The implementation at the course web site

The outputs

P2add is 1 if the machine player adds the random digit to a displayP2played is 1 if the machine player plays the random digit on a display

P2SEL has a 1 corresponding to the position played when the machine player plays the random digit

P2skip is 1 if the machine player skips the plays

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 31: Experiment 6 Labs 9 - 13 Outline Presentation

Page 31

Machine Play Block, Block 6 The implementation at the course web site

• Its playing strategy (intelligence) Play for now and future : Play differently for different

game situations to eventually win the game• If the largest regular reward points wins the game it plays for the

largest regular reward points (Action 0)• If it can play a code digit, it plays the digit on that position (Action 4)• If there is an adjacency and the next RD is a code digit, it plays on

the largest adjacency position (Action 1)• If the game has just started, it plays on zeros (Action 2)• If it is behind, it plays on the largest regular reward points position

(Action 0)• If no

If there is an adjacency, it plays on the largest adjacency position (Action 1)

Otherwise, if RD is not zero and the largest regular reward points is

less than 8, it plays on the largest display position (Action 3)

Otherwise, it skips (Action 5)

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 32: Experiment 6 Labs 9 - 13 Outline Presentation

Page 32

Course web site machine player playing strategy

Fro

m p

ag

e 4

2 o

f th

e T

erm

Pro

ject

Han

dou

t

Player 2 wins the game with regular reward

Action 0

Action 4

Action 1

Action 2

Player 2 is behind

Action 1 Action 0Action 3

Adjacency

Player 2 cannot win the game with regular reward

Action 5

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 33: Experiment 6 Labs 9 - 13 Outline Presentation

Page 33

Machine Play Block, Block 6 The implementation at the course web

site How can we implement the machine player ?

We have to convert the playing strategy and game rules to major operations• We partition Block 6 into subblocks

An intelligent machine player has to gather substantial amount of information about the game and then decide how to play• It must have an information gathering subblock and a

decision making subblock

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 34: Experiment 6 Labs 9 - 13 Outline Presentation

Page 34

Machine Play Block, Block 6 The implementation at the course web

site How can we implement the machine player ?

It must have an information gathering subblock and an decision making subblock We collect and process information in several clock periods :

Sequentially It gathers information sequentially

A sequential circuit ! We have to obtain an operation diagram since we have many FFs

Also, we need a controller to determine what to do in every

clock period

• The controller and operation diagram also imply that the Block 6 is a tiny digital system itself

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 35: Experiment 6 Labs 9 - 13 Outline Presentation

Page 35

Machine Play Block, Block 6 The implementation at the course web

siteHow can we implement the machine player ?

Three major operations, three subblocks• Information gathering about the current situation

► Information Gathering Subblock

• Decision making about what to do with the random digit ► Decision Making Subblock

• Controlling the operations in the block ► Sequencing Subblock

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 36: Experiment 6 Labs 9 - 13 Outline Presentation

Page 36

Sequencing Subblock

Figure 27. The course web site Machine Player partitioning.

InformationGathering

Datapath(Data Unit) Subblock

DecisionMakingSubblock

Control Unit

Machine Play Block, Block 6 The implementation at the course web site

Convert the playing strategy and game rules to major operations

•If the largest regular reward points wins the game it plays for the largest regular reward points (Action 0)•If it can play a code digit, it plays the digit on that position (Action 4)•If there is an adjacency and the next RD is a code digit, it plays on the largest adjacency position (Action 1)•If the game has just started, it plays on zeros (Action 2)•If it is behind, it plays on the largest regular reward points position (Action 0)•If no If there is an adjacency, it plays on the largest adjacency position (Action 1) Otherwise, if RD is not zero and the largest regular reward points is less than 8, it plays on the largest display position (Action 3) Otherwise, it skips (Action 5)

Fro

m p

ag

e 4

4 o

f th

e T

erm

Pro

ject

Han

dou

t

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 37: Experiment 6 Labs 9 - 13 Outline Presentation

Page 37

Machine Play Block, Block 6 The implementation at the course web site

Convert the playing strategy and game rules to major operations To an operation diagram

• Sequential gather

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 38: Experiment 6 Labs 9 - 13 Outline Presentation

Page 38

Gather adjacency and regular reward points informationif the random digit is played on position 0 directly

Gather adjacency and regular reward points informationif the random digit is played on position 1 directly

0

1

Gather adjacency and regular reward points informationif the random digit is played on position 2 directly

2

Gather adjacency and regular reward points information if the random digit is played on position 3 directly

3

Gather adjacency and regular reward points informationif the random digit is played on position 0 with an addition

4

Gather adjacency and regular reward points informationif the random digit is played on position 1 with an addition

5

Gather adjacency and regular reward points informationif the random digit is played on position 2 with an addition

6

Gather adjacency and regular reward points information

Based on the gathered information and also on P1PT, P2PT

7

Figure 29. The Detailed Machine Player operation diagram.

3

Player 1 examines the situation !

4

Player 2 thinks !

5

Player 2 plays

6Player 1 examines the si tuation !

Player 2 points being calculated !

on a position

(a) The Player 2 mode states of the Ppm operation diagram.

(b) The Player 2 substates.

Player 2 skips

if the random digit is played on position 3 with an addition

8

RWD, etc., make a decision to play on a position

4

........

....

Machine Play Block, Block 6 The implementation at the course web site

Convert the playing strategy and game rules to major operations To an operation diagram

• Sequential gather

9 P2clk periods

IG

IG

IG

IG

D

IG

IG

IG

IG

IG ≡ Information gatherD ≡ Decision making

2 Sysclk periods ≡ 0.364 seconds

Sysclk6 Hz

P2clk 48 Hz

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 39: Experiment 6 Labs 9 - 13 Outline Presentation

Page 39

Machine Play Block, Block 6 The implementation at the course web site

Implement the controller (sequencer) as a state machine Design the sequencer A counter + decoder combination is needed to keep track of the

states• A major portion of the Sequencing Subblock

Use this counter+decoder circuit if your machine player has nine states

9 P2clk clock periods

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 40: Experiment 6 Labs 9 - 13 Outline Presentation

Page 40

Machine Play Block, Block 6 The implementation at the course web site

Final digital system design

SequencingInformation gathering

Decision making

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 41: Experiment 6 Labs 9 - 13 Outline Presentation

Page 41

The Ppm Data Unit Block 6, Machine Play Block

Plays as the machine player Generates seven outputs to play correctly

• Seven specific outputs must be generated no matter what the machine playing strategy is

• The remaining 8 outputs can be output as 0 if the code digits are not discovered

Block 6? 15

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 42: Experiment 6 Labs 9 - 13 Outline Presentation

Page 42

The Ppm Data Unit Block 6, Machine Play Block

The playing strategy (intelligence)

Machine

Player

P2SEL

4

P2played

P2skip

P2add

.

.

.

•Must generate the seven outputs for correct operation•The Ppm will stay in state 4 when the machine thinks : both P2played and P2skip are zero

•It stays in state 4 at least one Sysclk period•The selection of inputs depends on the strategy and the implementation

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 43: Experiment 6 Labs 9 - 13 Outline Presentation

Page 43

The Ppm Data Unit Block 6, Machine Play Block

The black box view where the outputs are fixed

The input/output relationship consists of a) The game rules and how the machine player has to interact with

the rest of the Ppm digital systemb) The playing strategy (intelligence)

Machine

Player

P2SEL

4

P2played

P2skip

P2add

.

.

.

The other 8 outputs are 0

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 44: Experiment 6 Labs 9 - 13 Outline Presentation

Page 44

The Ppm Data Unit Block 6, Machine Play Block

If the random digit is played P2SEL and P2add are determined & P2played = 1

• No more than one of P2SEL can be one at a time

If the random digit is not played The machine player skips : P2skip = 1

P2played and P2skip are not 1 at the same time If both P2played and P2skip are 0, it means the machine player is

thinking by using Block4 and Block 5 Developing Block 6 is determining these seven outputs

Additional outputs (other than the 8) can be generated depending on the strategy

• These extra outputs are used by the other five blocks• The five blocks need to be changed !• Not recommended !

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 45: Experiment 6 Labs 9 - 13 Outline Presentation

Page 45

The Ppm Data Unit Block 6, Machine Play Block

The black box view where the outputs are fixed : 15 outputs !

The inputs ? We will collect the information sequentially and so we will stay

in state 4 more than one clock period The Machine Play Block is a digital system

• We have to use the mandatory inputs !

Machine

Player

P2SEL4

P2played

P2skip

P2add

The other 8 outputs are 0

.

.

P2sturn

Clearp2ffs

P2clk

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 46: Experiment 6 Labs 9 - 13 Outline Presentation

Page 46

The Ppm Data Unit Block 6, Machine Play Block

Seven critical outputs of the block P2SEL : 4 bits indicating on which position the machine

player has played• Only one of the lines can be 1 to play on a position

P2add : A line indicating if the machine player adds to a position

P2played : A line indicating that the machine player has played the random digit on a position

• When it is 1, only one of P2SEL lines can be 1 P2skip : A line indicating that the machine player has

skipped the play• When it is 1, P2played must be 0 and vice versa

These seven outputs must be generated no matter what the machine playing strategy is

How

can

we im

ple

men

t th

e b

lock ?

Design it as a Digital System

Use the 7-step Design Procedure

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 47: Experiment 6 Labs 9 - 13 Outline Presentation

Page 47

Block 6, Machine Play Block Development Plays as the machine player

On paper1. Start with the black box view where the outputs are fixed and the

input/output relationshipa) Understand the game rules and how the machine player has to

interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

2. Convert the black box view with the inputs determined and the textual input/output relationship (including the playing strategy) to an operation diagram• Convert the playing strategy to major operations• Partition Block 6 into subblocks• Operation diagram implies the machine player goes through steps

taking several clock periods• The operation diagram also implies that the Block 6 is a tiny digital

system itself

3. Convert the operation diagram to a high-level state diagram with microoperations with the same number of states• A diagram with finite number of states• Distribute microoperations to states

Lab 9

/10

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 48: Experiment 6 Labs 9 - 13 Outline Presentation

Page 48

Block 6, Machine Play Block Development On paper

4. From the high-level state diagram, obtain the datapath• Continue to partition the datapath into subblocks• Design each (sub)block• Implement microperations in datapath hardware

5. From the high-level state diagram and the datapath, obtain the low-level state diagram

6. Decide about how to implement the control unit (sequencer) Hardwiring or microprogramming Hardwiring is acceptable if it is not a complex digital system : It

is the case with the Ppm term project

7. Implement the sequencer which is treated as a state machine Design the sequencer

Start moving the circuits of Block 6 to the computer Copy the termproject folder and paste it as exp6 Start drawing the schematics by using the design on paper Label the components

Lab 9

/10

Lab 1

1-1

3How can we implement the block ?

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 49: Experiment 6 Labs 9 - 13 Outline Presentation

Page 49

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationshipa) Understand the game rules and how the machine player has to

interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Play on the (rightmost)

largest regular reward position

(directly)(Action 0)

We know the game rules already !

Exam

ple

1

Block 6? ?

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 50: Experiment 6 Labs 9 - 13 Outline Presentation

Page 50

Block 6, Machine Play Block Development1. Start with the black box view where the outputs

are fixed and the input/output relationship b) Determine the playing strategy (intelligence)

Always plays (does not skip at all) Plays on the largest regular reward points position

directly or with an addition (choose direct playing if reward points are equal)

If two or more positions have the same regular reward, selects the rightmost one (can also select randomly, or round robin, etc.)

If playing directly on a left side position gives the same regular reward points as playing with an addition on the right side, playing directly on the left side is chosen

Play on the (rightmost)

largest regular reward position (directly)(Action 0)

Exam

ple

1

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 51: Experiment 6 Labs 9 - 13 Outline Presentation

Page 51

Block 6, Machine Play Block Development1. Start with the black box view where the outputs

are fixed and the input/output relationship c) Determine the inputs

We have to collect eight regular reward points for eight possibilities• Four regular reward points on four displays with direct

playing• Four regular reward points on four displays with additions

We will collect the eight regular reward points sequentially• This will take 8 clock periods !

Then, we will play on a position in the ninth clock period

Play on the (rightmost)

largest regular reward position (directly)(Action 0)

Exam

ple

1

Player 2 spends NINE P2clk periods to think

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 52: Experiment 6 Labs 9 - 13 Outline Presentation

Page 52

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationshipa) Understand the game rules and how the machine player has

to interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Exam

ple

1

We need to collect the regular reward points : RWD

We will collect eight regular reward points sequentially

We have to input : P2sturn, Clearp2ffs, P2clk

Play on the (rightmost)

largest regular reward position

(directly)(Action 0)

Block 6? ?

Experiment 6Labs 9-13

CS 2204 Spring 2014

Page 53: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationshipa) Understand the game rules and how the machine player has

to interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 53CS 2204 Spring 2014

Exam

ple

1

Block 6

RWD8

P2sturn

P2clk

We input RWD

We input P2sturn, Clearp2ffs, P2clk Clearp2ffs

?

Play on the (rightmost)

largest regular reward position

(directly)(Action 0)

Page 54: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationshipa) Understand the game rules and how the machine player has

to interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 54CS 2204 Spring 2014

Exam

ple

1

The outputs are fixed !

Block 6

RWD8

P2sturn

P2clk

Clearp2ffs

We must connect 8 zeros to the P2CODE lines to avoid unnecessary warnings

P2SEL

P2add

P2played

4

P2skip

P2CODE8

Play on the (rightmost)

largest regular reward position (directly)(Action 0)

Page 55: Experiment 6 Labs 9 - 13 Outline Presentation

Experiment 6 Labs 9-13

Page 55CS 2204 Spring 2014

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationship

•Must generate the seven outputs for correct operation•The Ppm will stay in state 4 when the machine thinks : both P2played and P2skip are zero

•It stays in state 4 at least one Sysclk period•The selection of inputs depends on the strategy and the implementation

Exam

ple

1

Page 56: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs

determined and convert the textual input/output relationship (including the playing strategy) to an operation diagram Convert the playing strategy to major operations The goal is to develop an intelligent machine player

It gathers information about the current situation Decides how to play

Partition Block 6 into subblocks There are at least two major operations: gather reward

information and decide which position to play Therefore, Block 6 must have at least two subblocks

• Information Gathering SubblockThe information gathering subblock obtains the regular reward points with additions on the four positions and determines the largest regular reward position

• Decision Making Subblock The decision making subblock plays on the largest regular reward position

Experiment 6 Labs 9-13

Page 56CS 2204 Spring 2014

Exam

ple

1

Page 57: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs

determined and convert the textual input/output relationship (including the playing strategy) to an operation diagram Partition Block 6 into subblocks

Do we need another major operation ? The information gathering subblock has to obtain the

regular reward points with addition How can we gather and compare the four regular reward

points and then decide ? ► Sequentially !

A sequencing circuit is needed to get the regular reward points for each position one by one !

► A new subblock is needed as the mini sequencer

Experiment 6 Labs 9-13

Page 57CS 2204 Spring 2014

Exam

ple

1

Page 58: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs

determined and convert the textual input/output relationship (including the playing strategy) to an operation diagram Partition Block 6 into subblocks

The information gathering is done in several steps The machine player goes through steps taking

several clock periods• Another major operation, controlling major operation

is needed • A new subblock, a Sequencing Subblock is needed

Operation diagram is needed to describe what happens in each step• The operation diagram and the controller imply that the

Block 6 is a tiny digital system itself

Experiment 6 Labs 9-13

Page 58CS 2204 Spring 2014

Exam

ple

1

Page 59: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs determined and

convert the textual input/output relationship (including the playing strategy) to an operation diagram We have sequential gather and sequential compare

A sequencing circuit is needed to get reward points, compare with the previous largest reward and update the reward The machine player takes several clock periods to make a decision

An operation diagram is needed• Convert the game rules and playing strategy to major operations• Partition Block 6 into subblocks• Block 6 is a tiny digital system itself

Experiment 6 Labs 9-13

Page 59CS 2204 Spring 2014

To get the operation diagram, check the playing strategy and determine what to do when :

All actions happen in the last state Some actions indicate which data to

collect All conditions indicate what to collect

Exam

ple

1

Page 60: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs

determined and convert the textual input/output relationship (including the playing strategy) to an operation diagram How can we gather and compare the four regular

reward points and then decide sequentially ? The information gathering subblock has to obtain the

regular reward points with direct playing and additions• This is already done in Block 5 !

► Block 5 has the Regular Reward Calculation Subblock which uses

the Adjacency Subblock !► Block 5 receives the digit played

and the position tested from Block 4

Experiment 6 Labs 9-13

Page 60CS 2204 Spring 2014

Exam

ple

1

Adjacency

Regular RewardCalculation

DO NOT IMPLEMENT THIS INFORMATION GATHERING CIRCUITRY COMBINATIONALLY

Page 61: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs determined and

convert the textual input/output relationship (including the playing strategy) to an operation diagram There is only one action and no condition The action indicates we have to

Collect regular reward points When the random digit is played with direct playing and addition on the

four displays• Determine which display has the largest regular reward points

Play on the largest regular reward position• Since the information gathering subblock determines which position has

the largest regular reward, decision making subblock is simple ! We can use Block 5 to get the regular reward points for each display

We indicate which position we are testing (collecting the regular reward points of) with direct playing and addition one by one and Block 5 determines the regular reward points for the position tested

Collecting eight regular reward points and comparing them takes eight clock periods

Then, in the next clock period, the ninth one, we decide where to play This strategy requires nine clock periods to play !

Experiment 6 Labs 9-13

Page 61CS 2204 Spring 2014

Exam

ple

1

Play on the (rightmost)

largest regular reward position

(directly )(Action 0)

Page 62: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs determined and

convert the textual input/output relationship (including the playing strategy) to an operation diagram In summary, we have

Eight clock periods of regular reward collection and comparison• By using the output of Block 5 : RWD

One clock period of decision making How do we handle the secondary strategy ?

If two or more displays have the same largest regular reward points, we play on the rightmost of these

If playing directly and with an addition give the same regular reward points, we play directly

If playing directly on a left side position gives the same regular reward points as playing with an addition on the right side, playing directly on the left side is chosen

Do we need separate hardware for this ?• NO as we will see on the next slide !

Experiment 6 Labs 9-13

Page 62CS 2204 Spring 2014

Exam

ple

1

Play on the (rightmost)

largest regular reward position

(directly )(Action 0)

Page 63: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs determined and

convert the textual input/output relationship (including the playing strategy) to an operation diagram How do we convert the strategy to an operation diagram ?

Write down the steps to play1. Get the regular reward points for position 0 with a direct play2. Get the regular reward points for position 1 with a direct play and

compare with position 0 ► If position 1 has a larger regular reward than position 0, keep it !

3. Get the regular reward points for position 2 a direct play ► If position 2 has a larger regular reward than the previous two positions, keep it !

4. Get the regular reward points for position 3 with a direct play ► If position 3 has a larger regular reward than the previous three positions, keep it !

5. Get the regular reward points for position 0 with an addition ► If position 0 has a larger regular reward than the previous four cases,

keep it !

Experiment 6 Labs 9-13

Page 63CS 2204 Spring 2014

Exam

ple

1

DO NOT IMPLEMENT THIS INFORMATION GATHERING CIRCUITRY COMBINATIONALLY

Play on the (rightmost)

largest regular reward position

(directly )(Action 0)

Page 64: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs determined and

convert the textual input/output relationship (including the playing strategy) to an operation diagram How do we convert the strategy to an operation diagram ?

Write down the steps to play6. Get the regular reward points for position 1 with an addition and

compare with position 0 ► If position 1 has a larger regular reward than previous five points, keep it !

7. Get the regular reward points for position 2 with an addition ► If position 2 has a larger regular reward than the previous six points, keep it !

8. Get the regular reward points for position 3 with an addition ► If position 3 has a larger regular reward than the previous seven points, keep it !

9. Play on the position that has the largest regular reward with an addition

Implementing the secondary strategy is done by checking positions • From right to left and • Keeping a position only if its regular reward is greater than those to

the right • Selecting direct playing if it has the same points as playing with an

addition

Experiment 6 Labs 9-13

Page 64CS 2204 Spring 2014

Exam

ple

1

DO NOT IMPLEMENT THIS INFORMATION GATHERING CIRCUITRY COMBINATIONALLY

Play on the (rightmost)

largest regular reward position

(directly )(Action 0)

Page 65: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Convert the textual input/output relationship (including the playing strategy) to an operation

diagram

Experiment 6 Labs 9-13

Page 65CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

Machine

Player

RWD

8

P2sturn

Clearp2ffs

P2clk

P2add

P2SEL

4

P2played

P2skip

Determine position 0 regular reward with direct playing & record the position number

4

Player 2 plays on a position

Based on the stored information select the position to play

P2s

t0P

2st1 Determine position 1 regular reward with direct playing, keep it if it is larger

& record the position number

P2s

t2P

2st3

Determine position 2 regular reward with direct playing, keep it if it is larger & record the position number

Determine position 3 regular reward with direct playing, keep it if it is larger & record the position number

P2s

t4 Determine position 0 regular reward with an addition, keep it if it is larger & record the position number

P2s

t5 Determine position 1 regular reward with an addition, keep it if it is larger & record the position number

P2s

t6 Determine position 2 regular reward with an addition, keep it if it is larger & record the position number

P2s

t7 Determine position 3 regular reward with an addition, keep it if it is larger & record the position number

P2s

t8

IG

IG

IG

IG

D

IG

IG

IG

IG

Exam

ple

1

Sequential gather and Sequential compareAn operation diagram is needed

P2sturn = 1 in S4

Page 66: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state

diagram with microoperations with the same number of states How do we get the regular reward points without actually

playing ? How do we test each position without actually playing ?

1. Get the regular reward points for position 0 with a direct play• Indicate to Block 4 and Block 5 that position 0 is tested with a direct

play• P2SEL = 0001 ; P2add = 0 ; P2played = 0 ; P2skip = 0• Store RWD on register LRGRWD & store the position on register POS• LRGRWD RWD ; POS 00001

2. Get the regular reward points for position 1 with a direct play and compare with position 0• Indicate to Block 4 and Block 5 that position 1 is tested with a direct

play• P2SEL = 0010 ; P2add = 0 ; P2played = 0 ; P2skip = 0• If RWD is greater than LRGRWD, then store RWD on LRGRWD & store

the position on POS• If RWD > LRGRWD then LRGRWD RWD ; POS 00010

Experiment 6 Labs 9-13

Page 66CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

Exam

ple

1

Page 67: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram

with microoperations with the same number of states How do we get the regular reward points without actually

playing ? How do we test each position without actually playing ?

3. Get the regular reward points for position 2 with a direct play• Indicate to Block 4 and Block 5 that position 2 is tested with a direct

play• P2SEL = 0100 ; P2add = 0 ; P2played = 0 ; P2skip = 0• Store RWD on register LRGRWD & store the position on register POS• LRGRWD RWD ; POS 00100

4. Get the regular reward points for position 3 with a direct play and compare with position 0• Indicate to Block 4 and Block 5 that position 3 is tested with a direct

play• P2SEL = 1000 ; P2add = 0 ; P2played = 0 ; P2skip = 0• If RWD is greater than LRGRWD, then store RWD on LRGRWD & store

the position on POS• If RWD > LRGRWD then LRGRWD RWD ; POS 01000

Experiment 6 Labs 9-13

Page 67CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

Exam

ple

1

Page 68: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram

with microoperations with the same number of states How do we get the regular reward points without actually

playing ? How do we test each position without actually playing ?

5. Get the regular reward points for position 0 with with an addition• Indicate to Block 4 and Block 5 that position 0 is tested with an

addition• P2SEL = 0001 ; P2add = 1 ; P2played = 0 ; P2skip = 0• Store RWD on register LRGRWD & store the position on register POS• LRGRWD RWD ; POS 10001

6. Get the regular reward points for position 1 with an addition and compare with position 0• Indicate to Block 4 and Block 5 that position 1 is tested with an

addition• P2SEL = 0010 ; P2add = 1 ; P2played = 0 ; P2skip = 0• If RWD is greater than LRGRWD, then store RWD on LRGRWD & store

the position on POS• If RWD > LRGRWD then LRGRWD RWD ; POS 0010

Experiment 6 Lab 9-13

Page 68CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

Exam

ple

1

Page 69: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram

with microoperations with the same number of states How do we get the regular reward points without actually

playing ? How do we test each position without actually playing ?

7. Get the regular reward points for position 2 with a direct play• Indicate to Block 4 and Block 5 that position 2 is tested with an

addition• P2SEL = 0100 ; P2add = 1 ; P2played = 0 ; P2skip = 0• Store RWD on register LRGRWD & store the position on register POS• LRGRWD RWD ; POS 10100

8. Get the regular reward points for position 3 with a direct play and compare with position 0• Indicate to Block 4 and Block 5 that position 3 is tested with an

addition• P2SEL = 1000 ; P2add = 1 ; P2played = 0 ; P2skip = 0• If RWD is greater than LRGRWD, then store RWD on LRGRWD & store

the position on POS• If RWD > LRGRWD then LRGRWD RWD ; POS 11000

Experiment 6 Labs 9-13

Page 69CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

Exam

ple

1

Page 70: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram with microoperations with the same

number of states

Experiment 6 Labs 9-13

Page 70CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

P2SEL = 0001 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; LRGRWD RWD ; POS 00001

4

Player 2 plays on a position

P2SEL = 0010 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POS 00010

P2SEL = POS[3:0] ; P2add = POS[4] ; P2played =1 ; P2skip = 0

P2s

t0

RTL Notation used

P2s

t1

P2SEL = 0100 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POS 00100P

2st2

P2SEL = 1000 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POS 01000P

2st3

P2SEL = 0001 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 10001P

2st4

P2SEL = 0010 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 10010P

2st5

P2SEL = 0100 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 10100P

2st6

P2SEL = 1000 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 11000P

2st7

P2s

t8

Exam

ple

1

Machine

Player

RWD

8

P2sturn

Clearp2ffs

P2clk

P2add

P2SEL

4

P2played

P2skip

Sequential gather and Sequential compareA diagram with finite number of states

Page 71: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram with microoperations with the same

number of states

Experiment 6 Labs 9-13

Page 71CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

Machine

Player

RWD

8

P2sturn

Clearp2ffs

P2clk

P2add

P2SEL

4

P2played

P2skip

Exam

ple

1

Sequential gather and Sequential compareA diagram with finite number of states

Register ← Source

Wire/bus = Source

RTL Notation

Page 72: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram with microoperations with the same

number of states

Experiment 6 Labs 9-13

Page 72CS 2204 Spring 2014

Exam

ple

1

Test position 0

Blo

ck 4

Blo

ck 5

NSD

BR

WD

RWD

P2SEL = 0001

Regular reward points of Position 0

Page 73: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram with

microoperations with the same number of states Sequential gather and Sequential compare

A diagram with finite number of states

Experiment 6 Labs 9-13

Page 73CS 2204 Spring 2014

Exam

ple

1

Test0 is 1 if position 0 is tested : 0001Test1 is 1 if position 1 is tested : 0010Test2 is 1 if position 2 is tested : 0100Test3 is 1 if position 3 is tested : 1000

The control unit generates four Test signals one for each position and a direct/add signal : Test3, Test2, Test1 and Test0 and Testadd

Testadd is 0 the first four clock periodsTestadd is 1 the next four clock periods

How can we generate position selection and direct/add signals ?

Page 74: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development4. From the high-level state diagram, obtain the datapath

• Sequential gather and Sequential compare• Continue to partition the datapath into subblocks• Design each (sub)block• Implement microperations in datapath hardware

Experiment 6 Labs 9-13

Page 74CS 2204 Spring 2014

A

8-bitComparator

8RWD

8

LRGRWD B

A>B

Gt

Exam

ple

1

8-bitRegister

8RWD

Store

D

CE

P2clk

C

CLRClr

8

LRGRWD

Q

LRGRWDPOS0

POS1

POS2

POS3

P2clk

5-bitRegister

StoreCE

C

CLR

Test0 D0

Test1 D1

Test2 D2

Test3 D3

Q0

Q1

Q2

Q3

Clr

D4TestAdd P2AQ4

POS

DatapathInformationGathering

Page 75: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development4. From the high-level state diagram, obtain the datapath

• Sequential gather and Sequential compare• Continue to partition the datapath into subblocks• Design each (sub)block• Implement microperations in datapath hardware

Experiment 6 Labs 9-13

Page 75CS 2204 Spring 2014

P2playedPlay

P2skip0

Exam

ple

1

P2SEL0Test0

P2SEL1Test1

P2SEL2Test2

P2SEL3Test3

POS0

POS1

POS2

POS3

P2A

P2addTestAdd

Datapath

Play

Decision Making

In Information Gathering

Page 76: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development5. From the high-level state diagram and the datapath, obtain the low-level state

diagram

Experiment 6 Labs 9-13

Page 76CS 2204 Spring 2014

P2SEL = 0001 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; LRGRWD RWD ; POS 00001

4

Player 2 plays on a position

P2SEL = 0010 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POS 00010

P2SEL = POS ; P2add = POS[4] ; P2played =1 ; P2skip = 0

P2s

t0P

2st1

P2SEL = 0100 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POS 00100

P2s

t2

P2SEL = 1000 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POS 01000P

2st3

P2SEL = 0001 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 1 0001

P2s

t4

P2SEL = 0010 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 10010

P2s

t5

P2SEL = 0100 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 10100

P2s

t6

P2SEL = 1000 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 11000P

2st7

P2s

t8

Test0 = 1; TestAdd = 0 ; Store = 1

Test1 = 1 ; TestAdd = 0 ; If Gt == 1 then Store = 1

4

Play = 1

Test2 = 1 ; TestAdd = 0 ; If Gt == 1 then Store = 1

Test3 = 1 ; TestAdd = 0 ; If Gt == 1 then Store = 1

Test0 = 1 ; TestAdd = 1 ; If Gt == 1 then Store = 1

Test1 = 1 ; TestAdd = 1 ; If Gt == 1 then Store = 1

Test2 = 1 ; TestAdd = 1 ; If Gt == 1 then Store = 1

Test3 = 1 ; TestAdd = 1 ; If Gt == 1 then Store = 1

Player 2 plays on a position

P2s

t0

P2s

t1P

2st2

P2s

t3P

2st4

P2s

t5P

2st6

P2s

t7

P2s

t8

Exam

ple

1

Page 77: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development6. Decide about how to implement the control unit (sequencer)

Sequential gather and Sequential compare Hardwiring or microprogramming ?

• Hardwiring is acceptable if it is not a complex digital system : It is the case with the Ppm term project

Experiment 6 Labs 9-13

Page 77CS 2204 Spring 2014

RWD8

Control UnitClearp2ffs

P2clk

Test2 Test1ClrStoreGt Test0Test3

P2clk

Play

Eight control signals

One status signal

• Always plays on a position : It does not skip• Plays on the position with the largest regular reward by trying directly or with an addition• If two or more positions have the same reward, plays on the rightmost position

P2sturn

P2add

P2SEL4

P2played

P2skip

TestAdd

Exam

ple

1

Gather reward points & compare them

Select one ≡ Make a decision

Datapath

Page 78: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development6. Decide about how to implement the control unit

(sequencer) Sequential gather and Sequential compare

Hardwiring or microprogramming ?• Hardwiring is acceptable if it is not a complex digital system : It is the

case with the Ppm term project

Experiment 6 Labs 9-13

Page 78CS 2204 Spring 2014

Test0 =

1; TestA

dd = 0 ; S

tore = 1

Test1 =

1 ; TestA

dd = 0 ;

If Gt =

= 1 then S

tore = 1

4

Play =

1

Test2 =

1 ; TestA

dd = 0 ;

If Gt =

= 1 then S

tore = 1

Test3 =

1 ; TestA

dd = 0 ;

If Gt =

= 1 then S

tore = 1

Test0 =

1 ; TestA

dd = 1 ;

If Gt =

= 1 then S

tore = 1

Test1 =

1 ; TestA

dd = 1 ;

If Gt =

= 1 then S

tore = 1

Test2 =

1 ; TestA

dd = 1 ;

If Gt =

= 1 then S

tore = 1

Test3 =

1 ; TestA

dd = 1 ;

If Gt =

= 1 then S

tore = 1

Player 2 p

lays on a p

osition

P2st0

P2st1P2st2P2st3P2st4P2st5P2st6P2st7

P2st8

Exam

ple

1

Page 79: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 79CS 2204 Spring 2014

Exam

ple

1

We need a counter (not a register) to keep track of the states

How do we implement the roundrobin trace of the states ?

0 – 1 – 2 – 3 – 4 – 5 – 6 – 7 – 80 – 1 – 2 – 3 – 4 – 5 – 6 – 7 – 8

A counter + decoder combination is needed to keep track of the states

We need a combination of ► 4-bit Up counter ► 3-to-8 DecoderTo keep track of the current state

Page 80: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 80CS 2204 Spring 2014

Exam

ple

1

We start counting when it is PPm state 4 (P2sturn =1)

How do we stop counting when we reach state 8 ?

0 – 1 – 2 – 3 – 4 – 5 – 6 – 7 – 8When we reach state 8, P2s8 is 1 since we play in state 8

We count up (enable counting) if we are in Ppm state 4 and P2s8 is 0

How do we know when we have to count up ?

0 – 1 – 2 – 3 – 4 – 5 – 6 – 7 – 8

Counter enable input = P2sturn P2s8

Page 81: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 81CS 2204 Spring 2014

A counter + decoder combination is needed to keep track of the statesE

xam

ple

1

Counter enable input = P2sturn P2s8

When it is state 8, P2s8 is 1

Counter enable input = P2sturn P2s8

4-b

it u

p c

oun

terCE

C

CLR

Q0

Q1

Q2

P2s8

P2sturn

P2clk

Clearp2ffs

P2streg0

P2streg1

P2streg2

A0

E1

P2s

treg

A2

Q3

P2streg3

A1

3-to

-8 D

ecod

er

E0P2sturn

D0

D1

D2

D3

D4

D5

D6

D7

P2s1

P2s2

P2s3

P2s4

P2s5

P2s6

P2s7

P2s0

P2s8

Page 82: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 82CS 2204 Spring 2014

A counter + decoder combination is needed to keep track of the states

Clearp2ffs is 1 after Player 2 plays

Exam

ple

1

Counter enable input = P2sturn P2s8

4-b

it u

p c

oun

terCE

C

CLR

Q0

Q1

Q2

P2s8

P2sturn

P2clk

Clearp2ffs

P2streg0

P2streg1

P2streg2

A0

E1

P2s

treg

A2

Q3

P2streg3

A1

3-to

-8 D

ecod

er

E0P2sturn

D0

D1

D2

D3

D4

D5

D6

D7

P2s1

P2s2

P2s3

P2s4

P2s5

P2s6

P2s7

P2s0

P2s8

Page 83: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 83CS 2204 Spring 2014

Exam

ple

1 Obtain Expressions

Test0 = P2s0 + P2s4Test0 is 1 when it is state 0 or state 4

Test1 = P2s1 + P2s5Test1 is 1 when it is state 1 or state 5

Test2 = P2s2 + P2s6Test2 is 1 when it is state 2 or state 6

Test3 = P2s3 + P2s7Test3 is1 when it is state 3 or state 7

Play = P2s8Play is 1 when it is state 8

Obtain gate networks for the control signals

Page 84: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 84CS 2204 Spring 2014

Exam

ple

1

Store is 1 when it is • State 0 or • State 1 and Gt is 1 or • State 2 and Gt is 1 or • State 3 and Gt is 1 or• State 4 and Gt is 1 or • State 5 and Gt is 1 or • State 6 and Gt is 1 or• State 7 and Gt is 1

Store is 1 when it is • Not state 8 and

• It is either state 0 or• Gt is 1

Obtain Expressions

Store = P2s8 (P2s0 + Gt)

Obtain gate networks for the control signals

Page 85: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 85CS 2204 Spring 2014

Exam

ple

1

Store = P2s8 (P2s0 + Gt)Store is 1 when it is not state 8 and it is either state 0 or Gt is 1

4-b

it u

p c

oun

terCE

C

CLR

Q0

Q1

Q2

P2s8

P2sturn

P2clk

Clearp2ffs

P2streg0

P2streg1

P2streg2

A0

E1

P2s

treg

A2

Q3

P2streg3

A1

3-to

-8 D

ecod

er

E0P2sturn

D0

D1

D2

D3

D4

D5

D6

D7

P2s1

P2s2

P2s3

P2s4

P2s5

P2s6

P2s7

P2s0

P2s8

Page 86: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 86CS 2204 Spring 2014

Exam

ple

1

TestAdd is 1 when it is state 4 or 5 or 6 or state 7

TestAdd = P2s4 + P2s5 + P2s6 + P2s7

TestAdd = P2streg2

Page 87: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 87CS 2204 Spring 2014

Exam

ple

1

Clr is 1 when Clearp2ffs is 1

Clr = Clearp2ffs

Clearp2ffs is 1 after Player 2 plays

Page 88: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state

machine Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 88CS 2204 Spring 2014

Use this counter+decoder circuit if your machine player does not skip and has nine states

Control Unit

Exam

ple

1

Gt

Clr StoreTest0 Test1 Test2 Test3

P2s8Clearp2ffs

P2s0

Play

P2s8

TestAdd

P2streg2

4-b

it u

p c

oun

terCE

C

CLR

Q0

Q1

Q2

P2s8

P2sturn

P2clk

Clearp2ffs

P2streg0

P2streg1

P2streg2

A0

E1

P2s

treg

A2

Q3

P2streg3

A1

3-to

-8 D

ecod

er

E0P2sturn

D0

D1

D2

D3

D4

D5

D6

D7

P2s1

P2s2

P2s3

P2s4

P2s5

P2s6

P2s7

P2s0

P2s8

Page 89: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development Start implementing the circuits of Block 6 on computer

• Sequential gather and Sequential compare Final digital system design on paper

Experiment 6 Labs 9-13

Page 89CS 2204 Spring 2014

Datapath

Control Unit

Exam

ple

1

Page 90: Experiment 6 Labs 9 - 13 Outline Presentation

Experiment 6 Labs 9-13

Page 90CS 2204 Spring 2014

Block 6, Machine Play Block Development Start implementing the circuits of Block 6 on computer

• Sequential gather and Sequential compare Copy the termproject folder and paste it as exp6 Start drawing the schematics by using the design on paper Perform simulations

Exam

ple

1

Page 91: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationshipa) Understand the game rules and how the machine player has to

interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 91CS 2204 Spring 2014

Exam

ple

2

There is an adjacency ?

N

Play on the(rightmost)largest regular reward position (directly if equal)(Action 0)

Y

Play on the(rightmost)largest adjacency position (directly if equal)(Action 1)

Decision making is more complex !

Block 6? ?

Page 92: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationshipa) Understand the game rules and how the machine player has to

interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 92CS 2204 Spring 2014

We know the game rules already !

Exam

ple

2

Block 6? ?

There is an adjacency ?

N

Play on the(rightmost)largest regular reward position (directly if equal)(Action 0)

Y

Play on the(rightmost)largest adjacency position (directly if equal)(Action 1)

Page 93: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs

are fixed and the input/output relationship b) Determine the playing strategy (intelligence)

Always plays (does not skip at all) If there is no adjacency, it plays on the largest regular

reward points position directly or with an addition (chooses direct playing if the two reward points are equal).

Otherwise, it plays on the largest regular adjacency position directly or with an addition (chooses direct playing if adjacencies are equal)

In either case, if two or more positions equally playable, selects the rightmost one

If playing on the left side directly has the same adjacency/regular reward points as playing on the right side with addition, select playing on the left side directly

Experiment 6 Labs 9-13

Page 93CS 2204 Spring 2014

Exam

ple

2

Page 94: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationship c) Determine the inputs

We have to collect eight regular reward points for eight possibilities• Four regular reward points on four displays with direct playing• Four regular reward points on four displays with additions

We have to collect eight adjacencies for eight possibilities• Four adjacencies on four displays with direct playing• Four adjacencies on four displays with additions

We will collect the eight regular reward points and eight adjacencies sequentially• This will take 8 clock periods !

Then, we will play on a position in the ninth clock period

Experiment 6 Labs 9-13

Page 94CS 2204 Spring 2014

Exam

ple

2

Player 2 spends NINE P2clk periods to think

Page 95: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationshipa) Understand the game rules and how the machine player has

to interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 95CS 2204 Spring 2014

Exam

ple

2

We need to collect the regular reward points : RWD

We will collect eight regular reward points sequentially

We have to input : P2sturn, Clearp2ffs, P2clk Block 6

? ?

We need to collect the adjacencies : NSD

Page 96: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationshipa) Understand the game rules and how the machine player has

to interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 96CS 2204 Spring 2014

Exam

ple

2

Block 6

RWD8

P2sturn

P2clk

We input RWD, NSDWe input P2sturn, Clearp2ffs, P2clk

Clearp2ffs

?

NSD2

Page 97: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationshipa) Understand the game rules and how the machine player has

to interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 97CS 2204 Spring 2014

Exam

ple

2

The outputs are fixed !

Block 6

We must connect 8 zeros to the P2CODE lines to avoid unnecessary warnings

P2SEL

P2add

P2played

4

P2skip

P2CODE8

RWD8

P2sturn

P2clk

NSD2

Clearp2ffs

Page 98: Experiment 6 Labs 9 - 13 Outline Presentation

Experiment 6 Labs 9-13

Page 98CS 2204 Spring 2014

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationship

•Must generate the seven outputs for correct operation•The Ppm will stay in state 4 when the machine thinks : both P2played and P2skip are zero

•It stays in state 4 at least one Sysclk period•The selection of inputs depends on the strategy and the implementation

Exam

ple

2

Page 99: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Get the black box view with the inputs

determined and convert the textual input/output relationship (including the playing strategy) to an operation diagram Sequential gather and Sequential compare

An operation diagram is needed• Convert the playing strategy to major operations• Partition Block 6 into subblocks• Block 6 is a tiny digital system itself The machine player takes several clock periods to make a

decision

Experiment 6 Labs 9-13

Page 99CS 2204 Spring 2014

To get the operation diagram, check the playing strategy and determine what to do when :

All actions happen in the last state Some actions indicate which data to

collect All conditions indicate what to collect

Exam

ple

2

Page 100: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Convert the textual input/output relationship (including the playing strategy) to an operation

diagram

Experiment 6 Labs 9-13

Page 100

CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

Determine position 0 regular reward and adjacency with direct playing & record the position number

4

Player 2 plays on a position

Based on the stored information select the position to play

P2s

t0P

2st1 Determine position 1 regular reward and adjacency with direct playing, keep

each if it is larger & record the position number

P2s

t2P

2st3

Determine position 2 regular reward and adjacency with direct playing, keep each if it is larger & record the position number

Determine position 3 regular reward and adjacency with direct playing, keep each if it is larger & record the position number

P2s

t4 Determine position 0 regular reward and adjacency with an addition, keep each if it is larger & record the position number

P2s

t5 Determine position 1 regular reward and adjacency with an addition, keep each if it is larger & record the position number

P2s

t6 Determine position 2 regular reward and adjacency with an addition, keep each if it is larger & record the position number

P2s

t7 Determine position 3 regular reward and adjacency with an addition, keep each if it is larger & record the position number

P2s

t8

IG

IG

IG

IG

D

IG

IG

IG

IG

Machine

Player

RWD

8

P2sturn

Clearp2ffs

P2clk

P2add

P2SEL

4

P2played

P2skip

NSD 2

Exam

ple

2

Page 101: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development3. Convert the operation diagram to a high-level state diagram with microoperations with the same

number of states

Experiment 6 Labs 9-13

Page 101

CS 2204 Spring 2014

Player 2 spends NINE P2clk periods to think

RTL Notation used

P2SEL = 0001 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; LRGRWD RWD ; LRGADJ NSD ; POSRWD 00001 ; POSNSD 00001

4

Player 2 plays on a position

P2SEL = 0010 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POSRWD 00010If NSD > LRGNSD then LRGNSD NSD ; POSNSD 00010

P2played = 1 ; P2skip = 0If LRGNSD >0 then P2SEL = POSNSD[3:0] ; P2add = POSNSD[4] ; else P2SEL = POSRWD[3:0] ; P2add = POSRWD[4]

P2s

t0P

2st1

P2SEL = 0100 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POSRWD 0100If NSD > LRGNSD then LRGNSD NSD ; POSNSD 0100P

2st2

P2SEL = 1000 ; P2played = 0 ; P2skip = 0 ; P2add = 0 ; If RWD > LRGRWD then LRGRWD RWD ; POSRWD 01000If NSD > LRGNSD then LRGNSD NSD ; POSNSD 01000P

2st3

P2SEL = 0001 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POSRWD 10001If NSD > LRGNSD then LRGNSD NSD ; POSNSD 10001

P2s

t4

P2SEL = 0010 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POSRWD 10010If NSD > LRGNSD then LRGNSD NSD ; POSNSD 10010

P2s

t5

P2SEL = 0100 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POSRWD 10100If NSD > LRGNSD then LRGNSD NSD ; POSNSD 10100

P2s

t6

P2SEL = 1000 ; P2played = 0 ; P2skip = 0 ; P2add = 1 ; If RWD > LRGRWD then LRGRWD RWD ; POS 11000If NSD > LRGNSD then LRGNSD NSD ; POSNSD 11000P

2st7

P2s

t8

Machine

Player

RWD

8

P2sturn

Clearp2ffs

P2clk

P2add

P2SEL

4

P2played

P2skip

NSD 2

Exam

ple

2

Page 102: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development4. From the high-level state diagram, obtain the datapath

Experiment 6 Labs 9-13

Page 102

CS 2204 Spring 2014

A

8-b

itC

omp

arat

or

8

RWD

8

LRGRWD

B

A>B

Gtrwd

POSRWD0

POSRWD1

POSRWD2

POSRWD3

P2clk

5-b

itR

egis

ter

Storerwd CE

C

CLR

Test0 D0

Test1 D1

Test2 D2

Test3 D3

Q0

Q1

Q2

Q3

Clr

D4TestAdd

P2AQ4

PO

SR

WD

Datapath

Information Gathering

8-b

itR

egis

ter

8

RWD

Storerwd

D

CE

P2clk C

CLRClr

8

LRGRWD

Q

LR

GR

WD

POSNSD0

POSNSD1

POSNSD2

POSNSD3

P2clk

5-b

itR

egis

ter

Storensd CE

C

CLR

Test0 D0

Test1 D1

Test2 D2

Test3 D3

Q0

Q1

Q2

Q3

Clr

D4TestAdd

P2BQ4

PO

SN

SD

2-b

itR

egis

ter

2

NSD

Storensd

D

CE

P2clk C

CLRClr

2

LRGNSD

QLR

GN

SD

A

2-b

itC

omp

arat

or

2

NSD

2

LRGNSD

B

A>B

Gtnsd

Exam

ple

2

AdjLRGNSD1

LRGNSD0

Page 103: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development4. From the high-level state diagram, obtain the datapath

Experiment 6 Labs 9-13

Page 103

CS 2204 Spring 2014

P2SEL0Test0

P2SEL1Test1

P2SEL2Test2

P2SEL3Test3

P2add

P2playedPlay

P2skip0

TestAdd

5-b

it2-

to-1

MU

X

E

A0

B0

A1

B1

Y0

Y1

Y2

Y3

Play

A2

Y4

B2

A3

B3

Sel

A4

B4

Decision MakingPOSNSD0

POSNSD1

POSNSD2

POSNSD3

P2B

POSRWD0

POSRWD1

POSRWD2

POSRWD3

P2A

Datapath

Adj

Exam

ple

2

Page 104: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development4. From the high-level state diagram, obtain the datapath

Experiment 6 Labs 9-13

Page 104

CS 2204 Spring 2014

Decision Making

Datapath

Information Gathering

Exam

ple

2

Page 105: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development5. From the high-level state diagram and the datapath, obtain the low-level state

diagram

Experiment 6 Labs 9-13

Page 105

CS 2204 Spring 2014

Exam

ple

2

Test0 = 1; TestAdd = 0 ; Storerwd = 1 ; Storensd = 1

Test1 = 1 ; TestAdd = 0 ; If Gtrwd == 1 then Storerwd = 1 ;If Gtnsd == 1 then Storensd = 1

4

Play = 1

Test2 = 1 ; TestAdd = 0 ; If Gtrwd == 1 then Storerwd = 1 ;If Gtnsd == 1 then Storensd = 1

Test3 = 1 ; TestAdd = 0 ; If Gtrwd == 1 then Storerwd = 1 ;If Gtnsd == 1 then Storensd = 1

Test0 = 1 ; TestAdd = 1 ; If Gtrwd == 1 then Storerwd = 1 ;If Gtnsd == 1 then Storensd = 1

Test1 = 1 ; TestAdd = 1 ; If Gtrwd == 1 then Storerwd = 1 ;If Gtnsd == 1 then Storensd = 1

Test2 = 1 ; TestAdd = 1 ; If Gtrwd == 1 then Storerwd = 1 ;If Gtnsd == 1 then Storensd = 1

Test3 = 1 ; TestAdd = 1 ; If Gtrwd == 1 then Storerwd = 1If Gtnsd == 1 then Storensd = 1

Player 2 plays on a positionP

2st0

P2s

t1P

2st2

P2s

t3P

2st4

P2s

t5P

2st6

P2s

t7

P2s

t8

Page 106: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development6. Decide about how to implement the control unit (sequencer)

Sequential gather and Sequential compare Hardwiring or microprogramming ?

• Hardwiring is acceptable if it is not a complex digital system : It is the case with the Ppm term project

Experiment 6Labs 9-13

Page 106

CS 2204 Spring 2014

RWD

8

Clearp2ffs

P2clk

Test2Test1

ClrStorerwd

Gtrwd Test0Test3

P2clk

Play

Nine control signals

Two status signals

P2sturn

P2add

P2SEL

4

P2played

P2skip

TestAdd

NSD

2

GtnsdStorensd

Control Unit

Datapath

Gather reward points & adjacencies & compare them

Select one based on the adjacency ≡ Make a decision

Exam

ple

2

Page 107: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development6. Decide about how to implement the control unit

(sequencer) Sequential gather and Sequential compare

Hardwiring or microprogramming ?• Hardwiring is acceptable if it is not a complex digital system : It is the

case with the Ppm term project

Experiment 6Labs 9-13

Page 107

CS 2204 Spring 2014

Test0 =

1; TestA

dd = 0 ;

Storerw

d = 1 ; S

torensd = 1

Test1 =

1 ; TestA

dd = 0 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

4

Play =

1

Test2 =

1 ; TestA

dd = 0 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test3 =

1 ; TestA

dd = 0 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test0 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test1 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test2 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test3 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1

If Gtnsd =

= 1 then S

torensd = 1

Player 2 p

lays on a p

osition

P2st0P2st1P2st2P2st3P2st4P2st5P2st6P2st7

P2st8

Exam

ple

2

Page 108: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 108

CS 2204 Spring 2014

A counter + decoder combination is needed to keep track of the states

Test0 =

1; TestA

dd = 0 ;

Storerw

d = 1 ; S

torensd = 1

Test1 =

1 ; TestA

dd = 0 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

4

Play =

1

Test2 =

1 ; TestA

dd = 0 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test3 =

1 ; TestA

dd = 0 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test0 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test1 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test2 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1 ;

If Gtnsd =

= 1 then S

torensd = 1

Test3 =

1 ; TestA

dd = 1 ;

If Gtrw

d ==

1 then Storerw

d = 1

If Gtnsd =

= 1 then S

torensd = 1

Player 2 p

lays on a p

osition

P2st0P2st1P2st2P2st3P2st4P2st5P2st6P2st7

P2st8

Exam

ple

2

Page 109: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development7. Implement the sequencer which is treated as a state machine

Sequential gather and Sequential compare Design the hardwired sequencer

Experiment 6 Labs 9-13

Page 109

CS 2204 Spring 2014

Use this counter+decoder circuit if your machine player does not skip and has nine states

Exam

ple

2

Gtrwd

Clr StorerwdTest0 Test1 Test2 Test3

P2s8

Cle

arp2

ffs

P2s0

Play

P2s8

TestAdd

P2streg2

Gtnsd

Storensd

P2s8

P2s0

4-b

it u

p c

oun

terCE

C

CLR

Q0

Q1

Q2

P2s8

P2sturn

P2clk

Clearp2ffs

P2streg0

P2streg1

P2streg2

A0

E1

P2s

treg

A2

Q3

P2streg3

A1

3-to

-8 D

ecod

er

E0P2sturn

D0

D1

D2

D3

D4

D5

D6

D7

P2s1

P2s2

P2s3

P2s4

P2s5

P2s6

P2s7

P2s0

P2s8

Page 110: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development Start implementing the circuits of Block 6 on computer

• Sequential gather and Sequential compare Final digital system design on paper

Experiment 6 Labs 9-13

Page 110

CS 2204 Spring 2014

Control Unit

Information Gathering

Exam

ple

2

Datapath

Decision Making

Page 111: Experiment 6 Labs 9 - 13 Outline Presentation

Experiment 6 Labs 9-13

Page 111

CS 2204 Spring 2014

Block 6, Machine Play Block Development Start implementing the circuits of Block 6 on computer

• Sequential gather and Sequential compare Copy the termproject folder and paste it as exp6 Start drawing the schematics by using the design on paper Perform simulations

Exam

ple

2

Page 112: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed

and the input/output relationship b) Determine the playing strategy (intelligence)

How to determine of the machine player strategy is acceptable ?

Experiment 6 Labs 9-13

Page 112

CS 2204 Spring 2014

At least 3 (three)

different complex conditions

At least 4 (four)

different complex actions

Lab 9

-10

Page 113: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationship b) Determine the playing strategy (intelligence)

Students can use the following conditions and actions in case they cannot agree upon them

Experiment 6 Labs 9-13

Page 113

CS 2204 Spring 2014

Player 1 has more points than Player 2 ?

There is an adjacency & RD is not zero ?

There is a position with a 0 & RD is not zero & next RD not equal to RD ?

At least 3 (three) different complex conditions

Other complex conditions are possible

Player 1 does not have (64)10 or more points & there is a position with a zero and RD is not zero

Player 1 does not have (64)10 or more points & the largest regular reward is less than (64)10

Lab 9

-10

Page 114: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationship b) Determine the playing strategy (intelligence)

Students can use the following conditions and actions in case they cannot agree upon them

Experiment 6 Labs 9-13

Page 114

CS 2204 Spring 2014

Play on the (rightmost) largest regular reward position (directly if equal)

Play on the (rightmost) largest adjacency position (directly if equal)

Play on the (rightmost if equal) largest display position with an addition

Play on the(rightmost)zero position directly

At least 4 (four) different complex actions

Other complex actions are possible

Play on the (rightmost if equal) adjacency position that results in the most regular reward points (directly if equal)

Lab

9-1

0

Page 115: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationship b) Determine the playing strategy (intelligence)

Non-intelligent machine player strategies1. Play in a permanently fixed way : always play on the

rightmost position which does not have a display overflow. If all positions result in display overflows, skips

2. Play randomly : when it is time to play, stop a freely running 2-bit counter and play on that position

3. Play in a fixed way-round robin fashion : every time it is the turn, increment a 2-bit counter and play on that position

Experiment 6 Labs 9-13

Page 115

CS 2204 Spring 2014

Do not implement these strategies

Lab 9

-10

Page 116: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development1. Start with the black box view where the outputs are fixed and

the input/output relationship b) Determine the playing strategy (intelligence)

Experiment 6 Labs 9-13

Page 116

CS 2204 Spring 2014

Lab 9

-10

If you do not specify the secondary strategy for even a single action, it means the machine player does not work and so you will lose 30 points

Page 117: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development2. Convert the textual input/output relationship (including

the playing strategy) to an operation diagram Decide about the parallel/sequential implementation issue Get the subblocks Convert the playing strategy to major operations

3. Convert the operation diagram to a high-level state diagram with microoperations with the same number of states If sequential gather and Sequential compare+decide is

decided A diagram with finite number of states Distribute microoperations to states

Experiment 6 Labs 9-13

Page 117

CS 2204 Spring 2014

Lab 9

-10

Page 118: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development4. From the high-level state diagram, obtain the datapath

Sequential gather and Sequential compare+decide Design each (sub)block Implement microperations in datapath hardware

5. From the high-level state diagram and the datapath, obtain the low-level state diagram If Sequential gather and Sequential compare+decide is

chosen

6. Decide about how to implement the control unit (sequencer) Hardwiring or microprogramming ? Choose hardwiring

7. Implement the sequencer which is treated as a state machine Design the sequencer Use the 5-state or 9-state counter+decoder combinations

given on previous slides

Experiment 6 Labs 9-13

Page 118

CS 2204 Spring 2014

Lab 9

-10

Make sure the machine player takes at least 9 clock periods to play

Page 119: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development Move the design to the computer ≡ Implement

Block 6 on computer Plan where to place the subblocks on the screen Delete your Block 6 circuits if they are not needed Start drawing the schematics

First place the components, then their outputs and then their inputs

Label the components Save schematic 6, ppm6.sch

Experiment 6 Labs 9-13

Page 119

CS 2204 Spring 2014

Lab

11-1

3

Page 120: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development Move the design to the computer ≡ Implement

Block 6 on computer Start drawing the schematics

Experiment 6 Labs 9-13

Page 120

CS 2204 Spring 2014

Make sure your circuits in Block 6 follow the Term Project Check List handout

DO NOT IMPLEMENT INFORMATION GATHERING CIRCUITRY COMBINATIONALLY

USE available circuits in Blocks 1, 2, 3, 4 and 5

Lab

11

-13

Page 121: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development Move the design to the computer ≡ Implement

Block 6 on computer Start drawing the schematics

Experiment 6 Labs 9-13

Page 121

CS 2204 Spring 2014

Lab

11

-13 Your machine player would not work completely

because of three reasons

It does not follow the game rules

It does not follow your playing strategy

Your playing strategy is not complete

Page 122: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development Move the design to the computer ≡ Implement

Block 6 on computer Remember also the following

Follow all the suggestions and warnings, including the timetable !

Follow the 7-step procedure to design Block 6 ! Start debugging Block 6 starting with the outputs,

proceeding backward Make sure everybody has everything related to

Block 6 all the time Do not have black boxes (macros) Only six schematics in the projects TAs and I will not answer design related questions ! Experiment 6 is like an exam : It must be your

work ! No communication with other teams !

Experiment 6 Labs 9-13

Page 122

CS 2204 Spring 2014

Lab 1

1-1

3

Page 123: Experiment 6 Labs 9 - 13 Outline Presentation

Block 6, Machine Play Block Development Implementing the machine player, Block 6

Every member of a team must do the schematic design to remember better for the final exam

The timetable for the rest of the semester The last day to submit Experiment 5 as a team is

April 4, 2014 Students will submit the Experiment 6 project which

will include the implementation of • Block 6

The deadline : 6:50 PM, Friday, May 2, 2014

Experiment 6 Labs 9-13

Page 123

CS 2204 Spring 2014

Lab

11-1

3

Submit your Experiment 6 during a lab session !

Page 124: Experiment 6 Labs 9 - 13 Outline Presentation

CS2204 Lab Students will receive a lab grade

5% of the term grade Lab work

• Lab attendance, arrival, departure• Concentration on lab work• How well he/she cooperates with the teammates

Term project grade based on the Experiment 6 Check List handout

Arriving late would delay the team work Also, teammates cannot synchronize well If this happens frequently, the team member would fall

behind the teammates• Exam grades would go down as well

Labs affect the term grade more Labs are on all exams Labs reinforce lecture topics

Experiment 6 Labs 9-13

Page 124

CS 2204 Spring 2014

Page 125: Experiment 6 Labs 9 - 13 Outline Presentation

Lab Grade Calculating the lab grade

5% of the term grade Term project (Experiment 6) grade based on the Term

Project Check List handout : 80 Lab work : 90 based on

• Lab attendance, arrival, departure• Concentration on lab work• How well he/she cooperates with the teammates

The lab grade : (0.90 * 0.80) * 5 = (0.72) * 5 = 3.6

Labs affect the term grade more Labs are on all exams Labs reinforce lecture topics

Experiment 6 Labs 9-13

Page 125

CS 2204 Spring 2014

Page 126: Experiment 6 Labs 9 - 13 Outline Presentation

QUESTIONS ?

Experiment 6 Labs 9-13

Page 126

CS 2204 Spring 2014

DigitalLogic and

State Machine Design

Read all the slides to learn about the software, Project Navigator, Schematic design and other related topics

Continue reading the Term Project handout

Think about the machine player strategy

Do not leave the lab before your partners finish► Help your partners

Make sure you have the LABS account and see the S driveMake sure you have installed WebPACK 12.4 on your laptop

Make sure you create a CS2204 folder on both

Page 127: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Work We will develop (implement) Block 6 of

the term projectWe will replace the machine player with our

own circuits

Help our partners complete today’s project

We will continue reading the Term Project handout

Also read slides at the end to learn about the software, Project Manager, Schematic design and other related topics

Experiment 6 Labs 9-13

Page 127

CS 2204 Spring 2014

Page 128: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work

1. Open the ppm project in the exp5 foldera) Open the Project Manager and then

open the Ppm project in the exp5 folder

b) Look at the six Ppm schematics Make sure all schematics are not Non-Project

c) Enter the team information to the schematics if it has not been entered Save the schematic if the team information is

entered

Experiment 6 Labs 9-13

Page 128

CS 2204 Spring 2014

Lab

9/1

0

Page 129: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work1. Open the ppm project in the exp4 folder

d) Make sure Experiment 1, Experiment 2, Experiment 3, Experiment 4 and Experiment 5 are completed That is you have the following in Schematic 3 and two circuits in Schematic 6 on the

next slide :

Experiment 6 Labs 9-13

Page 129

CS 2204 Spring 2014

Lab

9/1

0

And the next slide

Experiment 1

Experiment 2

Page 130: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work1. Open the ppm project in the exp4 folder

d) Make sure Experiment 1, Experiment 2, Experiment 3, Experiment 4 and Experiment 5 are completed That is you have the following on Schematic 6 and a circuit on Schematic 3 on the previous

slide :

Experiment 6 Labs 9-13

Page 130

CS 2204 Spring 2014

Lab

9/1

0

Experiments 3, 4 and 5

Make sure your circuits in blocks 3 and 6 follow the Term Project Check List handout

Page 131: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work1. Open the ppm project in the exp4 folder

d) Make sure Experiment 1, Experiment 2, Experiment 3, Experiment 4 and Experiment 5 are completed

If they are not complete finish the designs by studying Lab 4 presentation for Experiment 1 Lab 5 presentation for Experiment 2 Lab 6 presentation for Experiment 3 Lab 7 presentation for Experiment 4 Lab 8 presentation for Experiment 5

• So that eventually Block 3 looks like as follows :

Experiment 6 Labs 9-13

Page 131

CS 2204 Spring 2014

Lab

9/1

0

Experiment 2

Experiment 1

Make sure your circuits in blocks 3 and 6 follow the Term Project Check List handout

Experiments 3, 4 and 5

Page 132: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work1. Open the ppm project in the exp3 folder

d) Make sure Experiment 1, Experiment 2, Experiment 3, Experiment 4 and Experiment 5 are completed So that eventually Block 3 and Block 6 look like as

follows :

Experiment 6 Labs 9-13

Page 132

CS 2204 Spring 2014

Make sure your circuits in blocks 3 and 6 follow the Term Project Check List handout

Lab

9/1

0 Experiment 1

Experiment 2

Experiments 3, 4 and 5

Page 133: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work2. Submit the Experiment 5 project after deciding whose

project is the best to submit Decide whose project on the team will be submitted

Block 3 and Block 6 must look like as follows :

Experiment 6 Labs 9-13

Page 133

CS 2204 Spring 2014

Make sure your circuits in blocks 3 and 6 follow the Term Project Check List handout

Experiment 1

Experiment 2

Experiments 3, 4 and 5

Page 134: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work2. Submit the Experiment 5 project after deciding whose

project is the best to submit Fill out a Term Project Check List handout before signaling to

the TA Block 3 and Block 6 must look like as follows :

Experiment 6 Labs 9-13

Page 134

CS 2204 Spring 2014

Make sure your circuits in blocks 3 and 6 follow the Term Project Check List handout

Experiment 1

Experiment 2

Experiments 3, 4 and 5

Page 135: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work3. By using Xilinx ISE create exp5 from the

exp6 Remember that we must create a new

project from an earlier one by using Xilinx ISE We will experiment with the Ppm schematics

4. Open the Ppm project in exp65. Look at the six Ppm schematics6. If it has not been entered, place your

team info on the schematics Save the schematic if you enter the team

information

Experiment 6 Labs 9-13

Page 135

CS 2204 Spring 2014

Lab

9/1

0

Page 136: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work7. Switch to schematic 68. Completely zoom out9. Check your Block 6 implementation !9. Analyze your Block 6 circuits and

compare them with the original Block 6 circuits by reading the slides of this presentation and the Term Project handout

10.Perform functional simulations on your Block 6 circuits

Record your test vectors to use later

Experiment 6 Labs 9-13

Page 136

CS 2204 Spring 2014

Lab

9/1

0

Page 137: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work11.Draw the circuit in schematic 6 by using

General Design Rules and Digital Product Development

First, do the design on paper1. Start with the black box view where the outputs are

fixed and the input/output relationshipa) Understand the game rules and how the machine player

has to interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence) ► Draw a graph

Students should study the slides in the presentation

section to decide about choosing a strategy : Students cannot implement them ! They have to come up with their own strategy and implementation !

The slides are ordered from the simplest to the most

complex !

Experiment 6 Labs 9-13

Page 137

CS 2204 Spring 2014

Lab

9/1

0

Page 138: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work11. Draw the circuit in schematic 6 by using General Design

Rules and Digital Product Development First, do the design on paper

1. Start with the black box view where the outputs are fixed and the input/output relationshipa) Understand the game rules and how the machine player has to

interact with the rest of the Ppm digital systemb) Determine the playing strategy (intelligence)

Experiment 6 Labs 9-13

Page 138

CS 2204 Spring 2014

Lab

9/1

0

At least 3 (three)

different complex conditionsAt least 4 (four)

different complex actions

Page 139: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work11. Draw the circuit in schematic 6 by using General Design Rules and

Digital Product Development First, do the design on paper

1. Start with the black box view where the outputs are fixed and the input/output relationshipb) Determine the playing strategy (intelligence)

Experiment 6 Labs 9-13

Page 139

CS 2204 Spring 2014

Lab

9/1

0

Player 1 has more points than Player 2 ?

There is an adjacency & RD is not zero ?

There is a position with a 0 & RD is not zero & next RD not equal to RD ?

At least 3 (three) different complex conditions

Other complex conditions are possible

Player 1 does not have (64)10 or more points & there is a position with a zero and RD is not zero

Player 1 does not have (64)10 or more points & the largest regular reward is less than (64)10

Page 140: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work11. Draw the circuit in schematic 6 by using General Design Rules

and Digital Product Development First, do the design on paper

1. Start with the black box view where the outputs are fixed and the input/output relationshipb) Determine the playing strategy (intelligence)

Experiment 6 Labs 9-13

Page 140

CS 2204 Spring 2014

Lab

9/1

0

Play on the (rightmost) largest regular reward position (directly if equal)

Play on the (rightmost) largest adjacency position (directly if equal)

Play on the (rightmost if equal) largest display position with an addition

Play on the(rightmost)zero position directly

At least 4 (four) different complex actions

Other complex actions are possible

Play on the (rightmost if equal) adjacency position that results in the most regular reward points (directly if equal)

Page 141: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work11. Draw the circuit in schematic 6 by using

General Design Rules and Digital Product Development

First, do the design on paper1. Start with the black box view where the outputs are fixed

and the input/output relationshipb) Determine the playing strategy (intelligence)

Experiment 6 Labs 9-13

Page 141

CS 2204 Spring 2014

Lab

9/1

0

If you do not specify the secondary strategy for even a single action, it means the machine player does not work and so you will lose 30 points

Page 142: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work11.Draw the circuit in schematic 6 by using

General Design Rules and Digital Product Development

First, do the design on paper1. Start with the black box view where the outputs are

fixed and the input/output relationshipa) Understand the game rules and how the machine

player has to interact with the rest of the Ppm digital system

b) Determine the playing strategy (intelligence)c) Determine the inputs

Experiment 6 Labs 9-13

Page 142

CS 2204 Spring 2014

Lab

9/1

0

Page 143: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work11.Draw the circuit in schematic 6 by using

General Design Rules and Digital Product Development

First, do the design on paper2. Convert the textual input/output relationship

(including the playing strategy) to an operation diagram• Decide about the parallel/sequential implementation

issue• Get the subblocks• Convert the playing strategy to major operations

3. Convert the operation diagram to a high-level state diagram with microoperations with the same number of states• If sequential gather and Sequential compare+decide is

decided ► A diagram with finite number of states ► Distribute microoperations to states

Experiment 6 Labs 9-13

Page 143

CS 2204 Spring 2014

Lab

9/1

0

Page 144: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work11. Draw the circuit in schematic 6

4. From the high-level state diagram, obtain the datapath• Sequential gather and Sequential compare+decide• Design each (sub)block• Implement microperations in datapath hardware

5. From the high-level state diagram and the datapath, obtain the low-level state diagram If Sequential gather and Sequential compare+decide is

chosen

6. Decide about how to implement the control unit (sequencer)• Hardwiring or microprogramming ? Choose hardwiring

7. Implement the sequencer which is treated as a state machine• Design the sequencer

► Use the 5-state or 9-state counter+decoder combinations given on previous slides

Experiment 6 Labs 9-13

Page 144

CS 2204 Spring 2014

Lab

9/1

0

Make sure the machine player takes at least 9 clock periods to play

Page 145: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work11.Draw the circuit in schematic 6

Move the design to the computer ≡ Implement Block 6 on computer Plan where to place the subblocks on the screen Delete your Block 6 circuits if they are not needed Start drawing the schematics

• First place the components, then their outputs and then their inputs

• Label the components Save schematic 6, ppm6.sch

Experiment 6 Labs 9-13

Page 145

CS 2204 Spring 2014

Lab

11

-13

Page 146: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work11.Draw the circuit in schematic 6

Move the design to the computer ≡ Implement Block 6 on computer Start drawing the schematics

Experiment 6 Labs 9-13

Page 146

CS 2204 Spring 2014

Lab

11

-13 Make sure your circuits in Block 6

follow the Term Project Check List handout

DO NOT IMPLEMENT INFORMATION GATHERING CIRCUITRY COMBINATIONALLY

USE available circuits in Blocks 1, 2, 3, 4 and 5

Page 147: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work11.Draw the circuit in schematic 6

Move the design to the computer ≡ Implement Block 6 on computer Start drawing the schematics

Experiment 6Labs 9-13

Page 147

CS 2204 Spring 2014

Lab

11

-13 Your machine player would not work completely

because of three reasons

It does not follow the game rules

It does not follow your playing strategy

Your playing strategy is not complete

Page 148: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work11. Draw the circuit in schematic 6

Move the design to the computer ≡ Implement Block 6 on computer Remember also the following

• Follow all the suggestions and warnings, including the timetable !

• Follow the 7-step procedure to design Block 6 !• Start debugging Block 6 starting with the outputs,

proceeding backward• Make sure everybody has everything related to Block 6

all the time• Do not have black boxes (macros)• Only six schematics in the projects• TAs and I will not answer design related questions !

Experiment 6 is like an exam : It must be your work ! No communication with other teams !

Experiment 6 Labs 9-13

Page 148

CS 2204 Spring 2014

Lab

11

-13

Page 149: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work12.Do a schematic check on the new design

Schematic checks do not catch all the errors That is why after the Schematic checks we have to

perform• Functional simulations• Xilinx IMPLEMENTATIONs• Timing simulations

13.Perform functional simulations in schematic 6 to verify that it is working

Use the test vectors you recorded in step 10 if necessary

Make sure the circuit is beautified and the schematic is saved again

Experiment 6 Labs 9-13

Page 149

CS 2204 Spring 2014

Lab 1

1-1

3

Page 150: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work14.Do a Xilinx IMPLEMENTATION

Make sure there are no errors Read the warnings

Confirm that the warnings are acceptable

The FPGA chip utilization does not have to be 6%• The utilization depends on the strategy, the

intelligence of the machine player designed

Experiment 6 Labs 9-13

Page 150

CS 2204 Spring 2014

Lab

11-1

3

Page 151: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work15.Download the Ppm project to the FPGA

chip and play the game and to verify that the schematic works correctly

In order to test the circuit fast you can input random digits directly to the machine player After you play, when the state is 3, leave one of

switches SW7 – SW4 on to signal you will input the random digit

Use switches SW3 – SW0 to select a random digit value

Press push button BTN2 so the machine player starts with the random digit you input

Turn off the signaling switch (one of SW7 – SW4) before you press push button BTN3 to play

Experiment 6 Labs 9-13

Page 151

CS 2204 Spring 2014

Lab

11

-13

Page 152: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work15.Download the Ppm project to the FPGA

chip and play the game and to verify that the schematic works correctly

If it does not work, inspect your circuit in Block 6 and correct the circuit

Experiment 6 Labs 9-13

Page 152

CS 2204 Spring 2014

Lab 1

1-1

3

Page 153: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Individual Xilinx Lab Work16.Ensure that all circuits related to

Experiment 1, Experiment 2, Experiment 3, Experiment 4 and Experiment 5 are complete

Including Component labels Well drawn circuits

If you are sure your circuit is correct then Copy your experiment 6 folder from the D drive to

your USB memory stick

17.Help your partners complete the project

Experiment 6 Labs 9-13

Page 153

CS 2204 Spring 2014

Lab 1

1-1

3

Page 154: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work18.Submitting the term project

After drawing the schematics, simulating circuits separately and testing them on the FPGA board, make sure that1) The components are labeled2) The subsubblocks and the subblocks are separated

by lines and labelled3) The circuit is beautified 4) The schematic is saved again5) Functional simulations of the subblocks are done

again6) A Xilinx IMPLEMENTATION is done again7) Downloading to the FPGA board and testing are

done again8) Your experiment 6 folder from the S drive is copied

to your laptop

Experiment 6 Labs 9-13

Page 154

CS 2204 Spring 2014

Lab

11

-13

Page 155: Experiment 6 Labs 9 - 13 Outline Presentation

Today’s Xilinx Lab Work18. Submitting the term project

After drawing the schematics, simulating circuits separately and testing them on the FPGA board9) Determine whose project will be submitted and then

signal to a TA to submit your project10) Fill out a Term Project Check List Handout11) The team project will be copied by the TA12) Once copied, open the project and download to the

FPGA board to make sure it is copied correctly13) Print all schematics to prepare for the final exam14) If you have any files on the local drive, delete them

Experiment 6 Labs 9-13

Page 155

CS 2204 Spring 2014

Lab

11-1

3

Submit your Experiment 6 during a lab session !

The deadline : 6:50 PM, May 2, 2014

Page 156: Experiment 6 Labs 9 - 13 Outline Presentation

Understand Critical WiresRD : 4 bits

The random digitR1D : 4 bits

Next random digitR2D : 4 bits

The random digit after next random digitDISP : 16 bits

They represent the four position displays In Hex

DISP15-DISP12 : The leftmost position display, PD3 DISP11-DISP8 : position display PD2, etc

NPDISP : 16 bits The result of RD to each display digit

In Hex NPDISP15-NPDISP12 : The leftmost position, PD3, value + RD NPDISP11-NPDISP8 : Position display PD2 value + RD

NPSELDISP : 4 bits Selects one of NPDISP display values

In Hex

Experiment 6 Labs 9-13

Page 156

CS 2204 Spring 2014

Page 157: Experiment 6 Labs 9 - 13 Outline Presentation

Understand Critical WiresBRWD : 4 bits

Basic reward In Hex

The digit played and also minimum points earned It is selected from RD or NPSELDISP

Based on how the player played : Directly or with an addition

Brwdeqz : 1 bit BRWD is zero when it is 1

PDPRD : 4 bits Display overflow bits after addition

Pdprd : 1 bitThe display overflow bit of the position played

Selplyr : 1 bit The current player

If it is 0, it is the human player, otherwise, it is the machine player

Experiment 6 Labs 9-13

Page 157

CS 2204 Spring 2014

Page 158: Experiment 6 Labs 9 - 13 Outline Presentation

Understand Critical WiresP1SEL : 4 bits

The position played by the human playerP2SEL : 4 bits

The position played by the machine playerPSEL : 4 bits

Position Select bits of current playerENCPSEL : 2 bits

The number of the position playedEQ : 4 bits

The equality of the four displays to the digit playedNSD : 2 bits

The number of similar digits, i.e. the adjacency information of the position played

RWD : 8 bits The regular reward points calculated based on adjacencies

In Unsigned Binary CODERWD : 8 bits

The code reward points calculated based on the code digits In Unsigned Binary

Experiment 6 Labs 9-13

Page 158

CS 2204 Spring 2014

Page 159: Experiment 6 Labs 9 - 13 Outline Presentation

Understand Critical WiresP1PT : 8 bits

Player 1 points In Hex

P2PT : 8 bits Player 2 points

In Hex

PT : 8 bits The points of the current player

In Hex

NPT : 8 bits New player points for the current player

In Hex

Ptovf : 1 bitThe points overflow

if it is 1, the new player points is above (255)10

Experiment 6 Labs 9-13

Page 159

CS 2204 Spring 2014

Page 160: Experiment 6 Labs 9 - 13 Outline Presentation

Understand Critical WiresP1add : 1 bit

Player 1 adds when it is 1

P2add : 1 bit Player 2 adds when it is 1

Add : 1 bit The current player adds when it is 1

P1skip : 1 bit Player 1 skips when it is 1

P2skip : 1 bit Player 2 skips when it is 1

P1played : 1 bit Player 1 has played when it is 1

P2played : 1 bit Player 2 has played when it is 1

Experiment 6Labs 9-13

Page 160

CS 2204 Spring 2014

Page 161: Experiment 6 Labs 9 - 13 Outline Presentation

Understand Critical WiresDISPSEL : 2 bit

Selects one of four values for displays 00 Selects position displays (displays that RD is played on) 01 Selects player points 10 Selects next two random digits 11 Selects discovered code digits

Add : 1 bitShows that the current player has selected to add

Stp1pt : 1 bit Store Player 1 points

Stp2pt : 1 bit Store Player 2 points

Grd : 1 bit Signals to generate a new random digit

The random digit counter output is stored as P2RD while P2RD and P1RD are shifted to generate the new P1RD and RD

Bpds : 1 bitBlink one or all displays slowly

Bpdf : 1 bitBlocks a display fast after a display overflow

Experiment 6 Labs 9-13

Page 161

CS 2204 Spring 2014

Page 162: Experiment 6 Labs 9 - 13 Outline Presentation

Understand Critical WiresClear : 1 bit

Clear FFs, registers, counters, etc. during reset in Block 2, Block 4 and Block 6 so that it can play again

Clearp2ffs : 1 bit Clears Player 2 FFs, counters and registers

Clff : 1 bit Clears FFs in Block 2 so that the next player can play if there

is no overflowS1 : 1 bit

State 1 where when it is 1, the Ppm is in state 1P2sturn : 1 bit

Signals that Player 2 has the turn It is 1 when the Ppm is in state 4

Sysclk : 1 bit System clock of the operation diagram at 6 Hz

P2clk : 1 bit The clock signal of Player 2 at 48 Hz

Rdclk : 1 bit The random digit counter clock at 192 Hz

Experiment 6 Labs 9-13

Page 162

CS 2204 Spring 2014