Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
55854ee1
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
55854ee1
编写于
6月 28, 2020
作者:
Y
Yinan Xu
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/dev-temp-lsu' into roq-writeback-log
上级
b44873f0
cd79f2b3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
79 addition
and
7 deletion
+79
-7
src/main/scala/xiangshan/Bundle.scala
src/main/scala/xiangshan/Bundle.scala
+1
-0
src/main/scala/xiangshan/backend/Backend.scala
src/main/scala/xiangshan/backend/Backend.scala
+1
-0
src/main/scala/xiangshan/backend/dispatch/DispatchQueue.scala
...main/scala/xiangshan/backend/dispatch/DispatchQueue.scala
+2
-2
src/main/scala/xiangshan/backend/exu/Exu.scala
src/main/scala/xiangshan/backend/exu/Exu.scala
+1
-0
src/main/scala/xiangshan/backend/exu/Lsu.scala
src/main/scala/xiangshan/backend/exu/Lsu.scala
+63
-3
src/main/scala/xiangshan/backend/roq/Roq.scala
src/main/scala/xiangshan/backend/roq/Roq.scala
+11
-2
未找到文件。
src/main/scala/xiangshan/Bundle.scala
浏览文件 @
55854ee1
...
...
@@ -91,6 +91,7 @@ class ExuIO extends XSBundle {
// for Lsu
val
dmem
=
new
SimpleBusUC
val
scommit
=
Input
(
UInt
(
3.
W
))
}
class
RoqCommit
extends
XSBundle
{
...
...
src/main/scala/xiangshan/backend/Backend.scala
浏览文件 @
55854ee1
...
...
@@ -84,6 +84,7 @@ class Backend(implicit val p: XSConfig) extends XSModule
// })
lsuExeUnits
.
foreach
(
_
.
io
.
dmem
<>
io
.
dmem
)
lsuExeUnits
.
foreach
(
_
.
io
.
scommit
<>
roq
.
io
.
scommit
)
io
.
frontend
.
redirect
<>
redirect
io
.
frontend
.
commits
<>
roq
.
io
.
commits
...
...
src/main/scala/xiangshan/backend/dispatch/DispatchQueue.scala
浏览文件 @
55854ee1
...
...
@@ -90,8 +90,8 @@ class DispatchQueue(size: Int, enqnum: Int, deqnum: Int, name: String) extends X
XSDebug
(
num_deq
>
0.
U
,
name
+
": num_deq = %d, head = (%d -> %d)\n"
,
num_deq
,
head
,
(
head
+
num_deq
)
%
size
.
U
)
XSDebug
(
num_enq
>
0.
U
,
name
+
"
]
num_enq = %d, tail = (%d -> %d)\n"
,
XSDebug
(
num_enq
>
0.
U
,
name
+
"
:
num_enq = %d, tail = (%d -> %d)\n"
,
num_enq
,
tail
,
(
tail
+
num_enq
)
%
size
.
U
)
XSDebug
(
valid_entries
>
0.
U
,
name
+
"
]
valid_entries = %d, head = (%d, %d), tail = (%d, %d), \n"
,
XSDebug
(
valid_entries
>
0.
U
,
name
+
"
:
valid_entries = %d, head = (%d, %d), tail = (%d, %d), \n"
,
valid_entries
,
head_direction
,
head
,
tail_direction
,
tail
)
}
\ No newline at end of file
src/main/scala/xiangshan/backend/exu/Exu.scala
浏览文件 @
55854ee1
...
...
@@ -107,6 +107,7 @@ trait HasExeUnits{
val
bjUnits
=
bruExeUnit
+:
aluExeUnits
exeUnits
.
foreach
(
_
.
io
.
dmem
:=
DontCare
)
exeUnits
.
foreach
(
_
.
io
.
scommit
:=
DontCare
)
}
class
WriteBackArbMtoN
(
m
:
Int
,
n
:
Int
)
extends
XSModule
{
...
...
src/main/scala/xiangshan/backend/exu/Lsu.scala
浏览文件 @
55854ee1
...
...
@@ -42,6 +42,15 @@ object LSUOpType {
def
atomD
=
"011"
.
U
}
class
StoreQueueEntry
extends
XSBundle
{
val
src1
=
UInt
(
XLEN
.
W
)
val
src2
=
UInt
(
XLEN
.
W
)
val
src3
=
UInt
(
XLEN
.
W
)
val
wdata
=
UInt
(
XLEN
.
W
)
val
func
=
UInt
(
6.
W
)
val
brMask
=
UInt
(
BrqSize
.
W
)
//FIXIT
}
class
Lsu
extends
Exu
(
FuType
.
ldu
.
litValue
(),
readIntRf
=
true
,
...
...
@@ -51,7 +60,29 @@ class Lsu extends Exu(
)
with
NeedImpl
{
override
def
toString
:
String
=
"Lsu"
val
(
valid
,
src1
,
src2
,
wdata
,
func
)
=
(
io
.
in
.
valid
,
io
.
in
.
bits
.
src1
,
io
.
in
.
bits
.
src2
,
io
.
in
.
bits
.
src3
,
io
.
in
.
bits
.
uop
.
ctrl
.
fuOpType
)
// store buffer
val
stqData
=
Reg
(
Vec
(
8
,
new
StoreQueueEntry
))
val
stqValid
=
RegInit
(
VecInit
(
List
.
fill
(
8
)(
false
.
B
)))
val
stqPtr
=
Reg
(
Vec
(
8
,
UInt
(
3.
W
)))
val
stqHead
=
RegInit
(
0.
U
(
3.
W
))
val
stqTail
=
stqPtr
(
0
)
val
stqCommited
=
RegInit
(
0.
U
(
3.
W
))
val
stqFull
=
stqHead
===
7.
U
//stq_valid.reduce(_.valid && _.valid)
val
emptySlot
=
PriorityMux
(~
stqValid
.
asUInt
,
VecInit
(
List
.
tabulate
(
CommitWidth
)(
_
.
U
)))
// when retiringStore, block all input insts
val
isStoreIn
=
io
.
in
.
valid
&&
LSUOpType
.
isStore
(
io
.
in
.
bits
.
uop
.
ctrl
.
fuOpType
)
val
retiringStore
=
Wire
(
Bool
())
//RegInit(false.B)
val
(
validIn
,
src1In
,
src2In
,
src3In
,
funcIn
)
=
(
io
.
in
.
valid
,
io
.
in
.
bits
.
src1
,
io
.
in
.
bits
.
src2
,
io
.
in
.
bits
.
src3
,
io
.
in
.
bits
.
uop
.
ctrl
.
fuOpType
)
val
(
valid
,
src1
,
src2
,
wdata
,
func
)
=
(
Mux
(
retiringStore
,
stqValid
(
stqTail
),
validIn
&&
!
isStoreIn
),
Mux
(
retiringStore
,
stqData
(
stqTail
).
src1
,
src1In
),
Mux
(
retiringStore
,
stqData
(
stqTail
).
src2
,
src2In
),
Mux
(
retiringStore
,
stqData
(
stqTail
).
src3
,
src3In
),
Mux
(
retiringStore
,
stqData
(
stqTail
).
func
,
funcIn
)
)
assert
(!(
retiringStore
&&
!
stqValid
(
stqTail
)))
def
genWmask
(
addr
:
UInt
,
sizeEncode
:
UInt
)
:
UInt
=
{
LookupTree
(
sizeEncode
,
List
(
...
...
@@ -112,12 +143,41 @@ class Lsu extends Exu(
LSUOpType
.
lwu
->
ZeroExt
(
rdataSel
(
31
,
0
),
XLEN
)
))
io
.
in
.
ready
:=
(
state
===
s_idle
)
&&
io
.
out
.
ready
io
.
in
.
ready
:=
io
.
out
.
fire
()
io
.
out
.
valid
:=
Mux
(
isStore
||
partialLoad
,
state
===
s_partialLoad
,
dmem
.
resp
.
fire
()
&&
(
state
===
s_wait_resp
)
)
io
.
out
.
valid
:=
!
retiringStore
&&
(
Mux
(
partialLoad
,
state
===
s_partialLoad
,
dmem
.
resp
.
fire
()
&&
(
state
===
s_wait_resp
))
||
isStoreIn
)
io
.
out
.
bits
.
uop
<>
io
.
in
.
bits
.
uop
io
.
out
.
bits
.
data
:=
Mux
(
partialLoad
,
rdataPartialLoad
,
rdata
)
// io.out.bits.debug.isMMIO := AddressSpace.isMMIO(addr) && io.out.valid
io
.
out
.
bits
.
debug
.
isMMIO
:=
false
.
B
//for debug
// if store, add it to store queue
val
stqEnqueue
=
valid
&&
isStore
&&
!
stqFull
when
(
stqEnqueue
){
stqPtr
(
stqHead
)
:=
emptySlot
stqData
(
emptySlot
).
src1
:=
src1In
stqData
(
emptySlot
).
src2
:=
src2In
stqData
(
emptySlot
).
src3
:=
src3In
stqData
(
emptySlot
).
func
:=
funcIn
stqValid
(
emptySlot
)
:=
true
.
B
}
// if store insts have been commited, send dmem req
retiringStore
:=
stqCommited
>
0.
U
// pop store queue if insts have been commited and dmem req fired successfully
val
stqDequeue
=
retiringStore
&&
state
===
s_partialLoad
when
(
stqDequeue
){
stqValid
(
stqTail
)
:=
false
.
B
}
// update stqTail, stqCommited
stqCommited
:=
stqCommited
+
io
.
scommit
-
stqDequeue
stqTail
:=
stqTail
+
stqEnqueue
-
stqDequeue
XSDebug
(
"state: %d (valid, ready): in (%d,%d) out (%d,%d)\n"
,
state
,
io
.
in
.
valid
,
io
.
in
.
ready
,
io
.
out
.
valid
,
io
.
out
.
ready
)
XSDebug
(
"stqinfo: stqValid.asUInt %b stqHead %d stqTail %d stqCommited %d emptySlot %d\n"
,
stqValid
.
asUInt
,
stqHead
,
stqTail
,
stqCommited
,
emptySlot
)
XSInfo
(
io
.
dmem
.
req
.
fire
()
&&
io
.
dmem
.
req
.
bits
.
cmd
=/=
SimpleBusCmd
.
write
,
"[DMEM LOAD REQ] addr 0x%x wdata 0x%x size %d\n"
,
dmem
.
req
.
bits
.
addr
,
dmem
.
req
.
bits
.
wdata
,
dmem
.
req
.
bits
.
size
)
XSInfo
(
io
.
dmem
.
req
.
fire
()
&&
io
.
dmem
.
req
.
bits
.
cmd
===
SimpleBusCmd
.
write
,
"[DMEM STORE REQ] addr 0x%x wdata 0x%x size %d\n"
,
dmem
.
req
.
bits
.
addr
,
dmem
.
req
.
bits
.
wdata
,
dmem
.
req
.
bits
.
size
)
XSInfo
(
io
.
dmem
.
resp
.
fire
(),
"[DMEM RESP] data %x\n"
,
rdata
)
}
src/main/scala/xiangshan/backend/roq/Roq.scala
浏览文件 @
55854ee1
...
...
@@ -15,6 +15,7 @@ class Roq(implicit val p: XSConfig) extends XSModule {
val
redirect
=
Output
(
Valid
(
new
Redirect
))
val
exeWbResults
=
Vec
(
exuConfig
.
ExuCnt
,
Flipped
(
ValidIO
(
new
ExuOutput
)))
val
commits
=
Vec
(
CommitWidth
,
Valid
(
new
RoqCommit
))
val
scommit
=
Output
(
UInt
(
3.
W
))
})
val
microOp
=
Mem
(
RoqSize
,
new
MicroOp
)
...
...
@@ -74,6 +75,10 @@ class Roq(implicit val p: XSConfig) extends XSModule {
}
val
firedWriteback
=
VecInit
((
0
until
exuConfig
.
ExuCnt
).
map
(
io
.
exeWbResults
(
_
).
fire
())).
asUInt
XSInfo
(
PopCount
(
firedWriteback
)
>
0.
U
,
"writebacked %d insts\n"
,
PopCount
(
firedWriteback
))
for
(
i
<-
0
until
exuConfig
.
ExuCnt
){
XSInfo
(
io
.
exeWbResults
(
i
).
valid
,
"writebacked pc 0x%x wen %d data %d\n"
,
microOp
(
io
.
exeWbResults
(
i
).
bits
.
uop
.
roqIdx
).
cf
.
pc
,
microOp
(
io
.
exeWbResults
(
i
).
bits
.
uop
.
roqIdx
).
ctrl
.
rfWen
,
io
.
exeWbResults
(
i
).
bits
.
data
)
}
// Commit uop to Rename
for
(
i
<-
0
until
CommitWidth
){
...
...
@@ -81,7 +86,7 @@ class Roq(implicit val p: XSConfig) extends XSModule {
val
canCommit
=
if
(
i
!=
0
)
io
.
commits
(
i
-
1
).
valid
else
true
.
B
io
.
commits
(
i
).
valid
:=
valid
(
ringBufferTail
+
i
.
U
)
&&
writebacked
(
ringBufferTail
+
i
.
U
)
&&
canCommit
io
.
commits
(
i
).
bits
.
uop
:=
microOp
(
ringBufferTail
+
i
.
U
)
when
(
microOp
(
i
).
ctrl
.
rfWen
){
archRF
(
microOp
(
i
).
ctrl
.
ldest
)
:=
exuData
(
i
)
}
when
(
microOp
(
ringBufferTail
+
i
.
U
).
ctrl
.
rfWen
){
archRF
(
microOp
(
ringBufferTail
+
i
.
U
).
ctrl
.
ldest
)
:=
exuData
(
ringBufferTail
+
i
.
U
)
}
when
(
io
.
commits
(
i
).
valid
){
valid
(
ringBufferTail
+
i
.
U
)
:=
false
.
B
}
}.
otherwise
{
//state === s_walk
io
.
commits
(
i
).
valid
:=
valid
(
ringBufferWalk
+
i
.
U
)
&&
writebacked
(
ringBufferWalk
+
i
.
U
)
...
...
@@ -96,7 +101,11 @@ class Roq(implicit val p: XSConfig) extends XSModule {
ringBufferTailExtended
:=
ringBufferTailExtended
+
PopCount
(
validCommit
)
}
val
retireCounter
=
Mux
(
state
===
s_idle
,
PopCount
(
validCommit
),
0.
U
)
// TODO: commit store
// commit store
val
validScommit
=
WireInit
(
VecInit
((
0
until
CommitWidth
).
map
(
i
=>
io
.
commits
(
i
).
valid
&&
microOp
(
ringBufferTail
+
i
.
U
).
ctrl
.
fuType
===
FuType
.
ldu
&&
microOp
(
ringBufferTail
+
i
.
U
).
ctrl
.
fuOpType
(
3
))))
//FIXIT
io
.
scommit
:=
PopCount
(
validScommit
.
asUInt
)
XSInfo
(
retireCounter
>
0.
U
,
"retired %d insts\n"
,
retireCounter
)
XSInfo
(
""
)
XSInfo
(){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录