Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
6ac289b3
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
6ac289b3
编写于
1月 16, 2021
作者:
L
LinJiawei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auipc: get pc in jump unit
上级
b506dafd
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
38 addition
and
22 deletion
+38
-22
src/main/scala/xiangshan/backend/brq/Brq.scala
src/main/scala/xiangshan/backend/brq/Brq.scala
+14
-6
src/main/scala/xiangshan/backend/decode/DecodeStage.scala
src/main/scala/xiangshan/backend/decode/DecodeStage.scala
+7
-4
src/main/scala/xiangshan/backend/decode/DecodeUnit.scala
src/main/scala/xiangshan/backend/decode/DecodeUnit.scala
+1
-1
src/main/scala/xiangshan/backend/dispatch/Dispatch1.scala
src/main/scala/xiangshan/backend/dispatch/Dispatch1.scala
+4
-1
src/main/scala/xiangshan/backend/fu/Jump.scala
src/main/scala/xiangshan/backend/fu/Jump.scala
+4
-4
src/main/scala/xiangshan/backend/package.scala
src/main/scala/xiangshan/backend/package.scala
+5
-4
src/main/scala/xiangshan/package.scala
src/main/scala/xiangshan/package.scala
+3
-2
未找到文件。
src/main/scala/xiangshan/backend/brq/Brq.scala
浏览文件 @
6ac289b3
...
...
@@ -5,6 +5,7 @@ import chisel3.util._
import
xiangshan._
import
utils._
import
chisel3.ExcitingUtils._
import
xiangshan.backend.JumpOpType
import
xiangshan.backend.decode.ImmUnion
...
...
@@ -75,7 +76,7 @@ class Brq extends XSModule with HasCircularQueuePtrHelper {
val
exuOut
=
new
ExuOutput
}
val
s_idle
::
s_wb
::
Nil
=
Enum
(
2
)
val
s_idle
::
s_wb
::
s_auipc_wb
::
Nil
=
Enum
(
3
)
class
DecodeEnqBrqData
extends
Bundle
{
val
cfiUpdateInfo
=
new
CfiUpdateInfo
...
...
@@ -107,7 +108,8 @@ class Brq extends XSModule with HasCircularQueuePtrHelper {
/**
* write back
*/
val
wbValid
=
stateQueue
(
writebackIdx
)
===
s_wb
val
wbState
=
stateQueue
(
writebackIdx
)
val
wbValid
=
wbState
===
s_wb
val
wbEntry
=
Wire
(
new
ExuOutput
)
val
wbIsMisPred
=
wbEntry
.
redirect
.
target
=/=
wbEntry
.
brUpdate
.
pnpc
...
...
@@ -117,7 +119,7 @@ class Brq extends XSModule with HasCircularQueuePtrHelper {
io
.
out
.
valid
:=
wbValid
io
.
out
.
bits
:=
wbEntry
when
(
wbValid
)
{
when
(
wbValid
||
wbState
===
s_auipc_wb
)
{
stateQueue
(
writebackIdx
)
:=
s_idle
writebackPtr_next
:=
writebackPtr
+
1.
U
}
...
...
@@ -164,7 +166,7 @@ class Brq extends XSModule with HasCircularQueuePtrHelper {
/**
* exu write back
*/
for
(
exuWb
<-
io
.
exuRedirectWb
)
{
for
(
(
exuWb
,
i
)
<-
io
.
exuRedirectWb
.
zipWithIndex
)
{
when
(
exuWb
.
valid
)
{
val
wbIdx
=
exuWb
.
bits
.
redirect
.
brTag
.
value
XSInfo
(
...
...
@@ -174,8 +176,14 @@ class Brq extends XSModule with HasCircularQueuePtrHelper {
p
"target=${Hexadecimal(exuWb.bits.redirect.target)}\n"
)
assert
(
stateQueue
(
wbIdx
)
===
s_idle
)
stateQueue
(
wbIdx
)
:=
s_wb
if
(
i
==
0
){
// jump
stateQueue
(
wbIdx
)
:=
Mux
(
JumpOpType
.
jumpOpisAuipc
(
exuWb
.
bits
.
uop
.
ctrl
.
fuOpType
),
s_auipc_wb
,
s_wb
)
}
else
{
// alu
stateQueue
(
wbIdx
)
:=
s_wb
}
}
}
...
...
src/main/scala/xiangshan/backend/decode/DecodeStage.scala
浏览文件 @
6ac289b3
...
...
@@ -5,6 +5,7 @@ import chisel3.util._
import
xiangshan._
import
xiangshan.backend.brq.BrqEnqIO
import
utils._
import
xiangshan.backend.decode.Instructions.
{
AUIPC
,
MRET
,
SRET
}
class
DecodeStage
extends
XSModule
{
val
io
=
IO
(
new
Bundle
()
{
...
...
@@ -31,12 +32,14 @@ class DecodeStage extends XSModule {
for
(
i
<-
0
until
DecodeWidth
)
{
decoders
(
i
).
io
.
enq
.
ctrl_flow
<>
io
.
in
(
i
).
bits
val
isMret
=
io
.
in
(
i
).
bits
.
instr
===
BitPat
(
"b001100000010_00000_000_00000_1110011"
)
val
isSret
=
io
.
in
(
i
).
bits
.
instr
===
BitPat
(
"b000100000010_00000_000_00000_1110011"
)
val
thisBrqValid
=
!
io
.
in
(
i
).
bits
.
brUpdate
.
pd
.
notCFI
||
isMret
||
isSret
val
isMret
=
io
.
in
(
i
).
bits
.
instr
===
MRET
val
isSret
=
io
.
in
(
i
).
bits
.
instr
===
SRET
val
isAuiPc
=
io
.
in
(
i
).
bits
.
instr
===
AUIPC
val
thisBrqValid
=
!
io
.
in
(
i
).
bits
.
brUpdate
.
pd
.
notCFI
||
isMret
||
isSret
||
isAuiPc
io
.
enqBrq
.
needAlloc
(
i
)
:=
thisBrqValid
io
.
enqBrq
.
req
(
i
).
valid
:=
io
.
in
(
i
).
valid
&&
thisBrqValid
&&
io
.
out
(
i
).
ready
io
.
enqBrq
.
req
(
i
).
bits
:=
decoders
(
i
).
io
.
deq
.
cf_ctrl
.
cf
io
.
enqBrq
.
req
(
i
).
bits
:=
io
.
in
(
i
).
bits
io
.
enqBrq
.
req
(
i
).
bits
.
instr
:=
decoders
(
i
).
io
.
deq
.
cf_ctrl
.
cf
.
instr
io
.
out
(
i
).
valid
:=
io
.
in
(
i
).
valid
&&
io
.
enqBrq
.
req
(
i
).
ready
io
.
out
(
i
).
bits
:=
decoders
(
i
).
io
.
deq
.
cf_ctrl
...
...
src/main/scala/xiangshan/backend/decode/DecodeUnit.scala
浏览文件 @
6ac289b3
...
...
@@ -135,7 +135,7 @@ object XDecode extends DecodeConstants {
REMW
->
List
(
SrcType
.
reg
,
SrcType
.
reg
,
SrcType
.
DC
,
FuType
.
div
,
MDUOpType
.
remw
,
Y
,
N
,
N
,
N
,
N
,
N
,
N
,
SelImm
.
IMM_X
),
REMUW
->
List
(
SrcType
.
reg
,
SrcType
.
reg
,
SrcType
.
DC
,
FuType
.
div
,
MDUOpType
.
remuw
,
Y
,
N
,
N
,
N
,
N
,
N
,
N
,
SelImm
.
IMM_X
),
AUIPC
->
List
(
SrcType
.
pc
,
SrcType
.
imm
,
SrcType
.
DC
,
FuType
.
alu
,
ALUOpType
.
add
,
Y
,
N
,
N
,
N
,
N
,
N
,
N
,
SelImm
.
IMM_U
),
AUIPC
->
List
(
SrcType
.
pc
,
SrcType
.
imm
,
SrcType
.
DC
,
FuType
.
jmp
,
JumpOpType
.
auipc
,
Y
,
N
,
N
,
N
,
N
,
N
,
N
,
SelImm
.
IMM_U
),
JAL
->
List
(
SrcType
.
pc
,
SrcType
.
imm
,
SrcType
.
DC
,
FuType
.
jmp
,
JumpOpType
.
jal
,
Y
,
N
,
N
,
N
,
N
,
N
,
N
,
SelImm
.
IMM_UJ
),
JALR
->
List
(
SrcType
.
reg
,
SrcType
.
imm
,
SrcType
.
DC
,
FuType
.
jmp
,
JumpOpType
.
jalr
,
Y
,
N
,
N
,
N
,
N
,
N
,
N
,
SelImm
.
IMM_I
),
BEQ
->
List
(
SrcType
.
reg
,
SrcType
.
reg
,
SrcType
.
DC
,
FuType
.
alu
,
ALUOpType
.
beq
,
N
,
N
,
N
,
N
,
N
,
N
,
N
,
SelImm
.
IMM_SB
),
...
...
src/main/scala/xiangshan/backend/dispatch/Dispatch1.scala
浏览文件 @
6ac289b3
...
...
@@ -45,7 +45,10 @@ class Dispatch1 extends XSModule {
*/
// valid bits for different dispatch queues
val
isInt
=
VecInit
(
io
.
fromRename
.
map
(
req
=>
FuType
.
isIntExu
(
req
.
bits
.
ctrl
.
fuType
)))
val
isBranch
=
VecInit
(
io
.
fromRename
.
map
(
req
=>
!
req
.
bits
.
cf
.
brUpdate
.
pd
.
notCFI
))
val
isBranch
=
VecInit
(
io
.
fromRename
.
map
(
req
=>
// cover auipc (a fake branch)
!
req
.
bits
.
cf
.
brUpdate
.
pd
.
notCFI
||
FuType
.
isJumpExu
(
req
.
bits
.
ctrl
.
fuType
)
))
val
isFp
=
VecInit
(
io
.
fromRename
.
map
(
req
=>
FuType
.
isFpExu
(
req
.
bits
.
ctrl
.
fuType
)))
val
isLs
=
VecInit
(
io
.
fromRename
.
map
(
req
=>
FuType
.
isMemExu
(
req
.
bits
.
ctrl
.
fuType
)))
val
isStore
=
VecInit
(
io
.
fromRename
.
map
(
req
=>
FuType
.
isStoreExu
(
req
.
bits
.
ctrl
.
fuType
)))
...
...
src/main/scala/xiangshan/backend/fu/Jump.scala
浏览文件 @
6ac289b3
...
...
@@ -25,9 +25,9 @@ class Jump extends FunctionUnit with HasRedirectOut {
io
.
in
.
bits
.
uop
)
val
offset
=
SignExt
(
Mux
(
JumpOpType
.
jumpOp
IsJal
(
func
),
ImmUnion
.
J
.
toImm32
(
immMin
),
ImmUnion
.
I
.
toImm32
(
immMin
)
val
offset
=
SignExt
(
Mux
(
JumpOpType
.
jumpOp
isJalr
(
func
),
ImmUnion
.
I
.
toImm32
(
immMin
),
ImmUnion
.
J
.
toImm32
(
immMin
)
// Note: imm of auipc also expanded here
),
XLEN
)
val
redirectHit
=
uop
.
roqIdx
.
needFlush
(
io
.
redirectIn
)
...
...
@@ -53,7 +53,7 @@ class Jump extends FunctionUnit with HasRedirectOut {
brUpdate
.
taken
:=
true
.
B
// Output
val
res
=
snpc
val
res
=
Mux
(
JumpOpType
.
jumpOpisAuipc
(
func
),
target
,
snpc
)
io
.
in
.
ready
:=
io
.
out
.
ready
io
.
out
.
valid
:=
valid
...
...
src/main/scala/xiangshan/backend/package.scala
浏览文件 @
6ac289b3
...
...
@@ -17,12 +17,13 @@ package object backend {
// jump
object
JumpOpType
{
def
jal
=
"b11_000"
.
U
def
jalr
=
"b11_010"
.
U
def
jal
=
"b00"
.
U
def
jalr
=
"b01"
.
U
def
auipc
=
"b10"
.
U
// def call = "b11_011".U
// def ret = "b11_100".U
def
jumpOp
IsJal
(
op
:
UInt
)
=
!
op
(
1
)
def
jumpOpis
Jalr
(
op
:
UInt
)
=
op
(
1
)
def
jumpOp
isJalr
(
op
:
UInt
)
=
op
(
0
)
def
jumpOpis
Auipc
(
op
:
UInt
)
=
op
(
1
)
}
object
FenceOpType
{
...
...
src/main/scala/xiangshan/package.scala
浏览文件 @
6ac289b3
...
...
@@ -48,10 +48,11 @@ package object xiangshan {
def
apply
()
=
UInt
(
log2Up
(
num
).
W
)
def
isIntExu
(
fuType
:
UInt
)
=
!
fuType
(
3
)
def
isIntExu
(
fuType
:
UInt
)
=
!
fuType
(
3
)
def
isJumpExu
(
fuType
:
UInt
)
=
fuType
===
jmp
def
isFpExu
(
fuType
:
UInt
)
=
fuType
(
3
,
2
)
===
"b10"
.
U
def
isMemExu
(
fuType
:
UInt
)
=
fuType
(
3
,
2
)
===
"b11"
.
U
def
isLoadExu
(
fuType
:
UInt
)
=
fuType
===
ldu
||
fuType
===
mou
def
isLoadExu
(
fuType
:
UInt
)
=
fuType
===
ldu
||
fuType
===
mou
def
isStoreExu
(
fuType
:
UInt
)
=
fuType
===
stu
val
functionNameMap
=
Map
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录