EE 316 Computer Engineering Junior Lab Designing State
EE 316 Computer Engineering Junior Lab Designing State machines for a numeric Keypad Spring 2006 1
Topics Designing a state machine to detect key press PLD based design Mealy or Moore? Is clock frequency an issue? Debouncing issues Spring 2006 2
Keypad Hardware State Machine Column Scan 9 Outputs? 1 1 1 GAL 22 V 10 1 Detection of Key press=> input to the state machine } Code for Key press: Output of the State machine Ready or Enable Clock Spring 2006 3 http: //www. webopedia. com/TERM/n/numeric_keypad. html
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 2006 4
GAL 22 V 10 Max 22 inputs Max 10 outputs 8 -16 Product terms 8 Product terms for this macrocell Spring 2006 Ref: Digital Design Principles & practices, John Wakerly 5
State-machine structure (Mealy) Output can change asynchronously with the change of input. Ø Do we need to add debouncing circuits? Ø Or, should we use a pipelined version of Mealy? Spring 2006 Ref: Digital Design Principles & practices, John Wakerly 6
State-machine structure (Moore) ØDo we need keypad debouncing circuits? ØHow many flip-flops do we need? Spring 2006 Ref: Digital Design Principles & practices, John Wakerly 7
Fitting the State Machine on a GAL chip 0 1 1 1 5 V 1 0 1 1 1 1 0 1 1 4. 7 K 1 0 1 1 1 1 1 Key press detect Spring 2006 8
Input State Output key code, Ready A Moore State machine Scan 1111 One input is 0 Resolved 4 code/1 Key detect 4 1111/0 One input is 0 0111 - 7 1011 - 11 1101 - 13 1110 - 14 0011 - 3 0001 - 1 1001 - 9 1000 - 8 1100 - 12 0100 - 4 0110 - 6 0010 - 2 Key press Detect Key detect 1 1111/0 State 1 1111/0 1111 Resolved 1 code/1 12 States? 4 or more Flipflops? State 4 1111/0 1111 Resolved 3 code/1 State 2 1111/0 1111 Key detect 3 1111/0 One input is 0 State 3 1111/0 1111 One input is 0 1111 Spring 2006 Valid Output Key detect 2 1111/0 Resolved 2 code/1 9
Fitting the State Machine on a GAL chip 0 1 1 1 5 V 1 0 1 1 1 1 0 State 1? State 2? State 3? State 4? 1 1 4. 7 K 1 0 1 1 1 1 1 Key press detect We use part of the state variables as outputs of the state machine to be used for column scan. Spring 2006 10
A Mealy State machine Input/key code, Ready One input is 0/code, 1 1111/1111, 0 Key detect State 4 One input is 0/1111, 0 State 1 1111/0 One input is 0/1111, 0 1111/1111, 0 00111 - 7 01011 - 11 01101 - 13 01110 - 14 1111/1111, 0 State 4 1111/0 10111 – 3 Key detect State 1 State 2 1111/0 11011 – 9 11101 - 12 11110 - 6 1111/1111, 0 State 3 1111/0 Key detect State 3 One input is 0/code, 1 One input is 0/1111, 0 1111/1111, 0 Key detect State 2 One input is 0/code, 1 One input is 0/1111, 0 Spring 2006 1111/1111, 0 11
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 Spring 2006 12
- Slides: 12