Return Address Predictor

The return address predictor (RAP) is a memory device used to [speculatively] track the value of a register (the link register) which links the target of a return instruction to the most-recent previous call instruction.

In the RISC-V ISA, call and return instructions are implemented by expecting the programmer to use particular encodings of JAL and JALR. Software is responsible for using the general-purpose registers to link a pair of call and return instructions. The RISC-V ISA suggests that registers x1 and x5 should be used as link registers, and that implementations can use this as a way to distinguish the intent of JAL and JALR instructions.

  1. When we encounter a call, save the return address somewhere

  2. When we encounter a return, predict with the most-recent previous return address

class ember.bp.rap.RapRequest(num_entries: int)
class ember.bp.rap.RapWriteRequest(num_entries: int)
class ember.bp.rap.RapResponse(num_entries: int)
class ember.bp.rap.RapPushRequest(num_entries: int)

A request to push an address onto the RAP stack.

class ember.bp.rap.RapPushResponse(num_entries: int)

Response to a RAP push request.

class ember.bp.rap.RapPopRequest(num_entries: int)

A request to pop an address off the RAP stack.

class ember.bp.rap.RapPopResponse(num_entries: int)

Response to a RAP pop request.

class ember.bp.rap.ReturnAddressPredictor(*args, src_loc_at=0, **kwargs)

A memory device used to track predicted return addresses.

Warning

At the moment, this is a simple memory device that does not accomodate for overflow/underflow conditions, and we assume that other logic in the pipeline is responsible for interacting with the RAP in a way that implements a stack.