Debugging Stack Pointer Off By One
Hardware stack pointers must strictly adhere to their empty and full conventions to prevent data corruption. A stack controller manages a 3-bit stack pointer SP that points to the current top element of a memory array.
Expected behavior:
| Push | Pop | Mem_WE | Mem_Addr | SP_Next | |--------|-------|----------|------------|-----------| | 0 | 0 | 0 | SP | SP | | 1 | 0 | 1 | SP + 1 | SP + 1 | | 0 | 1 | 0 | SP | SP - 1 | | 1 | 1 | 0 | SP | SP |
Simulation shows Mem_Addr = 2 for input Push = 1, Pop = 0, and SP = 2. The memory address is incorrect for a push operation, causing the controller to overwrite the current top element instead of writing to the next available slot. Inspect the circuit and correct the fault.
Constraints
- Only modify the internal wiring or logic gates to correct the fault.
- Do not alter the top-level module interface or port names.
Topics
Solve this problem
Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.