Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
ff287d10
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
大约 1 年 前同步成功
通知
1183
Star
3914
Fork
526
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
XiangShan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ff287d10
编写于
5月 07, 2021
作者:
W
William Wang
提交者:
GitHub
5月 07, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #804 from RISCVERS/dev-config
Config: add MinimalConfig
上级
c11a4d2c
175bcfe9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
151 addition
and
44 deletion
+151
-44
src/main/scala/system/SoC.scala
src/main/scala/system/SoC.scala
+2
-2
src/main/scala/top/ArgParser.scala
src/main/scala/top/ArgParser.scala
+79
-0
src/main/scala/top/Configs.scala
src/main/scala/top/Configs.scala
+59
-0
src/main/scala/top/Top.scala
src/main/scala/top/Top.scala
+3
-13
src/main/scala/xiangshan/Parameters.scala
src/main/scala/xiangshan/Parameters.scala
+6
-6
src/test/scala/top/SimTop.scala
src/test/scala/top/SimTop.scala
+2
-23
未找到文件。
src/main/scala/system/SoC.scala
浏览文件 @
ff287d10
...
...
@@ -12,11 +12,11 @@ case class SoCParameters
(
cores
:
List
[
XSCoreParameters
],
EnableILA
:
Boolean
=
false
,
extIntrs
:
Int
=
150
extIntrs
:
Int
=
150
,
useFakeL3Cache
:
Boolean
=
false
){
val
PAddrBits
=
cores
.
map
(
_
.
PAddrBits
).
reduce
((
x
,
y
)
=>
if
(
x
>
y
)
x
else
y
)
// L3 configurations
val
useFakeL3Cache
=
false
val
L3InnerBusWidth
=
256
val
L3Size
=
4
*
1024
*
1024
// 4MB
val
L3BlockSize
=
64
...
...
src/main/scala/top/ArgParser.scala
0 → 100644
浏览文件 @
ff287d10
package
top
import
chipsalliance.rocketchip.config.
{
Config
,
Parameters
}
import
system.SoCParamsKey
import
xiangshan.DebugOptionsKey
import
scala.annotation.tailrec
import
scala.sys.exit
object
ArgParser
{
// TODO: add more explainations
val
usage
=
"""
|XiangShan Options
|--xs-help print this help message
|--config <ConfigClassName>
|--num-cores <Int>
|--dual-core same as '--num-cores 2'
|--with-dramsim3
|--disable-log
|--disable-perf
|"""
.
stripMargin
def
getConfigByName
(
confString
:
String
)
:
Parameters
=
{
var
prefix
=
"top."
// default package is 'top'
if
(
confString
.
contains
(
'.'
)){
// already a full name
prefix
=
""
}
val
c
=
Class
.
forName
(
prefix
+
confString
).
getConstructor
(
Integer
.
TYPE
)
c
.
newInstance
(
1.
asInstanceOf
[
Object
]).
asInstanceOf
[
Parameters
]
}
def
parse
(
args
:
Array
[
String
],
fpga
:
Boolean
=
true
)
:
(
Parameters
,
Array
[
String
])
=
{
val
default
=
new
DefaultConfig
(
1
)
var
firrtlOpts
=
Array
[
String
]()
@tailrec
def
nextOption
(
config
:
Parameters
,
list
:
List
[
String
])
:
Parameters
=
{
list
match
{
case
Nil
=>
config
case
"--xs-help"
::
tail
=>
println
(
usage
)
if
(
tail
==
Nil
)
exit
(
0
)
nextOption
(
config
,
tail
)
case
"--config"
::
confString
::
tail
=>
nextOption
(
getConfigByName
(
confString
),
tail
)
case
"--num-cores"
::
value
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
SoCParamsKey
=>
up
(
SoCParamsKey
).
copy
(
cores
=
List
.
tabulate
(
value
.
toInt
){
i
=>
up
(
SoCParamsKey
).
cores
.
head
.
copy
(
HartId
=
i
)
}
)
}),
tail
)
case
"--dual-core"
::
tail
=>
nextOption
(
config
,
"--num-cores"
::
"2"
::
tail
)
case
"--with-dramsim3"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
UseDRAMSim
=
true
)
}),
tail
)
case
"--disable-log"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
EnableDebug
=
false
)
}),
tail
)
case
"--disable-perf"
::
tail
=>
nextOption
(
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
EnablePerfDebug
=
false
)
}),
tail
)
case
option
::
tail
=>
// unknown option, maybe a firrtl option, skip
firrtlOpts
:+=
option
nextOption
(
config
,
tail
)
}
}
var
config
=
nextOption
(
default
,
args
.
toList
)
if
(!
fpga
){
config
=
config
.
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
up
(
DebugOptionsKey
).
copy
(
FPGAPlatform
=
false
)
})
}
(
config
,
firrtlOpts
)
}
}
src/main/scala/top/Configs.scala
0 → 100644
浏览文件 @
ff287d10
package
top
import
chisel3._
import
chisel3.util._
import
xiangshan._
import
utils._
import
system._
import
chipsalliance.rocketchip.config._
import
freechips.rocketchip.tile.
{
BusErrorUnit
,
BusErrorUnitParams
,
XLen
}
import
sifive.blocks.inclusivecache.
{
InclusiveCache
,
InclusiveCacheMicroParameters
,
CacheParameters
}
import
xiangshan.backend.dispatch.DispatchParameters
import
xiangshan.cache.
{
DCacheParameters
,
ICacheParameters
,
L1plusCacheParameters
}
import
xiangshan.cache.prefetch.
{
BOPParameters
,
L1plusPrefetcherParameters
,
L2PrefetcherParameters
,
StreamPrefetchParameters
}
class
DefaultConfig
(
n
:
Int
)
extends
Config
((
site
,
here
,
up
)
=>
{
case
XLen
=>
64
case
DebugOptionsKey
=>
DebugOptions
()
case
SoCParamsKey
=>
SoCParameters
(
cores
=
List
.
tabulate
(
n
){
i
=>
XSCoreParameters
(
HartId
=
i
)
}
)
})
// TODO: disable L2 and L3
class
MinimalConfig
(
n
:
Int
=
1
)
extends
Config
(
new
DefaultConfig
(
n
).
alter
((
site
,
here
,
up
)
=>
{
case
SoCParamsKey
=>
up
(
SoCParamsKey
).
copy
(
cores
=
up
(
SoCParamsKey
).
cores
.
map
(
_
.
copy
(
IssQueSize
=
8
,
NRPhyRegs
=
80
,
LoadQueueSize
=
16
,
StoreQueueSize
=
16
,
RoqSize
=
32
,
BrqSize
=
8
,
FtqSize
=
16
,
IBufSize
=
16
,
dpParams
=
DispatchParameters
(
IntDqSize
=
8
,
FpDqSize
=
8
,
LsDqSize
=
8
,
IntDqDeqWidth
=
4
,
FpDqDeqWidth
=
4
,
LsDqDeqWidth
=
4
),
EnableBPD
=
false
,
// disable TAGE
EnableLoop
=
false
,
TlbEntrySize
=
4
,
TlbSPEntrySize
=
2
,
PtwL1EntrySize
=
2
,
PtwL2EntrySize
=
2
,
PtwL3EntrySize
=
4
,
PtwSPEntrySize
=
2
,
useFakeDCache
=
true
,
useFakePTW
=
true
,
useFakeL1plusCache
=
true
,
)),
useFakeL3Cache
=
true
)
})
)
\ No newline at end of file
src/main/scala/top/Top.scala
浏览文件 @
ff287d10
...
...
@@ -319,22 +319,12 @@ class XSTopWithoutDMA()(implicit p: Parameters) extends BaseXSSoc()
}
}
class
DefaultConfig
(
n
:
Int
)
extends
Config
((
site
,
here
,
up
)
=>
{
case
XLen
=>
64
case
DebugOptionsKey
=>
DebugOptions
()
case
SoCParamsKey
=>
SoCParameters
(
cores
=
List
.
tabulate
(
n
){
i
=>
XSCoreParameters
(
HartId
=
i
)
}
)
})
object
TopMain
extends
App
{
override
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
numCores
=
if
(
args
.
contains
(
"--dual-core"
))
2
else
1
val
otherArgs
=
args
.
filterNot
(
_
==
"--dual-core"
)
implicit
val
config
=
new
DefaultConfig
(
numCores
)
XiangShanStage
.
execute
(
otherArgs
,
Seq
(
val
(
config
,
firrtlOpts
)
=
ArgParser
.
parse
(
args
)
XiangShanStage
.
execute
(
firrtlOpts
,
Seq
(
ChiselGeneratorAnnotation
(()
=>
{
val
soc
=
LazyModule
(
new
XSTop
())
val
soc
=
LazyModule
(
new
XSTop
()
(
config
)
)
soc
.
module
})
))
...
...
src/main/scala/xiangshan/Parameters.scala
浏览文件 @
ff287d10
...
...
@@ -14,7 +14,6 @@ case object XSCoreParamsKey extends Field[XSCoreParameters]
case
class
XSCoreParameters
(
HasL2Cache
:
Boolean
=
false
,
HasPrefetch
:
Boolean
=
false
,
HartId
:
Int
=
0
,
XLEN
:
Int
=
64
,
...
...
@@ -23,7 +22,6 @@ case class XSCoreParameters
HasDiv
:
Boolean
=
true
,
HasICache
:
Boolean
=
true
,
HasDCache
:
Boolean
=
true
,
EnableStoreQueue
:
Boolean
=
true
,
AddrBits
:
Int
=
64
,
VAddrBits
:
Int
=
39
,
PAddrBits
:
Int
=
40
,
...
...
@@ -94,6 +92,9 @@ case class XSCoreParameters
PtwL1EntrySize
:
Int
=
16
,
PtwL2EntrySize
:
Int
=
2048
,
//(256 * 8)
NumPerfCounters
:
Int
=
16
,
useFakePTW
:
Boolean
=
false
,
useFakeDCache
:
Boolean
=
false
,
useFakeL1plusCache
:
Boolean
=
false
){
val
loadExuConfigs
=
Seq
.
fill
(
exuParameters
.
LduCnt
)(
LdExeUnitCfg
)
val
storeExuConfigs
=
Seq
.
fill
(
exuParameters
.
StuCnt
)(
StExeUnitCfg
)
...
...
@@ -138,7 +139,6 @@ trait HasXSParameter {
val
HasDiv
=
coreParams
.
HasDiv
val
HasIcache
=
coreParams
.
HasICache
val
HasDcache
=
coreParams
.
HasDCache
val
EnableStoreQueue
=
coreParams
.
EnableStoreQueue
val
AddrBits
=
coreParams
.
AddrBits
// AddrBits is used in some cases
val
VAddrBits
=
coreParams
.
VAddrBits
// VAddrBits is Virtual Memory addr bits
val
PAddrBits
=
coreParams
.
PAddrBits
// PAddrBits is Phyical Memory addr bits
...
...
@@ -197,7 +197,6 @@ trait HasXSParameter {
val
DTLBWidth
=
coreParams
.
LoadPipelineWidth
+
coreParams
.
StorePipelineWidth
val
TlbEntrySize
=
coreParams
.
TlbEntrySize
val
TlbSPEntrySize
=
coreParams
.
TlbSPEntrySize
val
useFakePTW
=
false
val
PtwL3EntrySize
=
coreParams
.
PtwL3EntrySize
val
PtwSPEntrySize
=
coreParams
.
PtwSPEntrySize
val
PtwL1EntrySize
=
coreParams
.
PtwL1EntrySize
...
...
@@ -214,7 +213,6 @@ trait HasXSParameter {
nMissEntries
=
2
)
val
useFakeL1plusCache
=
false
val
l1plusCacheParameters
=
L1plusCacheParameters
(
tagECC
=
Some
(
"secded"
),
dataECC
=
Some
(
"secded"
),
...
...
@@ -222,7 +220,6 @@ trait HasXSParameter {
nMissEntries
=
8
)
val
useFakeDCache
=
false
val
dcacheParameters
=
DCacheParameters
(
tagECC
=
Some
(
"secded"
),
dataECC
=
Some
(
"secded"
),
...
...
@@ -239,6 +236,9 @@ trait HasXSParameter {
// cache hierarchy configurations
val
l1BusDataWidth
=
256
val
useFakeDCache
=
coreParams
.
useFakeDCache
val
useFakePTW
=
coreParams
.
useFakePTW
val
useFakeL1plusCache
=
coreParams
.
useFakeL1plusCache
// L2 configurations
val
useFakeL2Cache
=
useFakeDCache
&&
useFakePTW
&&
useFakeL1plusCache
val
L1BusWidth
=
256
...
...
src/test/scala/top/SimTop.scala
浏览文件 @
ff287d10
...
...
@@ -71,31 +71,10 @@ class SimTop(implicit p: Parameters) extends Module {
object
SimTop
extends
App
{
override
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
useDRAMSim
=
args
.
contains
(
"--with-dramsim3"
)
val
numCores
=
if
(
args
.
contains
(
"--dual-core"
))
2
else
1
val
disableLog
=
args
.
contains
(
"--disable-log"
)
val
disablePerf
=
args
.
contains
(
"--disable-perf"
)
val
firrtlArgs
=
args
.
filterNot
(
_
==
"--with-dramsim3"
).
filterNot
(
_
==
"--dual-core"
).
filterNot
(
_
==
"--disable-log"
).
filterNot
(
_
==
"--disable-perf"
)
val
config
=
new
DefaultConfig
(
numCores
).
alter
((
site
,
here
,
up
)
=>
{
case
DebugOptionsKey
=>
val
default
=
up
(
DebugOptionsKey
)
DebugOptions
(
FPGAPlatform
=
false
,
EnableDebug
=
if
(
disableLog
)
false
else
default
.
EnableDebug
,
EnablePerfDebug
=
if
(
disablePerf
)
false
else
default
.
EnablePerfDebug
,
UseDRAMSim
=
if
(
useDRAMSim
)
true
else
default
.
UseDRAMSim
)
})
val
(
config
,
firrtlOpts
)
=
ArgParser
.
parse
(
args
,
fpga
=
false
)
// generate verilog
XiangShanStage
.
execute
(
firrtl
Arg
s
,
firrtl
Opt
s
,
Seq
(
ChiselGeneratorAnnotation
(()
=>
new
SimTop
()(
config
))
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录