cpu

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLQSize 默认 Load Queue 大小
	DefaultLQSize = 128

	// DefaultSQSize 默认 Store Queue 大小
	DefaultSQSize = 72
)
View Source
const DefaultDIBShift = 6

DefaultDIBShift 默认 DIB 索引位移(对应 64 字节)

View Source
const DefaultDIBSize = 2048

DefaultDIBSize 默认 DIB 大小

View Source
const (
	// DefaultROBSize 默认 ROB 大小
	// Intel Skylake: 224 entries
	// AMD Zen 2: 224 entries
	DefaultROBSize = 224
)
View Source
const InvalidPhysicalRegister = instruction.PhysicalRegisterID(-1)

InvalidPhysicalRegister 无效的物理寄存器 ID(用于 RAT 初始化)

Variables

This section is empty.

Functions

func CalculateOptimalShift

func CalculateOptimalShift(cacheLineSize int) uint

CalculateOptimalShift 根据缓存行大小计算最优位移量

Types

type DIB

type DIB struct {
	// contains filtered or unexported fields
}

DIB (Decoded Instruction Buffer) 类似于 Intel CPU 的 uop cache

工作原理: - 缓存最近译码的指令,避免重复译码 - 按指令地址(IP)的高位索引 - 使用 LRU 替换策略

命中时: - 跳过 Fetch 和 Decode 阶段 - 直接进入 Dispatch - 减少前端延迟

func NewDIB

func NewDIB(maxSize int, shiftAmount uint) *DIB

NewDIB 创建新的 DIB

参数:

  • maxSize: 最大条目数(典型值:1024-4096)
  • shiftAmount: IP 索引位移(典型值:6,对应 64 字节缓存行)

func (*DIB) Check

func (dib *DIB) Check(ip uint64) bool

Check 检查指令是否在 DIB 中

如果命中,更新访问时间。

func (*DIB) Clear

func (dib *DIB) Clear()

Clear 清空所有条目

func (*DIB) Insert

func (dib *DIB) Insert(ip uint64)

Insert 插入指令到 DIB

如果 DIB 已满,使用 LRU 策略驱逐最旧的条目。

func (*DIB) Invalidate

func (dib *DIB) Invalidate(ip uint64)

Invalidate 使某个地址的条目无效

用于自修改代码或代码重定位。

func (*DIB) Size

func (dib *DIB) Size() int

Size 返回当前条目数

type DIBEntry

type DIBEntry struct {
	// contains filtered or unexported fields
}

DIBEntry DIB 缓存条目

type DIBStats

type DIBStats struct {
	Hits   uint64
	Misses uint64
}

HitRate 返回命中率统计(需要配合外部计数器)

func (*DIBStats) CalculateHitRate

func (stats *DIBStats) CalculateHitRate() float64

CalculateHitRate 计算命中率

type LSQEntry

type LSQEntry struct {

	// InstrID 对应的指令 ID (与 OOOModelInstr.InstrID 相同)
	// 用于关联 LSQ 条目和 ROB 中的指令
	InstrID uint64

	// VirtualAddr 虚拟内存地址
	// 对于 load: 读取的地址
	// 对于 store: 写入的地址
	VirtualAddr uint64

	// IP 指令地址 (用于调试和统计)
	IP uint64

	// ASID 地址空间标识符
	ASID [2]uint8

	// ReadyTime 该内存操作准备好执行的时间
	// 对于 load: 地址计算完成的时间
	// 对于 store: 数据和地址都准备好的时间
	ReadyTime uint64

	// FetchIssued 是否已向内存系统发出请求
	// load: 已发出读请求
	// store: 已发出写请求
	FetchIssued bool

	// Completed 内存操作是否完成
	Completed bool

	// CompleteCycle 完成时的周期数
	CompleteCycle uint64

	// ProducerID 产生该地址的指令 ID
	// 如果该 load/store 的地址依赖于前面的指令计算结果,
	// ProducerID 记录那条指令的 ID
	// MaxUint64 表示无依赖
	ProducerID uint64

	// LQDependOnMe Load Queue 中依赖于我的条目列表
	//
	// 对于 Store Queue 中的条目:
	//   记录哪些 load 可能依赖于这个 store (地址匹配或部分重叠)
	//   当 store 完成时,需要检查这些 load 是否可以执行
	//
	// 对于 Load Queue 中的条目:
	//   通常为空,load 不会阻塞其他 load
	LQDependOnMe []*LSQEntry
}

