Tomasulo Reservation Station Entry

Problem Description
This module implements one reservation station entry from Tomasulo's out-of-order execution algorithm.
When issue pulses and the entry is free, it loads the operation code and both source operands — operands already known are stored as values, while unresolved operands store a 2-bit producer tag.
Every clock the entry snoops the Common Data Bus: when cdb_valid is high and cdb_tag matches a stored pending tag, the value is captured and that operand is marked ready. ready_to_dispatch asserts combinationally the moment entry_busy is high and both rj and rk flags are set.
On flush the entry clears completely; flush has priority over all other inputs including cdb_valid and issue. On asynchronous reset every register returns to zero immediately, without waiting for a clock edge.

Interface Definition
Port | Direction | Width | Description |
|---|---|---|---|
| input | 1 | Positive-edge triggered clock |
| input | 1 | Active-high asynchronous reset — clears all registers instantly |
| input | 1 | Level — clears entry (dispatch or misprediction). Highest priority |
| input | 1 | Pulse — load new instruction this cycle. Ignored if entry already busy |
| input | 8 | Value of source operand 1. Valid only when |
| input | 1 | 1 = Vj is known now; 0 = waiting on CDB for tag |
| input | 2 | Producer tag for source 1. Stored when |
| input | 8 | Value of source operand 2. Valid only when |
| input | 1 | 1 = Vk is known now; 0 = waiting on CDB for tag |
| input | 2 | Producer tag for source 2. Stored when |
| input | 4 | Operation code to store in this entry |
| input | 1 | 1 = CDB is broadcasting a result this cycle |
| input | 2 | Tag of the result being broadcast on CDB |
| input | 8 | Value of the result being broadcast on CDB |
| output | 1 | Registered — high while entry holds a valid instruction |
| output | 1 | Combinational — high when busy AND both operands resolved |
| output | 4 | Stored operation code (registered) |
| output | 8 | Resolved value of source operand 1 (registered) |
| output | 8 | Resolved value of source operand 2 (registered) |
Test Cases
Cycle | issue | src1_ready | src1_tag | src2_ready | cdb_valid | cdb_tag | busy_q | rj_q | rk_q | ready_to_dispatch | What happened? |
|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | — | 1 | 0 | — | 0 | 0 | 0 | 0 | issue seen before clock — entry still empty |
2 | 0 | — | — | — | 0 | — | 1 | 1 | 1 | 1 | both srcs ready — FIRES immediately ✓ |
3 | 1 | 0 | 10 | 1 | 0 | — | 0 | 0 | 0 | 0 | issue with src1 waiting (tag=10) |
4 | 0 | — | — | — | 0 | — | 1 | 0 | 1 | 0 | entry busy, src1 parked — not ready ✗ |
5 | 0 | — | — | — | 1 | 10 | 1 | 0 | 1 | 0 | CDB broadcasting tag=10 this cycle |
6 | 0 | — | — | — | 0 | — | 1 | 1 | 1 | 1 | src1 captured from CDB — FIRES ✓ |
7 | flush=1 | — | — | — | 0 | — | 0 | 0 | 0 | 0 | flush clears entry completely ✗ |
8 | reset=1 (async) | 0 | 0 | 0 | 0 | reset mid-wait, instant clear ✗ |
Verilog
Code Editor Access
Log in to write, run and submit your solution to this interview question. It's free.
