# Hi, I am struggling on this lab because I have no idea where or how to even start. Any advice would be greatly appreciated. --State Machine Homework

#### SergioEE

Joined Feb 10, 2022
15

#### MrSalts

Joined Apr 2, 2020
2,767
Google "elevator state machine" for a start. You are not the first to be assigned this general type of problem. The details of your assignment may be slightly different from others but googling for an example (similar) case will get you started.

#### RBR1317

Joined Nov 13, 2010
712
"I have no idea where or how to even start."

You can't really start until you decide how to represent the elevator. With 8 floors you could use a 3-bit up-down counter or an 8-stage bi-directional shift register (3 flip-flops vs 8 flip-flops). However, fewer flip-flops would require more decoder logic. Yet more flip-flops would require more careful design to not have the elevator be on multiple floors at the same time.

Last edited by a moderator:

#### SergioEE

Joined Feb 10, 2022
15
"I have no idea where or how to even start."

You can't really start until you decide how to represent the elevator. With 8 floors you could use a 3-bit up-down counter or an 8-stage bi-directional shift register (3 flip-flops vs 8 flip-flops). However, fewer flip-flops would require more decoder logic. Yet more flip-flops would require more careful design to not have the elevator be on multiple floors at the same time.
I decided on 8 flip flops but I am stuck on making sure that the doesn’t show up on multiple floors.

#### RBR1317

Joined Nov 13, 2010
712
I am stuck on making sure that the doesn’t show up on multiple floors.
Maybe all that is necessary is a reset button to set the initial state of the state machine, and then make sure that during operation a floor (flip-flop) can only acquire the elevator (value of 1?) from an adjacent floor.

#### boostbuck

Joined Oct 5, 2017
421
If you think about mapping the function of the real machine onto your state machine, an up-down counter might be a better choice. The real lift can only change state by one floor count, cannot jump between separated floors, cannot be at two or more floors at once. All these conditions are inherent in an up-down counter, but must be explicitly managed in a multiple flipflop solution.