更改CpuConfig

This commit is contained in:
Liphen 2024-03-22 23:16:48 +08:00
parent 81b3915c46
commit e955c3d580
3 changed files with 10 additions and 25 deletions

View File

@ -6,9 +6,11 @@ import cpu.defines.Const._
case class CpuConfig(
// 指令集
val isRV32: Boolean = false, // 是否为RV32
val hasMExtension: Boolean = true, // 是否有乘除法单元
val hasAExtension: Boolean = false, // 是否有原子指令
val hasMExtension: Boolean = true, // 是否实现M扩展即乘除法指令
val hasZicsrExtension: Boolean = false, // 是否实现Zicsr扩展即CSR指令
val hasZifenceiExtension: Boolean = false, // 是否实现Zifencei扩展即FENCE.I指令
val hasAExtension: Boolean = false, // 是否实现A扩展即原子指令
// 特权模式
val hasSMode: Boolean = false, // 是否有S模式
val hasUMode: Boolean = true, // 是否有U模式
val hasUMode: Boolean = false // 是否有U模式
)

View File

@ -58,24 +58,7 @@ object Instructions extends HasInstrType with CoreParameter {
def DecodeTable = RVIInstr.table ++
(if (cpuConfig.hasMExtension) RVMInstr.table else Array.empty) ++
(if (cpuConfig.hasAExtension) RVAInstr.table else Array.empty) ++
Priviledged.table ++
RVZicsrInstr.table ++
RVZifenceiInstr.table
}
object AddressSpace extends CoreParameter {
// (start, size)
// address out of MMIO will be considered as DRAM
def mmio = List(
(0x30000000L, 0x10000000L), // internal devices, such as CLINT and PLIC
(0x40000000L, 0x40000000L) // external devices
)
def isMMIO(addr: UInt) = mmio
.map(range => {
require(isPow2(range._2))
val bits = log2Up(range._2)
(addr ^ range._1.U)(PADDR_WID - 1, bits) === 0.U
})
.reduce(_ || _)
(if (cpuConfig.hasUMode) Privileged.table else Array.empty) ++
(if (cpuConfig.hasZicsrExtension) RVZicsrInstr.table else Array.empty) ++
(if (cpuConfig.hasZifenceiExtension) RVZifenceiInstr.table else Array.empty)
}

View File

@ -3,7 +3,7 @@ package cpu.defines
import chisel3._
import chisel3.util._
object Priviledged extends HasInstrType with CoreParameter {
object Privileged extends HasInstrType with CoreParameter {
def ECALL = BitPat("b000000000000_00000_000_00000_1110011")
def EBREAK = BitPat("b000000000001_00000_000_00000_1110011")
def MRET = BitPat("b001100000010_00000_000_00000_1110011")