LSQEntry 表示 Load/Store Queue 中的一个条目

LSQ (Load-Store Queue) 用于管理内存操作的顺序和依赖关系: - Load Queue: 跟踪待执行和执行中的 load 操作 - Store Queue: 跟踪待执行和执行中的 store 操作

LSQ 的关键功能:

  1. Store-to-Load Forwarding: 如果 load 地址与之前的 store 地址匹配, 可以直接从 store 数据转发,无需等待 store 写入内存
  2. 内存顺序保证: 确保 load/store 按程序顺序执行
  3. 依赖跟踪: 跟踪哪些 load 依赖于哪些 store

func NewLSQEntry

func NewLSQEntry(instrID uint64, virtualAddr uint64, ip uint64, asid [2]uint8) *LSQEntry

NewLSQEntry 创建新的 LSQ 条目

func (*LSQEntry) AddDependentLoad

func (entry *LSQEntry) AddDependentLoad(loadEntry *LSQEntry)

AddDependentLoad 添加一个依赖于该条目的 load 用于 Store-to-Load Forwarding 的依赖跟踪

func (*LSQEntry) ClearDependents

func (entry *LSQEntry) ClearDependents()

ClearDependents 清空依赖列表 当 store 完成时调用

func (*LSQEntry) HasDependents

func (entry *LSQEntry) HasDependents() bool

HasDependents 返回是否有依赖于该条目的 load

func (*LSQEntry) IsReady

func (entry *LSQEntry) IsReady(currentCycle uint64) bool

IsReady 返回该条目是否准备好执行

type LSQStats

type LSQStats struct {
	TotalLoads          uint64 // 总 load 数
	TotalStores         uint64 // 总 store 数
	ForwardedLoads      uint64 // 被转发的 load 数
	LoadQueueFull       uint64 // LQ 满的次数
	StoreQueueFull      uint64 // SQ 满的次数
	AverageLoadLatency  float64
	AverageStoreLatency float64
}

LSQStats LSQ 统计信息

type LoadStoreQueue

type LoadStoreQueue struct {
	// contains filtered or unexported fields
}

LoadStoreQueue 管理 Load 和 Store 操作

LSQ 的核心功能: 1. 内存顺序保证:确保 load/store 按程序顺序执行 2. Store-to-Load Forwarding:如果 load 的地址与前面的 store 匹配,直接转发数据 3. 依赖跟踪:跟踪哪些 load 依赖于哪些 store

func NewLoadStoreQueue

func NewLoadStoreQueue(maxLQSize, maxSQSize int) *LoadStoreQueue

NewLoadStoreQueue 创建新的 LSQ

func (*LoadStoreQueue) AddLoad

func (lsq *LoadStoreQueue) AddLoad(entry *LSQEntry) error

AddLoad 添加 load 操作到 LQ

func (*LoadStoreQueue) AddStore

func (lsq *LoadStoreQueue) AddStore(entry *LSQEntry) error

AddStore 添加 store 操作到 SQ

func (*LoadStoreQueue) CheckMemoryOrdering

func (lsq *LoadStoreQueue) CheckMemoryOrdering(instr *instruction.OOOModelInstr) bool

CheckMemoryOrdering 检查内存顺序冲突

确保没有违反内存顺序的情况: - Load 不能越过同地址的 Store - Store 不能越过同地址的 Load 或 Store

func (*LoadStoreQueue) CheckStoreToLoadForwarding

func (lsq *LoadStoreQueue) CheckStoreToLoadForwarding(loadEntry *LSQEntry) (bool, *LSQEntry)

CheckStoreToLoadForwarding 检查是否可以从 SQ 转发数据给 load

返回:

  • 如果可以转发,返回 true 和转发的 store 条目
  • 如果不能转发,返回 false

func (*LoadStoreQueue) FindLoadByInstrID

func (lsq *LoadStoreQueue) FindLoadByInstrID(instrID uint64) *LSQEntry

FindLoadByInstrID 通过指令 ID 查找 load 条目

func (*LoadStoreQueue) FindStoreByInstrID

func (lsq *LoadStoreQueue) FindStoreByInstrID(instrID uint64) *LSQEntry

FindStoreByInstrID 通过指令 ID 查找 store 条目

func (*LoadStoreQueue) GetAllLoads

func (lsq *LoadStoreQueue) GetAllLoads() []*LSQEntry

GetAllLoads 返回所有 load 条目(用于调试)

