Codiode

Stack Overflow Protection

HardLogic CircuitBuild

Software cannot always be trusted to respect memory boundaries. Hardware stack controllers must defend themselves against invalid operations by interlocking control signals before they reach the memory array.

The protection circuit receives a push command and a full status flag. It generates a safe write_en signal that asserts only when a push is requested and the stack is not full. Additionally, if a push is attempted while the stack is full, an overflow_err flag must assert on the next clock cycle and remain high until synchronously reset.

rst push full overflow_err (current) write_en overflow_err (next)
1 0 0 0 0 0
0 0 0 0 0 0
0 1 0 0 1 0
0 1 1 0 0 1
0 0 0 1 0 1
0 1 0 1 1 1

Note: The write_en signal must be forced to 0 when rst is active, regardless of other inputs.

Constraints

  • Implement synchronous active-high reset for all sequential elements.
  • Drive write_en using only combinational logic to ensure zero-cycle latency.
  • Use a D flip-flop to store the overflow_err state.

Topics

DatapathInterlockingState Management

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.

Part of Datapath and Storage

Problem 12 of 29 in the Datapath and Storage track.

Related problems

Browse all problems · Digital logic design practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.