13. Complete an Elevator Door Controller

Loading simulator…

The provided five-flip-flop register uses the following one-hot assignment. The completion logic drives each existing D input; the register itself is not rebuilt.

StateQ4Q3Q2Q1Q0
CLOSE00001
OPENING00010
OPEN00100
CLOSING01000
WAIT10000

X means either HIGH or LOW; the input does not affect that row.

Current StateobsopnclscofNext StateD4D3D2D1D0
CLOSEX0XXCLOSE00001
CLOSEX1XXOPENING00010
OPENINGXXXXOPEN00100
OPENXX0XOPEN00100
OPENXX1XCLOSING01000
CLOSING1XXXWAIT10000
CLOSING01XXWAIT10000
CLOSING00XXCLOSE00001
WAITXXX0WAIT10000
WAITXXX1OPENING00010

The missing combinational next-state networks are:

D_WAIT    = Q3·(obs + opn) + Q4·cof'
D_CLOSING = Q2·cls
D_OPEN    = Q1 + Q2·cls'
D_OPENING = Q0·opn + Q4·cof
D_CLOSE   = opn'·(Q0 + Q3·obs')

The learner also adds the 2-bit timeout section, which is not pre-placed in the template. 

Both counter flip-flops are asynchronously cleared outside WAIT. 

In EWsim, their active-LOW clear inputs are nClear0 and nClear1. 

While WAIT = 1, the counter advances 00 → 01 → 10 → 11. The logical equations are:

Clear0' = Q4
Clear1' = Q4
cof = C1·C0

With this arrangement, cof requests OPENING after three complete counter increments. 

The exact clock-edge alignment must match the final validation sequence.

The five supplied state outputs are direct Moore decodes of the one-hot register:

CLOSE   = Q0        OPENING = Q1       OPEN = Q2
CLOSING = Q3        WAIT    = Q4