func (*LoadStoreQueue) GetAllStores

func (lsq *LoadStoreQueue) GetAllStores() []*LSQEntry

GetAllStores 返回所有 store 条目(用于调试)

func (*LoadStoreQueue) GetReadyLoads

func (lsq *LoadStoreQueue) GetReadyLoads(currentCycle uint64) []*LSQEntry

GetReadyLoads 返回准备好发送到内存系统的 load 请求

func (*LoadStoreQueue) GetReadyStores

func (lsq *LoadStoreQueue) GetReadyStores(currentCycle uint64) []*LSQEntry

GetReadyStores 返回准备好发送到内存系统的 store 请求

func (*LoadStoreQueue) GetStats

func (lsq *LoadStoreQueue) GetStats() LSQStats

GetStats 返回统计信息

func (*LoadStoreQueue) HandleLoadResponse

func (lsq *LoadStoreQueue) HandleLoadResponse(instrID uint64, cycle uint64) bool

HandleLoadResponse 处理 load 响应

func (*LoadStoreQueue) HandleStoreResponse

func (lsq *LoadStoreQueue) HandleStoreResponse(instrID uint64, cycle uint64) bool

HandleStoreResponse 处理 store 响应

func (*LoadStoreQueue) HasPendingMemoryRequest

func (lsq *LoadStoreQueue) HasPendingMemoryRequest() bool

HasPendingMemoryRequest 检查是否有待处理的内存请求

func (*LoadStoreQueue) IsLoadQueueFull

func (lsq *LoadStoreQueue) IsLoadQueueFull() bool

IsLoadQueueFull 检查 LQ 是否已满

func (*LoadStoreQueue) IsStoreQueueFull

func (lsq *LoadStoreQueue) IsStoreQueueFull() bool

IsStoreQueueFull 检查 SQ 是否已满

func (*LoadStoreQueue) LoadQueueSize

func (lsq *LoadStoreQueue) LoadQueueSize() int

LoadQueueSize 返回 LQ 当前大小

func (*LoadStoreQueue) RemoveLoad

func (lsq *LoadStoreQueue) RemoveLoad(instrID uint64) bool

RemoveLoad 从 LQ 移除 load(当指令退休时)

func (*LoadStoreQueue) RemoveStore

func (lsq *LoadStoreQueue) RemoveStore(instrID uint64) bool

RemoveStore 从 SQ 移除 store(当指令退休时)

func (*LoadStoreQueue) Reset

func (lsq *LoadStoreQueue) Reset()

Reset 重置 LSQ(用于测试)

func (*LoadStoreQueue) StoreQueueSize

func (lsq *LoadStoreQueue) StoreQueueSize() int

StoreQueueSize 返回 SQ 当前大小

type O3CPU

type O3CPU struct {
	// contains filtered or unexported fields
}

O3CPU Out-of-Order CPU 模型

实现完整的乱序执行流水线:

  1. Fetch: 从 trace 读取指令(检查 DIB)
  2. Decode: 译码和寄存器重命名
  3. Dispatch: 分发到保留站
  4. Schedule: 选择就绪指令执行
  5. Execute: 执行和内存操作
  6. Retire: 按序退休

func NewO3CPU

func NewO3CPU(traceReader trace.TraceReader, config O3CPUConfig) *O3CPU

NewO3CPU 创建新的 O3 CPU

func (*O3CPU) GetLSQStats

func (cpu *O3CPU) GetLSQStats() LSQStats

GetLSQStats 返回 LSQ 统计信息(用于测试)

func (*O3CPU) GetReadyLoads

func (cpu *O3CPU) GetReadyLoads(currentCycle uint64) []*LSQEntry

GetReadyLoads 返回准备好的 load 请求(用于框架集成)

func (*O3CPU) GetReadyStores

func (cpu *O3CPU) GetReadyStores(currentCycle uint64) []*LSQEntry

GetReadyStores 返回准备好的 store 请求(用于框架集成)

func (*O3CPU) GetStats

func (cpu *O3CPU) GetStats() O3CPUStats

GetStats 返回统计信息

func (*O3CPU) HandleLoadResponse

func (cpu *O3CPU) HandleLoadResponse(instrID uint64, cycle uint64) bool

HandleLoadResponse 处理 load 响应(用于框架集成)

func (*O3CPU) HandleStoreResponse

func (cpu *O3CPU) HandleStoreResponse(instrID uint64, cycle uint64) bool

