When Contexts change -- Context Flush
When a branch is mis-predicted, we need to revert back to the non-speculative context.
- Fetch module sets lastctx = firstctx, asserts FLUSHCTX for one cycle.
We are NOT keeping multiple copies of the Shelves and ROB in order to save resources. This complicates context recovery
In the case of a context flush:
- All shelves, ROB entries with SPEC_FLAG = TRUE must be marked as INVALID.
- From its current position, the tail pointer must be pointed at the first valid entry (first entry with spec_flag = FALSE).
- The head pointer must be set based upon the tail position
- Counting backwards from tail, find first VALID entry.
- Head pointer will be this location + 1.
- Need to handle special cases of buffer empty (no Valid entries) or buffer full (all Valid entries).