CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Sequential Logic

Simultaneous Push and Pop Resolution

HardLogic CircuitBuild

Pipelined processors often encounter structural hazards when a return instruction and a new function call attempt to access the call stack in the same clock cycle. To prevent pipeline stalls, the stack controller must resolve simultaneous push and pop operations gracefully without corrupting the stack pointer.

Design the pointer and write-enable logic for a synchronous stack controller. The circuit maintains a 4-bit stack pointer ptr that tracks the current top of the stack. When a simultaneous push and pop occurs, the pointer must not change, but the new push_data must immediately overwrite the data being popped at the current pointer address.

| push | pop | ptr (next cycle) | we | waddr | wdata | |--------|-------|--------------------|------|---------|---------| | 0 | 0 | ptr | 0 | 0 | 0 | | 1 | 0 | ptr + 1 | 1 | ptr + 1 | push_data | | 0 | 1 | ptr - 1 | 0 | 0 | 0 | | 1 | 1 | ptr | 1 | ptr | push_data |

Constraints

  • Implement ptr as a 4-bit register initialized to 0 on a synchronous active-high rst.
  • Output 0 for both 4-bit waddr and 8-bit wdata whenever we is 0.
  • Generate control signals for an external RAM rather than instantiating internal memory blocks.

Topics

DatapathRegistersControl Logic

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.

Sign in to solveSee what Pro unlocks

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.

Related problems

  • 3-bit Ripple Counter from Toggle Flip-FlopsEasy
  • D Latch from a 2:1 MUXEasy
  • 2-bit Ring CounterEasy
  • T Flip-Flop from a D Flip-FlopEasy
  • Handshake Deadlock Due to Early ResetHard
  • Reconvergence of Individually Synchronized BitsHard
  • Debug: Asynchronous Clear GlitchHard
  • Clock Gate Enable Crossing DomainsHard

Browse all problems · Learning tracks