HandleStoreResponse 处理 store 响应(用于框架集成)

func (*O3CPU) Run

func (cpu *O3CPU) Run(warmupInstrs, simInstrs uint64)

Run 运行仿真直到指定的指令数

func (*O3CPU) SetL1DCache

func (cpu *O3CPU) SetL1DCache(cache interface {
	Access(addr uint64, vaddr uint64, instrID uint64, accessType compcache.AccessType, cycle uint64) (hit bool, readyCycle uint64, mshrIndex int)
	HandleFill(addr uint64, data uint64, cycle uint64) bool
	SetStandaloneMode(standalone bool)
	GetStats() interface{}
})

SetL1DCache 设置 L1D Cache

参数: - cache: 实现了Cache接口的对象(通常是*cache.SetAssociativeCache)

func (*O3CPU) SetStandaloneMode

func (cpu *O3CPU) SetStandaloneMode(standalone bool)

SetStandaloneMode 设置独立模式

standaloneMode=true: 内存操作自动完成(用于测试) standaloneMode=false: 内存操作等待框架响应(用于集成)

func (*O3CPU) Tick

func (cpu *O3CPU) Tick()

Tick 执行一个时钟周期

执行顺序完全对应 ChampSim 的 O3_CPU::operate(): 1. Retire: 退休已完成的指令 2. Complete: 标记已执行指令的寄存器为有效 3. Execute: 执行已调度的指令 4. Schedule: 调度就绪的指令 5. Dispatch: 分发指令到保留站 6. Decode: 译码指令 7. Fetch: 从 trace 读取指令

type O3CPUConfig

type O3CPUConfig struct {

	// FetchWidth 每周期 Fetch 的指令数(典型:4-6)
	FetchWidth int

	// DecodeWidth 每周期 Decode 的指令数(典型:4-6)
	DecodeWidth int

	// DispatchWidth 每周期 Dispatch 的指令数(典型:4-6)
	DispatchWidth int

	// ScheduleWidth 每周期 Schedule 的指令数(典型:8-10)
	ScheduleWidth int

	// ExecuteWidth 每周期 Execute 的指令数(典型:8-10)
	ExecuteWidth int

	// RetireWidth 每周期 Retire 的指令数(典型:4-6)
	RetireWidth int

	// FetchQueueSize Fetch 队列大小
	FetchQueueSize int

	// DecodeQueueSize Decode 队列大小
	DecodeQueueSize int

	// ROBSize ROB 大小
	ROBSize int

	// LQSize Load Queue 大小
	LQSize int

	// SQSize Store Queue 大小
	SQSize int

	// PhysicalRegisters 物理寄存器数量
	PhysicalRegisters int

	// DIBSize DIB 大小
	DIBSize int

	// FetchLatency Fetch 延迟(周期)
	FetchLatency uint64

	// DecodeLatency Decode 延迟(周期)
	DecodeLatency uint64

	// DispatchLatency Dispatch 延迟(周期)
	DispatchLatency uint64

	// ExecuteLatency 执行延迟(周期)
	ExecuteLatency uint64
}

O3CPUConfig CPU 配置参数

func DefaultO3CPUConfig

func DefaultO3CPUConfig() O3CPUConfig

DefaultO3CPUConfig 返回默认配置(基于 Intel Skylake)

type O3CPUStats

type O3CPUStats struct {
	// 总周期数
	TotalCycles uint64

	// 总指令数
	TotalInstructions uint64

	// IPC (Instructions Per Cycle)
	IPC float64

	// 各阶段停顿
	FetchStalls    uint64
	DecodeStalls   uint64
	DispatchStalls uint64
	ExecuteStalls  uint64

	// 分支预测
	BranchMispredictions uint64
	TotalBranches        uint64
}

O3CPUStats CPU 统计信息

type PendingMemOp

type PendingMemOp struct {
	InstrID    uint64 // 指令ID
	ReadyCycle uint64 // 数据就绪周期
}

PendingMemOp 待处理的内存操作

type PhysicalRegister

type PhysicalRegister struct {
	// ArchRegIndex 对应的架构寄存器索引
	ArchRegIndex uint8

	// ProducingInstructionID 产生该寄存器值的指令 ID
	ProducingInstructionID uint64

	// Valid 数据是否有效(产生指令是否已 complete)
	// 当 Valid=false 时,依赖该寄存器的指令无法 schedule
	Valid bool

	// Busy 寄存器是否在流水线中使用
	Busy bool
}

