RISC-V:控制与状态寄存器(CSR)
芯片示意图
管脚信息
名称 | 方向 | 类型 | 作用 |
---|---|---|---|
interrupts | input | CoreInterrupts | 输入:相关的中断信息 |
hartid | input | UInt | 输入:硬件线程id |
rw | exchange | 结构体 | 输入:指令 输出:操作的寄存器结果 |
decode | exchange | Vec(new CSRDecodeIO) | 输入:指令 输出:异常控制线 |
csr_stall | output | Bool | 输出:csr暂停(stall) |
eret | output | Bool | 是否执行call、break、ret |
singleStep | output | Bool | 输出:单步控制 |
status | output | MStatus | 输出:mstatus情况 |
ptbr | output | PTBR | 输出:翻译和保护寄存器情况 |
evec | output | UInt | 输出:陷入地址 |
exception | input | Bool | 输入:外部异常 |
retire | input | UInt | 输入:是否有效 |
cause | input | UInt | 输入:中断原因 |
pc | input | UInt | 输入:当前pc值 |
tval | input | UInt | 输入:引起异常的值 |
time | output | UInt | 输出:进程执行周期 |
fcsr_rm | output | Bits | 输出:浮点读舍入模式 |
fcsr_flags | exchange | Valid(Bits) | 交换:浮点读异常标志 |
set_fs_dirty | input | Bool | 输入:指定浮点脏标志 |
rocc_interrupt | input | Bool | 输入:协处理器中断 |
interrupt | output | Bool | 输出:判断是否发生中断 |
interrupt_cause | output | UInt | 输出:判断发生中断的原因 |
bp | output | Vec(new BP) | 输出:断点情况 |
pmp | output | Vec(new PMP) | 输出:内存保护情况 |
counters | exchange | Vec(new PerfCounterIO) | 输入:hpmcounter的inc 输出:hpmevent情况 |
csrw_counter | output | UInt | 输出:使用的counter下标 |
inst | input | Vec(UInt) | 输入:trace命令 |
trace | output | Vec(new TracedInstruction) | 输出:trace情况 |
customCSRs | exchange | Vec(new CustomCSRIO) | 交换:传统csr |
流程说明
1.reg_mip寄存器
(1)reg_mip结构
class MIP(implicit p: Parameters) extends CoreBundle()(p)
with HasCoreParameters {
val lip = Vec(coreParams.nLocalInterrupts, Bool())
val zero2 = Bool()
val debug = Bool() // keep in sync with CSR.debugIntCause
val zero1 = Bool()
val rocc = Bool()
val meip = Bool()
val heip = Bool()
val seip