Merge pull request #124 from tomverbeure/uinstret

Add uinstret support.
This commit is contained in:
Dolu1990 2020-05-20 10:35:42 +02:00 committed by GitHub
commit 24b676ce30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 10 deletions

View file

@ -159,5 +159,7 @@ object Riscv{
def UCYCLE = 0xC00 // UR Machine ucycle counter.
def UCYCLEH = 0xC80
def UINSTRET = 0xC02 // UR Machine instructions-retired counter.
def UINSTRETH = 0xC82 // UR Upper 32 bits of minstret, RV32I only.
}
}

View file

@ -147,7 +147,8 @@ object BrieyConfig{
minstretAccess = CsrAccess.NONE,
ecallGen = false,
wfiGenAsWait = false,
ucycleAccess = CsrAccess.NONE
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE
)
),
new YamlPlugin("cpu0.yaml")

View file

@ -126,7 +126,8 @@ object VexRiscvAhbLite3{
minstretAccess = CsrAccess.NONE,
ecallGen = false,
wfiGenAsWait = false,
ucycleAccess = CsrAccess.NONE
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE
)
),
new YamlPlugin("cpu0.yaml")

View file

@ -124,7 +124,8 @@ object VexRiscvAvalonForSim{
minstretAccess = CsrAccess.NONE,
ecallGen = false,
wfiGenAsWait = false,
ucycleAccess = CsrAccess.NONE
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE
)
),
new YamlPlugin("cpu0.yaml")

View file

@ -121,7 +121,8 @@ object VexRiscvAvalonWithIntegratedJtag{
minstretAccess = CsrAccess.NONE,
ecallGen = false,
wfiGenAsWait = false,
ucycleAccess = CsrAccess.NONE
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE
)
),
new YamlPlugin("cpu0.yaml")

View file

@ -122,7 +122,8 @@ object VexRiscvAxi4WithIntegratedJtag{
minstretAccess = CsrAccess.NONE,
ecallGen = false,
wfiGenAsWait = false,
ucycleAccess = CsrAccess.NONE
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE
)
),
new YamlPlugin("cpu0.yaml")

View file

@ -38,7 +38,7 @@ case class CsrPluginConfig(
marchid : BigInt,
mimpid : BigInt,
mhartid : BigInt,
misaExtensionsInit : Int,
misaExtensionsInit : Int,
misaAccess : CsrAccess,
mtvecAccess : CsrAccess,
mtvecInit : BigInt,
@ -49,6 +49,7 @@ case class CsrPluginConfig(
mcycleAccess : CsrAccess,
minstretAccess : CsrAccess,
ucycleAccess : CsrAccess,
uinstretAccess : CsrAccess = CsrAccess.NONE,
wfiGenAsWait : Boolean,
ecallGen : Boolean,
xtvecModeGen : Boolean = false,
@ -100,6 +101,7 @@ object CsrPluginConfig{
mcycleAccess = CsrAccess.NONE,
minstretAccess = CsrAccess.NONE,
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE,
wfiGenAsWait = true,
ecallGen = true,
xtvecModeGen = false,
@ -140,6 +142,7 @@ object CsrPluginConfig{
mcycleAccess = CsrAccess.READ_WRITE,
minstretAccess = CsrAccess.READ_WRITE,
ucycleAccess = CsrAccess.READ_ONLY,
uinstretAccess = CsrAccess.READ_ONLY,
wfiGenAsWait = true,
ecallGen = true,
xtvecModeGen = false,
@ -180,7 +183,8 @@ object CsrPluginConfig{
minstretAccess = CsrAccess.READ_WRITE,
ecallGen = true,
wfiGenAsWait = true,
ucycleAccess = CsrAccess.READ_ONLY
ucycleAccess = CsrAccess.READ_ONLY,
uinstretAccess = CsrAccess.READ_ONLY
)
def all2(mtvecInit : BigInt) : CsrPluginConfig = CsrPluginConfig(
@ -202,6 +206,7 @@ object CsrPluginConfig{
ecallGen = true,
wfiGenAsWait = true,
ucycleAccess = CsrAccess.READ_ONLY,
uinstretAccess = CsrAccess.READ_ONLY,
supervisorGen = true,
sscratchGen = true,
stvecAccess = CsrAccess.READ_WRITE,
@ -233,7 +238,8 @@ object CsrPluginConfig{
minstretAccess = CsrAccess.NONE,
ecallGen = false,
wfiGenAsWait = false,
ucycleAccess = CsrAccess.NONE
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE
)
def smallest(mtvecInit : BigInt) = CsrPluginConfig(
@ -254,7 +260,8 @@ object CsrPluginConfig{
minstretAccess = CsrAccess.NONE,
ecallGen = false,
wfiGenAsWait = false,
ucycleAccess = CsrAccess.NONE
ucycleAccess = CsrAccess.NONE,
uinstretAccess = CsrAccess.NONE
)
}
@ -586,6 +593,8 @@ class CsrPlugin(val config: CsrPluginConfig) extends Plugin[VexRiscv] with Excep
//User CSR
ucycleAccess(CSR.UCYCLE, mcycle(31 downto 0))
ucycleAccess(CSR.UCYCLEH, mcycle(63 downto 32))
uinstretAccess(CSR.UINSTRET, minstret(31 downto 0))
uinstretAccess(CSR.UINSTRETH, minstret(63 downto 32))
pipeline(MPP) := mstatus.MPP
}
@ -1148,4 +1157,4 @@ class UserInterruptPlugin(interruptName : String, code : Int, privilege : Int =
csr.rw(csrAddress = CSR.MIE, bitOffset = code, interruptEnable)
}
override def build(pipeline: VexRiscv): Unit = {}
}
}