PhysicalRegister 物理寄存器

对应 ChampSim 的 physical_register 结构

type ROBStats

type ROBStats struct {
	TotalRetired uint64 // 总退休指令数
	ROBFull      uint64 // ROB 满的次数
}

ROBStats ROB 统计信息

type RegisterAllocator

type RegisterAllocator struct {
	// contains filtered or unexported fields
}

RegisterAllocator 物理寄存器分配器

完全对应 ChampSim 的 RegisterAllocator,实现寄存器重命名和依赖跟踪。

核心概念: - Frontend RAT: Dispatch 时使用,维护最新的架构→物理寄存器映射 - Backend RAT: Retire 时更新,表示已提交的映射 - 物理寄存器有 valid 标志,只有 valid=true 时依赖指令才能 schedule

func NewRegisterAllocator

func NewRegisterAllocator(numPhysical int) *RegisterAllocator

NewRegisterAllocator 创建寄存器分配器

参数:

  • numPhysical: 物理寄存器总数(典型值:128-256)

对应 ChampSim 的构造函数

func (*RegisterAllocator) AllocatedCount

func (ra *RegisterAllocator) AllocatedCount() int

AllocatedCount 返回已分配的寄存器数量

func (*RegisterAllocator) AvailableCount

func (ra *RegisterAllocator) AvailableCount() int

AvailableCount 返回空闲寄存器数量

func (*RegisterAllocator) CompleteDestRegister

func (ra *RegisterAllocator) CompleteDestRegister(physReg instruction.PhysicalRegisterID)

CompleteDestRegister 标记物理寄存器数据为有效

在 Execute 完成后调用,表示寄存器的数据已经产生。 这会允许依赖该寄存器的指令进行 schedule。

参数:

  • physReg: 物理寄存器 ID

对应 ChampSim 的 complete_dest_register()

func (*RegisterAllocator) CountRegDependencies

func (ra *RegisterAllocator) CountRegDependencies(instr *instruction.OOOModelInstr) int

CountRegDependencies 计算指令的寄存器依赖数量

统计源寄存器中有多少个数据尚未有效(Valid=false)。

参数:

  • instr: 指令

返回:

  • 未就绪的源寄存器数量

对应 ChampSim 的 count_reg_dependencies()

func (*RegisterAllocator) FreeRegister

func (ra *RegisterAllocator) FreeRegister(physReg instruction.PhysicalRegisterID)

FreeRegister 释放物理寄存器

清空寄存器状态并加入空闲队列。

参数:

  • physReg: 物理寄存器 ID

对应 ChampSim 的 free_register()

func (*RegisterAllocator) IsAllocated

func (ra *RegisterAllocator) IsAllocated(archReg uint8) bool

IsAllocated 检查架构寄存器是否已分配

参数:

  • archReg: 架构寄存器编号

返回:

  • true 如果架构寄存器已有物理寄存器映射

对应 ChampSim 的 isAllocated()

func (*RegisterAllocator) IsValid

IsValid 检查物理寄存器数据是否有效

参数:

  • physReg: 物理寄存器 ID

返回:

  • true 如果寄存器数据有效

对应 ChampSim 的 isValid()

func (*RegisterAllocator) RenameDestRegister

func (ra *RegisterAllocator) RenameDestRegister(archReg uint8, producerID uint64) instruction.PhysicalRegisterID

RenameDestRegister 重命名目标寄存器

在 Dispatch 阶段调用,为写操作分配新的物理寄存器。

参数:

  • archReg: 架构寄存器编号
  • producerID: 产生该寄存器值的指令 ID

返回:

  • 分配的物理寄存器 ID

对应 ChampSim 的 rename_dest_register()

func (*RegisterAllocator) RenameSrcRegister

func (ra *RegisterAllocator) RenameSrcRegister(archReg uint8) instruction.PhysicalRegisterID

RenameSrcRegister 重命名源寄存器

在 Dispatch 阶段调用,查找架构寄存器对应的物理寄存器。 如果架构寄存器尚未映射(trace 从程序中间开始),则分配一个物理寄存器。

参数:

  • archReg: 架构寄存器编号

返回:

  • 物理寄存器 ID

对应 ChampSim 的 rename_src_register()

func (*RegisterAllocator) Reset

func (ra *RegisterAllocator) Reset()

Reset 重置分配器

func (*RegisterAllocator) ResetFrontendRAT

func (ra *RegisterAllocator) ResetFrontendRAT()

