Spring EE 316 Computer Engineering Junior Lab Designing State machines for a numeric Keypad
Spring Topics Designing a state machine to detect key press PLD based design Mealy or Moore? Is clock frequency an issue? Debouncing issues
Spring Keypad Hardware GAL22V10 } Ready or Enable Column Scan Detection of Key press=> input to the state machine Code for Key press: Output of the State machine Clock State Machine 9 Outputs?
Spring Design alternatives Which of the two state machines, Mealy or Moore, should we use? Since we need 9 outputs for the state machine, 9 flip-flops are used up. Can we fit the keypad state machine on a single GAL chip?
Spring GAL22V10 Ref: Digital Design Principles & practices, John Wakerly Max 22 inputs Max 10 outputs 8-16 Product terms 8 Product terms for this macrocell
Spring Ref: Digital Design Principles & practices, John Wakerly State-machine structure (Mealy) Do we need to add debouncing circuits? Or, should we use a pipelined version of Mealy? Output can change asynchronously with the change of input.
Spring Ref: Digital Design Principles & practices, John Wakerly State-machine structure (Moore) Do we need keypad debouncing circuits? How many flip-flops do we need?
Spring V K Key press detect Fitting the State Machine on a GAL chip
Spring State Output key code, Ready A Moore State machine One input is 0 State /0 State /0 State /0 State /0 Key detect /0 One input is Key detect /0 Key detect /0 Key detect /0 Resolved 1 code/ Resolved 2 code/1 Resolved 3 code/1 Resolved 4 code/ Input Key detect /0 One input is 0 Key detect /0 12 States? 4 or more Flipflops? Scan Key press Detect Valid Output
Spring V State 1? State 2? 4.7 K State 3? State 4? Key press detect Fitting the State Machine on a GAL chip We use part of the state variables as outputs of the state machine to be used for column scan
Spring Input/key code, Ready One input is 0/1111, 0 Key detect State 1 Key detect State 2 Key detect State 3 Key detect State 4 One input is 0/1111, /1111, 0 A Mealy State machine 1111/1111, 0 One input is 0/code, 1 State /0 State /0 State /0 State / – –
Spring How to choose the proper clock frequency The clock frequency should be slow enough so that period is comparable to or larger than the keypad bouncing times. The clock frequency should be fast enough so that it will be able to detect the key press even if it is released very quickly