Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
bf4f68f6
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
bf4f68f6
编写于
8月 13, 2020
作者:
Y
Yinan Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dispatch queue: fix needReplay and maskedNeedReplay
上级
0953aabf
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
30 addition
and
8 deletion
+30
-8
src/main/scala/xiangshan/backend/dispatch/DispatchQueue.scala
...main/scala/xiangshan/backend/dispatch/DispatchQueue.scala
+30
-8
未找到文件。
src/main/scala/xiangshan/backend/dispatch/DispatchQueue.scala
浏览文件 @
bf4f68f6
...
...
@@ -64,6 +64,16 @@ class DispatchQueue(size: Int, enqnum: Int, deqnum: Int, replayWidth: Int) exten
val
dispatchEntries
=
distanceBetween
(
tailPtr
,
dispatchPtr
)
val
commitEntries
=
validEntries
-
dispatchEntries
val
emptyEntries
=
size
.
U
-
validEntries
val
isFull
=
tailDirection
=/=
headDirection
&&
tailIndex
===
headIndex
val
isFullDispatch
=
dispatchDirection
=/=
headDirection
&&
dispatchIndex
===
headIndex
def
rangeMask
(
start
:
UInt
,
end
:
UInt
)
:
UInt
=
{
val
startMask
=
(
1.
U
((
size
+
1
).
W
)
<<
start
(
indexWidth
-
1
,
0
)).
asUInt
-
1.
U
val
endMask
=
(
1.
U
((
size
+
1
).
W
)
<<
end
(
indexWidth
-
1
,
0
)).
asUInt
-
1.
U
val
xorMask
=
startMask
(
size
-
1
,
0
)
^
endMask
(
size
-
1
,
0
)
Mux
(
start
(
indexWidth
)
===
end
(
indexWidth
),
xorMask
,
~
xorMask
)
}
val
dispatchedMask
=
rangeMask
(
headPtr
,
dispatchPtr
)
/**
* Part 1: update states and uops when enqueue, dequeue, commit, redirect/replay
...
...
@@ -126,7 +136,7 @@ class DispatchQueue(size: Int, enqnum: Int, deqnum: Int, replayWidth: Int) exten
val
replayValid
=
io
.
redirect
.
valid
&&
io
.
redirect
.
bits
.
isReplay
val
needReplay
=
Wire
(
Vec
(
size
,
Bool
()))
for
(
i
<-
0
until
size
)
{
needReplay
(
i
)
:=
roqNeedFlush
(
i
)
&&
stateEntries
(
i
)
=
/=
s_invali
d
&&
replayValid
needReplay
(
i
)
:=
roqNeedFlush
(
i
)
&&
stateEntries
(
i
)
=
==
s_dispatche
d
&&
replayValid
when
(
needReplay
(
i
))
{
stateEntries
(
i
)
:=
s_valid
}
...
...
@@ -148,10 +158,11 @@ class DispatchQueue(size: Int, enqnum: Int, deqnum: Int, replayWidth: Int) exten
// note that it returns the position starting from either the leftmost or the rightmost
// 00000001 => 0
// 00111000 => 3
// 11000111 =>
1
// 10000000 =>
0
// 11000111 =>
2
// 10000000 =>
1
// 00000000 => 7
def
getFirstMaskPosition
(
mask
:
Vec
[
Bool
])
=
{
// 11111111 => 7
def
getFirstMaskPosition
(
mask
:
Seq
[
Bool
])
=
{
Mux
(
mask
(
size
-
1
),
PriorityEncoder
(
mask
.
reverse
.
map
(
m
=>
!
m
)),
PriorityEncoder
(
mask
)
...
...
@@ -159,8 +170,19 @@ class DispatchQueue(size: Int, enqnum: Int, deqnum: Int, replayWidth: Int) exten
}
// when nothing is cancelled or replayed, the pointers remain unchanged
val
cancelPosition
=
Mux
(
Cat
(
needCancel
).
orR
,
getFirstMaskPosition
(
needCancel
),
tailIndex
)
val
replayPosition
=
Mux
(
Cat
(
needReplay
).
orR
,
getFirstMaskPosition
(
needReplay
),
dispatchIndex
)
// if any uop is cancelled or replayed, the pointer should go to the first zero before all ones
// position: continuous ones count from leftmost or rightmost (direction bit is considered)
// if all bits are one, we need to keep the index unchanged
// 00000000, 11111111: unchanged
// otherwise: firstMaskPosition
// how to check 00000000: tail is 0 (should be the same as needCancel(tailIndex - 1.U))
// how to check 11111111: full && head is 1 (should be the same as needCancel(headIndex))
// however, 11111111 should never occur unless exception
val
maskedNeedReplay
=
Cat
(
needReplay
.
reverse
)
&
dispatchedMask
val
cancelPosition
=
Mux
(
needCancel
(
tailIndex
-
1.
U
),
getFirstMaskPosition
(
needCancel
),
tailIndex
)
val
replayPosition
=
Mux
(
maskedNeedReplay
(
dispatchIndex
-
1.
U
),
getFirstMaskPosition
(
maskedNeedReplay
.
asBools
),
dispatchIndex
)
XSError
(!
exceptionValid
&&
(
isFull
&&
needCancel
(
headIndex
)),
"ALL CANCELLED: this should never occur\n"
)
XSError
(!
exceptionValid
&&
(
isFullDispatch
&&
maskedNeedReplay
(
headIndex
)),
"ALL REPLAYED: this should never occur\n"
)
assert
(
cancelPosition
.
getWidth
==
indexWidth
)
assert
(
replayPosition
.
getWidth
==
indexWidth
)
// If the highest bit is one, the direction flips.
...
...
@@ -174,9 +196,9 @@ class DispatchQueue(size: Int, enqnum: Int, deqnum: Int, replayWidth: Int) exten
val
dispatchCancelPtr
=
Mux
(
needCancel
(
dispatchIndex
)
||
dispatchEntries
===
0.
U
,
tailCancelPtr
,
dispatchPtr
)
// In case of replay, we need to walk back and recover preg states in the busy table.
// We keep track of the number of entries needed to be walked instead of target position to reduce overhead
val
dispatchReplayCnt
=
Mux
(
n
eedReplay
(
size
-
1
),
dispatchIndex
+
replayPosition
,
dispatchIndex
-
replayPosition
)
val
dispatchReplayCnt
=
Mux
(
maskedN
eedReplay
(
size
-
1
),
dispatchIndex
+
replayPosition
,
dispatchIndex
-
replayPosition
)
val
dispatchReplayCntReg
=
RegInit
(
0.
U
(
indexWidth
.
W
))
val
needExtraReplayWalk
=
Cat
((
0
until
deqnum
).
map
(
i
=>
stateEntries
(
deqIndex
(
i
))
===
s_dispatched
)).
orR
val
needExtraReplayWalk
=
Cat
((
0
until
deqnum
).
map
(
i
=>
needReplay
(
deqIndex
(
i
))
)).
orR
val
needExtraReplayWalkReg
=
RegNext
(
needExtraReplayWalk
&&
replayValid
,
false
.
B
)
val
inReplayWalk
=
dispatchReplayCntReg
=/=
0.
U
||
needExtraReplayWalkReg
val
dispatchReplayStep
=
Mux
(
needExtraReplayWalkReg
,
0.
U
,
Mux
(
dispatchReplayCntReg
>
replayWidth
.
U
,
replayWidth
.
U
,
dispatchReplayCntReg
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录