ResetFrontendRAT 重置 Frontend RAT 为 Backend RAT

用于分支预测错误后恢复正确状态。

对应 ChampSim 的 reset_frontend_RAT()

func (*RegisterAllocator) RetireDestRegister

func (ra *RegisterAllocator) RetireDestRegister(physReg instruction.PhysicalRegisterID)

RetireDestRegister 在 Retire 阶段更新 Backend RAT

更新 Backend RAT 到新的物理寄存器,并释放旧的物理寄存器。

参数:

  • physReg: 新的物理寄存器 ID

对应 ChampSim 的 retire_dest_register()

func (*RegisterAllocator) TotalCount

func (ra *RegisterAllocator) TotalCount() int

TotalCount 返回物理寄存器总数

type ReorderBuffer

type ReorderBuffer struct {
	// contains filtered or unexported fields
}

ReorderBuffer (ROB) 重排序缓冲区

ROB 是乱序执行 CPU 的核心组件: - 跟踪所有在执行中的指令 - 保证按程序顺序退休(Retire) - 处理分支预测错误时的恢复

ROB 使用环形缓冲区实现,有 head 和 tail 指针: - tail: 新指令插入位置(分配) - head: 下一个要退休的指令(退休)

func NewReorderBuffer

func NewReorderBuffer(maxSize int) *ReorderBuffer

NewReorderBuffer 创建新的 ROB

参数:

  • maxSize: ROB 最大容量(典型值:128-256)

func (*ReorderBuffer) Add

func (rob *ReorderBuffer) Add(instr *instruction.OOOModelInstr) error

Add 添加指令到 ROB(在 tail 位置)

返回错误如果 ROB 已满。

func (*ReorderBuffer) AvailableSpace

func (rob *ReorderBuffer) AvailableSpace() int

AvailableSpace 返回 ROB 中剩余空间

func (*ReorderBuffer) FindByInstrID

func (rob *ReorderBuffer) FindByInstrID(instrID uint64) *instruction.OOOModelInstr

FindByInstrID 通过指令 ID 查找 ROB 中的指令

func (*ReorderBuffer) Flush

func (rob *ReorderBuffer) Flush(branchInstrID uint64) int

Flush 清空 ROB(分支预测错误时使用)

保留 head 到 branchInstrID 之间的指令, 清空 branchInstrID 之后的所有指令。

返回被清空的指令数量。

func (*ReorderBuffer) FlushAll

func (rob *ReorderBuffer) FlushAll()

FlushAll 清空整个 ROB(用于异常处理或重置)

func (*ReorderBuffer) GetAllInstructions

func (rob *ReorderBuffer) GetAllInstructions() []*instruction.OOOModelInstr

GetAllInstructions 返回 ROB 中所有指令(按程序顺序)

用于调试和统计。

func (*ReorderBuffer) GetStats

func (rob *ReorderBuffer) GetStats() ROBStats

GetStats 返回统计信息

func (*ReorderBuffer) Head

Head 返回 head 位置的指令(不移除)

func (*ReorderBuffer) IsEmpty

func (rob *ReorderBuffer) IsEmpty() bool

IsEmpty 检查 ROB 是否为空

func (*ReorderBuffer) IsFull

func (rob *ReorderBuffer) IsFull() bool

IsFull 检查 ROB 是否已满

func (*ReorderBuffer) MaxSize

func (rob *ReorderBuffer) MaxSize() int

MaxSize 返回 ROB 的最大容量

func (*ReorderBuffer) PeekAt

func (rob *ReorderBuffer) PeekAt(i int) *instruction.OOOModelInstr

PeekAt 返回 ROB 中第 i 个位置的指令(不移除)

参数:

  • i: 从 head 开始的偏移量(0 表示 head)

返回:

  • 指令指针,如果索引越界则返回 nil

用于 complete_inflight_instruction() 扫描整个 ROB

func (*ReorderBuffer) ResetStats

func (rob *ReorderBuffer) ResetStats()

ResetStats 重置统计信息(不清空 ROB)

func (*ReorderBuffer) Retire

func (rob *ReorderBuffer) Retire() *instruction.OOOModelInstr

Retire 退休 head 位置的指令

只有当 head 指令完成时才能退休。 返回退休的指令,如果不能退休则返回 nil。

func (*ReorderBuffer) Size

func (rob *ReorderBuffer) Size() int

Size 返回当前 ROB 中的指令数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL