flaming-cl / 61C

1 stars 0 forks source link

CPU #8

Open flaming-cl opened 3 years ago

flaming-cl commented 3 years ago

CPU

课程教材中的某张图很好,形象简述了CPU内部构造是怎样的 Screen Shot 2021-05-29 at 5 50 59 PM

Datapath

RISC-V CPU处理以下几种常见运算 Screen Shot 2021-05-30 at 12 08 56 AM 先从简单的下手,构造 R type 运算 e.g. add t0, t0, t2
运算五步走: Screen Shot 2021-05-30 at 12 36 29 AM

接着是一步步详细讲

step 1

Screen Shot 2021-05-30 at 2 56 12 PM IMEM从PC获取指令地址,输出指令 R type instructions, 运行完毕,PC就会去到下一个指令

step 2

Screen Shot 2021-05-30 at 3 07 33 PM 从IMEM取出instruction bits
inst[11:7] inst[19:15] inst[24:20] 分别对应 rd, rs1, rs2 (这一步也决定了我们要操作的registers和要使用的内存大小)

step 3

Screen Shot 2021-05-30 at 3 23 36 PM 生成新的register file
abstraction for all registers and some muxing
读写也在此处发生

step 4

Screen Shot 2021-05-30 at 4 11 09 PM 此处用到ALU来处理运算
怎么确定该运行哪个操作?—— ALUSelect

step 5

Screen Shot 2021-05-30 at 7 07 12 PM 把 ALU 的输出送去 regfile,写入新数据

I-type

Screen Shot 2021-05-30 at 8 43 53 PM Imm Gen 生成 immediate
ALU前面加BSel,区分R type, I type

DMEM

For load instructions, DMEM
input: address
output: 32 bit value
(Load instruction will use every component)

control refresher

ALUSel: to perform which operation?
RWEn: write back to register?
BSel: R type or I type?
ImmSel: how to reassemble the immediate?
MemRW: read from memory or write to it?
WBSel: write back to destination register the ALU output or DMEM output?