A stack controller is a digital circuit in a computer that implements last in firstout (LIFO) storage for temporary data. It operates analogously to a stack of plates where you can put a new plate on the top of the stack or you can take a plate off the top of the stack.
For this circuit, three operations can be performed:
• PUSH adds an element to the top of the stack.
• POP removes the top element from the stack.
• EXCHNG swaps the top two elements of the stack.
When using a stack, 2 types of errors can occur:
• Underflow occurs when a POP operation is attempted on an empty stack or when an EXCHNG is attempted on a stack with fewer than 2 elements on it.
• Overflow occurs when a PUSH operation is attempted on a stack which already contains its maximum number of elements.
Design a circuit which performs error checking on a stack which can contain a maximum of 5 elements. The input signals are PUSH, POP and EXCHNG. You may assume that at most one of the inputs will be asserted in any clock cycle. The outputs of your circuit should be OVF and UNF which indicate overflow and underflow, respectively. Draw the Mealy state diagram for the memory controller