Gem5:Minor CPU 模型内幕 ( Inside the Minor CPU model )

原文出处:http://www.gem5.org/docs/html/minor.html

Minor 简介:

       Minor是有序执行的CPU模型(in-order CPU,有序执行技术的CPU,对应out of order,乱序执行),模型有固定的流水线,和可配置的数据结构和执行行为。模型对严格执行顺序的处理器进行建模,可以通过 minortrace / minorview.py 工具可视化 指令在 pipeline 中的位置。目的是提供一个描述微结构的框架,去对应具有类似功能的处理器。

设计哲学:

多线程:

该模型目前不支持多线程处理,但在关键位置(有THREAD注释的地方),需要重组stage数据(理解为 pipeline 的 stage)以支持多线程处理

数据结构:

       避免使用大量指令周期信息来修饰数据结构。只有指令(MinorDyinst)包含其数据内容的很大一部分,这些数据内容的值在构造时没有设置

       所有内部结构都有固定的施工尺寸。队列和FIFOS(minorbuffer,fupipeline)中保存的数据应该有一个bubbleif接口,以便为每种类型提供一个不同的“bubble”/无数据值选项。  

       阶段间“struct”数据打包在按值传递的结构中。只有minordyinst、forwardLineData中的行数据和内存接口对象fetch1::fetchRequest和lsq::lsqRequest是在运行模型时分配的“::new”。

Model structure:

       minorpu类是Gem5中的一个CPU对象。minorpu实现了(cpu.hh)的接口,可以为连接到缓存系统提供数据和指令接口。该模型通过python以类似于其他gem5模型的方式配置。该配置被传递给minorpu::pipeline(属于类pipeline),后者实际上实现了处理器管道。

MinorCPU 的主要层次结构如下:

  • MinorCPU
    • Pipeline - container for the pipeline, owns the cyclic 'tick' event mechanism and the idling (cycle skipping) mechanism.
      • Fetch1 - instruction fetch unit responsible for fetching cache lines (or parts of lines from the I-cache interface)
        • Fetch1::IcachePort - interface to the I-cache from Fetch1
      • Fetch2 - line to instruction decomposition
      • Decode - instruction to micro-op decomposition
      • Execute - instruction execution and data memory interface

         

        • LSQ - load store queue for memory ref. instructions
        • LSQ::DcachePort - interface to the D-cache from Execute 

Key Data Structures

Instruction and line identity: InstId (dyn_inst.hh)

instid包含序列号和线程号,这些序列号和线程号描述单个提取的缓存线和指令的生命周期和指令流关联。

InstID以以下形式之一打印:

- T/S.P/L - for fetched cache lines

- T/S.P/L/F - for instructions before Decode

- T/S.P/L/F.E - for instructions from Decode onwards

例子:

- 0/10.12/5/6.7

InstId's fields are:

Field Symbol Generated by Checked by

Function

 

InstId::threadId T Fetch1 Everywhere the thread number is needed

Thread number (currently always 0).

 

InstId::streamSeqNum S Execute Fetch1, Fetch2, Execute (to discard lines/insts)

Stream sequence number as chosen by Execute. Stream sequence numbers change after changes of PC (branches, exceptions) in Execute and are used to separate pre and post branch instruction streams.

 

InstId::predictionSeqNum P Fetch2 Fetch2 (while discarding lines after prediction)

Prediction sequence numbers represent branch prediction decisions. This is used by Fetch2 to mark lines/instructions according to the last followed branch prediction made by Fetch2. Fetch2 can signal to Fetch1 that it should change its fetch address and mark lines with a new prediction sequence number (which it will only do if the stream sequence number Fetch1 expects matches that of the request).

 

InstId::lineSeqNum L Fetch1 (Just for debugging)

Line fetch sequence number of this cache line or the line this instruction was extracted from.

 

InstId::fetchSeqNum F Fetch2 Fetch2 (as the inst. sequence number for branches)

Instruction fetch order assigned by Fetch2 when lines are decomposed into instructions.

 

InstId::execSeqNum E Decode Execute (to check instruction identity in queues/FUs/LSQ)

Instruction order after micro-op decomposition.

序列号字段彼此独立,尽管例如,指令的instid::execseqnum始终大于等于instid::fetchseqnum,但比较并不有用。

每个序列号字段的起始阶段为该字段保留一个计数器,该计数器可以递增以生成新的唯一编号。 

The pipeline

------------------------------------------------------------------------------
    Key:

    [] : inter-stage BufferBuffer
    ,--.
    |  | : pipeline stage
    `--'
    ---> : forward communication
    <--- : backward communication

    rv : reservation information for input buffers

                ,------.     ,------.     ,------.     ,-------.
 (from  --[]-v->|Fetch1|-[]->|Fetch2|-[]->|Decode|-[]->|Execute|--> (to Fetch1
 Execute)    |  |      |<-[]-|      |<-rv-|      |<-rv-|       |     & Fetch2)
             |  `------'<-rv-|      |     |      |     |       |
             `-------------->|      |     |      |     |       |
                             `------'     `------'     `-------'
------------------------------------------------------------------------------

这四个管道级通过minorbuffer-fifo(stage.hh,最终从timebuffer派生)结构连接在一起,这些结构允许对级间延迟进行建模。在向前方向的相邻阶段(例如:从fetch1到fetch2的线路)之间有一个minorbuffers,在fetch2和fetch1之间有一个反向缓冲区,承载分支预测。

阶段fetch2、解码和执行具有输入缓冲区,每个周期都可以接受上一阶段的输入数据,如果阶段尚未准备好处理该数据,则可以保存该数据。输入缓冲区以接收到的相同形式存储数据,因此解码和执行的输入缓冲区包含前一阶段的输出指令向量(forwardinstdata(pipe_data.hh)),指令和气泡与单个缓冲区条目位于同一位置。

阶段输入缓冲区提供一个与前一阶段的可保留(stage.hh)接口,以允许在其输入缓冲区中保留插槽,并向后通信其输入缓冲区占用情况,以允许前一阶段计划是否应在给定的周期中进行输出。

 

你可能感兴趣的:(gem5)