BR 1/991 Dice Game (Chapter 22) The dice game in Chapter 22 is a good example of a Finite State Machine controlling a Datapath. –The combined FSM/Datapath.

Slides:



Advertisements
Similar presentations
Basic Finite State Machines 1. 2 Finite State Machines Binary encoded state machines –The number of flip-flops is the smallest number m such that 2 m.
Advertisements

Chapter #10: Finite State Machine Implementation
CPE 201 Digital Design Lecture 25: Register Transfer Level Design (2)
General Sequential Design
Lecture 23: Registers and Counters (2)
1ASM Algorithmic State Machines (ASM) part 1. ASM2 Algorithmic State Machine (ASM) ‏ Our design methodologies do not scale well to real-world problems.
Shift Registers Module M11.1 Section 7.3.
Registers and Counters
Table 7.1 Verilog Operators.
BR 1/991 Rb?Ra? D7 or D11? Roll D2312? Sp Rb?Ra?Eq?D7? Roll Lose Win S0 S1 S2 S4 S3 S5 Fig 1: Dice Game ASM Chart.
Give qualifications of instructors: DAP
BR 1/991 Hints on Meeting Project Constraints Clock Cycle Constraint (12 clocks) – More resources (multipliers, adders), less clocks –Can be done with.
BR 1/991 Dice Game Chap 22 1-to-6 Cntr Adder CntbCnta Point Register Comparator dicesum Test Logic ControlControl Roll D7 D11 D2312 eq Dpathb.vhd Dpatha.vhd.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
Charles Kime © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 7 – Registers and Register Transfers Part 3 – Control of.
1 COMP541 Sequencing and Control Montek Singh Mar 29, 2007.
Shift Registers Lecture L6.6 Section Bit Shift Register.
ELEN 468 Advanced Logic Design
FINITE STATE MACHINES (FSMs) Dr. Konstantinos Tatas.
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic CMOS logic elements Combinational logic elements and design.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 8, 2007.
Computer Architecture Lecture 12 Fasih ur Rehman.
Dr. H.v.d.Biggelaar / Mar3-Ver2 / 1 Engineering Technology Dr. H.v.d.Biggelaar March 22, 2000 State Machines in VHDL.
Algorithmic State Machines.  1) Create an algorithm, using pseudocode, to describe the desired operation of the device. 2) Convert the pseudocode into.
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 21 Multiplier Example Example: (101 x 011) Base 2 Note that the partial product summation.
Instructor: Yuzhuang Hu Another Design Example: PIG (Chapter 7-10) PIG is a single dice game. Two players roll the dice in turns. When.
Chapter 10 State Machine Design. 2 State Machine Definitions State Machine: A synchronous sequential circuit consisting of a sequential logic section.
Computer Organization & Programming Chapter 5 Synchronous Components.
BR 1/991 Dice Game Implementation Why was dice game implemented in three 22V10 PLDs? What are the resources needed by the Dice Game? –Outputs: 6 for dice.
Chapter 3 Digital Logic Structures. 3-2 Combinational vs. Sequential Combinational Circuit always gives the same output for a given set of inputs  ex:
Fibonnaci Sequence Generator and Testbench in VHDL Michael Larson.
BR 1/991 DataPath Elements Altera LPM library has many elements useful for building common datapath functions –lpm_ram_dq - recommended for either asynchronous.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 11, 2010.
Digital System Design using VHDL
CEC 220 Digital Circuit Design Dice Game Wed, April 06 CEC 220 Digital Circuit Design Slide 1 of 15.
CDA 4253 FPGA System Design RTL Design Methodology 1 Hao Zheng Comp Sci & Eng USF.
ECE/CS 352 Digital System Fundamentals© T. Kaminski & C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Fall 2000 Chapter 5 – Part 2 Tom Kaminski & Charles.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Chapter 8 Solving Larger Sequential Problems.
Counters and registers Eng.Maha Alqubali. Registers Registers are groups of flip-flops, where each flip- flop is capable of storing one bit of information.
1 강의노트 09 Logic Design with ASM Charts: Based on Digital Systems Design Using VHDL, Chapter 5, by Charles H. Roth, Jr.
Digital Design with SM Charts
SERIAL MULTIPLIER Part 1
Class Exercise 1B.
Figure 8.1. The general form of a sequential circuit.
Digital Electronics Multiplexer
Registers and Counters
Instructor: Alexander Stoytchev
Digital Electronics Multiplexer
Lecture 16 Arithmetic Circuits
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
KU College of Engineering Elec 204: Digital Systems Design
ECE 434 Advanced Digital System L13
Shift Registers Lecture L8.6 Section 8.3.
Instructor: Alexander Stoytchev
CSE 370 – Winter Sequential Logic-2 - 1
Instructor: Alexander Stoytchev
ECE 545—Digital System Design with VHDL Lecture 1
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Instructor: Alexander Stoytchev
Figure 8.1. The general form of a sequential circuit.
Instructor: Alexander Stoytchev
Switching Theory and Logic Design Chapter 5:
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
RTL Design Methodology Transition from Pseudocode & Interface
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
CSE 370 – Winter Sequential Logic-2 - 1
Presentation transcript:

BR 1/991 Dice Game (Chapter 22) The dice game in Chapter 22 is a good example of a Finite State Machine controlling a Datapath. –The combined FSM/Datapath implement a Dice Game. Dice Game Rules: –After 1st roll of dice, player wins if roll if 7 or 11. Player loses if roll is 2, 3 or 12. Anything else is saved as the players “POINT”. –On subsequent rolls, player loses if roll is a 7. Player wins if the dice roll is equal to their “POINT”. You must keep rolling until you win or lose.

BR 1/992 What do we need: A Dice Roll Some way to simulate a dice roll. Dice have values of 1,2,3,4,5,6. We could generate a “random” number between 1-6. –Could use a psuedo random sequence generator in the form of a shift register for this. –Can be difficult to test if using psuedo random sequences An easier way is to use a counter whose count sequence is 1,2,3,4,5,6,1,2, etc. –Even though count sequence is NON-RANDOM, a high speed clock and a user pushing buttons to stop/start the roll will make the dice roll look random!!!

BR 1/ Counter S0 S1 S2 S3 Q = 1 Q = 2 En=0 En=1 En=0 En=1 Q = 3 En=0 En=1 Q = 4 En=0 En=1 Q = 5 En=0 En=1 Q = 6 En=0 En=1 S4 S5 Need two counters, one for each dice. Need an ADDER to sum the two 3-bit dice outputs to produce a four bit sum that we can test!

BR 1/994 “dpatha” Details Clk C 3 EN R Cntr Q Roll (from control) Reset C 3 EN R Q Logic Roll Clk Reset Cntb Cnta AdderAdder 4 dicesum 3 Ena Ena = 1 when Cntb = 6 and Roll = 1 Counters count 1,2,3,4,5,6,1,2, etc Cntr

BR 1/995 What else do we need??? We need to save the “POINT” value from the first roll somewhere. –Use a Register! We need to compare our POINT value and the current dice roll to several values –Compare Current dice roll to POINT value: Use a comparator –Compare Current dice roll to values of 7, 11, 2, 3, 12: Use comparator logic Need inputs to start the dice roll, stop the dice roll.

BR 1/996 “dpathb” Details DIN 4 C LD Register Point 4 R Dicesum (from dpatha) sp (from control) Compare Clk Reset Eq (1 if point = sum) Test Logic D7 (1 if sum=7) D11 (1 if sum=11) D2312 (1 if sum=2,3 or 12) “sp” (save point) loads value of dicesum into register.

BR 1/997 Dice Game Chap 22 1-to-6 Cntr Adder CntbCnta Point Register Comparator dicesum Test Logic ControlControl Roll D7 D11 D2312 eq Dpathb.vhd Dpatha.vhd control.vhd Rb Ra sp win lose

BR 1/998 Dice Game Flow Chart Roll Dice Sum=7 or 11? Sum=2,3 or 12? Store Sum in Point Register Roll Dice Sum= Point? Reset? Lose Sum= 7? Reset? Win YN Y Y YY Y N N N NN

BR 1/999 Rb?Ra? D7 or D11? Roll D2312? Sp Rb?Ra?Eq?D7? Roll Lose Win S0 S1 S2 S4 S3 S5 Dice Game ASM Chart

BR 1/9910 Dice Game Implementation Dice game implemented in three 22V10 PLDs –control.vhd (Finite State Machine) –dpatha.vhd (two 1-6 counters, adder) –dpathb.vhd (point register, comparator, test logic) The Control FSM is implemented using one-hot encoding. –Outputs q0, q1, q5 are states S0, S1, S5. Output “win” is state S2, output “lose” is state S3. Outputs q0,q1,q5 are available just for debugging purposes.

BR 1/9911 Finite State Machine Changes Asynchronous Reset now use to exit states S2, S3. Resets back to State S0. S2 Win S3 Lose

BR 1/9912 Finite State Machine Changes (cont). Because we don’t have debounced switches, added extra “roll” input called “Ra”. Changed States S1, S5 to use Ra, not Rb. S1 Ra 0 1 Roll S5 Ra 0 1 Roll This means that to roll the dice, you use flip switch Rb up, then down. This starts the dice rolling. To stop the dice, Flip Ra switch up then down.