系列文章 : [gem5] 從零開始的 gem5 學習筆記
class Pipeline 會繼承 class Ticked
https://github.com/gem5/gem5/blob/v25.1.0.0/src/cpu/minor/pipeline.hh#L72
https://github.com/gem5/gem5/blob/v25.1.0.0/src/sim/ticked_object.hh#L61
class Minor CPU 會繼承 class ClockedObject
https://github.com/gem5/gem5/blob/v25.1.0.0/src/cpu/minor/cpu.hh#L84
https://github.com/gem5/gem5/blob/v25.1.0.0/src/cpu/base.hh#L106
https://github.com/gem5/gem5/blob/v25.1.0.0/src/sim/clocked_object.hh#L234
在 class MinorCPU 裡面,會去 new 一個 pipeline,並把自己傳進 class Pipeline 的建構子。
https://github.com/gem5/gem5/blob/v25.1.0.0/src/cpu/minor/cpu.cc#L79
在 class Pipeline 裡面,會把 class MinorCPU 的指標再傳給 class Ticked 的建構子。
https://github.com/gem5/gem5/blob/v25.1.0.0/src/cpu/minor/pipeline.cc#L58 https://github.com/gem5/gem5/blob/v25.1.0.0/src/sim/ticked_object.hh#L94-L96
在 class Ticked 裡面,會利用 class ClockedObject 的指標,每一個 Cycle 都去 schedule 一個 event,在每一個 cycle 都觸發 Ticked::evaluate function
https://github.com/gem5/gem5/blob/v25.1.0.0/src/sim/ticked_object.cc#L51
https://github.com/gem5/gem5/blob/v25.1.0.0/src/sim/ticked_object.cc#L61-L68
在 class Pipeline 這邊,會去 override class Ticked 的 evaluate function。
在每一個 cycle,class Pipeline 會去 evaluate 每一個 stage,以及每一個 Latch。
以此來模擬每一個 cycle 的 pipeline 推進。
https://github.com/gem5/gem5/blob/v25.1.0.0/src/cpu/minor/pipeline.cc#L125-L146