Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
XiangShan
提交
1854804d
X
XiangShan
项目概览
OpenXiangShan
/
XiangShan
10 个月 前同步成功
通知
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 搜索 >>
提交
1854804d
编写于
7月 30, 2020
作者:
Z
zhanglinjuan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev-ifu-predecode' into dev-frontend-ifu
上级
df95fad7
4c18e803
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
208 addition
and
7 deletion
+208
-7
debug/Makefile
debug/Makefile
+6
-3
src/main/scala/xiangshan/backend/decode/isa/predecode/predecode.scala
...la/xiangshan/backend/decode/isa/predecode/predecode.scala
+1
-1
src/main/scala/xiangshan/frontend/FakeICache.scala
src/main/scala/xiangshan/frontend/FakeICache.scala
+5
-3
src/main/scala/xiangshan/frontend/PreDecode.scala
src/main/scala/xiangshan/frontend/PreDecode.scala
+139
-0
src/test/scala/xiangshan/frontend/PDtest.scala
src/test/scala/xiangshan/frontend/PDtest.scala
+57
-0
未找到文件。
debug/Makefile
浏览文件 @
1854804d
...
...
@@ -20,7 +20,8 @@ cpu:
# ------------------------------------------------------------------
cputest
:
$(MAKE)
-C
$(AM_HOME)
/tests/cputest
$(ARCH)
$(EMU_ARGS)
run 2
>
cpu.log
$(MAKE)
-C
$(AM_HOME)
/tests/cputest
$(ARCH)
$(EMU_ARGS)
run
#2 > cpu.log
cat
cpu.log |
grep
different
cat
cpu.log |
grep
IPC
...
...
@@ -37,7 +38,8 @@ amtest:
cat
test.log |
grep
ISU
>
isu.log
microbench
:
$(MAKE)
-C
$(AM_HOME)
/apps/microbench
$(ARCH)
$(EMU_ARGS)
mainargs
=
test
run 2
>
microbench.log
$(MAKE)
-C
$(AM_HOME)
/apps/microbench
$(ARCH)
$(EMU_ARGS)
mainargs
=
test
run
#2 > microbench.log
cat
microbench.log |
grep
IPC
microbench_train
:
...
...
@@ -45,7 +47,8 @@ microbench_train:
cat
microbench.log |
grep
IPC
coremark
:
$(MAKE)
-C
$(AM_HOME)
/apps/coremark
$(ARCH)
$(EMU_ARGS)
mainargs
=
test
run 2
>
coremark.log
$(MAKE)
-C
$(AM_HOME)
/apps/coremark
$(ARCH)
$(EMU_ARGS)
mainargs
=
test
run
#2 > coremark.log
cat
coremark.log |
grep
IPC
dhrystone
:
...
...
src/main/scala/xiangshan/backend/decode/isa/predecode/predecode.scala
浏览文件 @
1854804d
...
...
@@ -3,7 +3,7 @@ package xiangshan.backend.decode.isa.predecode
import
chisel3.util._
import
xiangshan.frontend.BrType
object
PreDecode
{
object
PreDecode
Inst
{
def
C_JAL
=
BitPat
(
"b????????????????_?01_?_??_???_??_???_01"
)
//c.jal & c.j //C_ADDIW?
def
C_JALR
=
BitPat
(
"b????????????????_100_?_??_???_00_000_10"
)
//c.jalr & c.jr
def
C_BRANCH
=
BitPat
(
"b????????????????_11?_?_??_???_??_???_01"
)
...
...
src/main/scala/xiangshan/frontend/FakeICache.scala
浏览文件 @
1854804d
...
...
@@ -21,8 +21,9 @@ class FakeIcacheReq extends XSBundle {
}
class
FakeIcacheResp
extends
XSBundle
{
// val icacheOut = Vec(FetchWidth, UInt(32.W))
val
icacheOut
=
UInt
((
FetchWidth
*
32
).
W
)
val
pc
=
UInt
(
VAddrBits
.
W
)
// val data = Vec(FetchWidth, UInt(32.W))
val
data
=
UInt
((
FetchWidth
*
32
).
W
)
val
mask
=
UInt
(
PredictWidth
.
W
)
}
...
...
@@ -158,6 +159,7 @@ class FakeCache extends XSModule with HasICacheConst {
// tempPredecode.io.in := s3_ram_out
io
.
out
.
valid
:=
s3_valid
io
.
out
.
bits
.
icacheOut
:=
s3_ram_out
.
asUInt
io
.
out
.
bits
.
pc
:=
s3_pc
io
.
out
.
bits
.
data
:=
s3_ram_out
.
asUInt
io
.
out
.
bits
.
mask
:=
mask
(
s3_pc
)
}
\ No newline at end of file
src/main/scala/xiangshan/frontend/PreDecode.scala
0 → 100644
浏览文件 @
1854804d
package
xiangshan.frontend
import
chisel3._
import
chisel3.util._
import
utils.XSDebug
import
xiangshan._
import
xiangshan.backend.decode.isa.predecode.PreDecodeInst
trait
HasPdconst
{
this:
XSModule
=>
// val groupAlign = log2Up(FetchWidth * 4)
def
isRVC
(
inst
:
UInt
)
=
(
inst
(
1
,
0
)
=/=
3.
U
)
// def groupPC(pc: UInt): UInt = Cat(pc(VAddrBits-1, groupAlign), 0.U(groupAlign.W))
def
isLink
(
reg
:
UInt
)
=
reg
===
1.
U
||
reg
===
5.
U
def
brInfo
(
instr
:
UInt
)
=
{
val
rd
=
instr
(
11
,
7
)
val
rs
=
instr
(
19
,
15
)
val
brType
::
Nil
=
ListLookup
(
instr
,
List
(
BrType
.
notBr
),
PreDecodeInst
.
brTable
)
val
isCall
=
(
brType
===
BrType
.
jal
||
brType
===
BrType
.
jalr
)
&&
isLink
(
rd
)
&&
!
isRVC
(
instr
)
val
isRet
=
brType
===
BrType
.
jalr
&&
isLink
(
rs
)
&&
!
isLink
(
rd
)
&&
!
isRVC
(
instr
)
List
(
brType
,
isCall
,
isRet
)
}
}
object
BrType
{
def
notBr
=
"b00"
.
U
def
branch
=
"b01"
.
U
def
jal
=
"b10"
.
U
def
jalr
=
"b11"
.
U
def
apply
()
=
UInt
(
2.
W
)
}
object
ExcType
{
//TODO:add exctype
def
notExc
=
"b000"
.
U
def
apply
()
=
UInt
(
3.
W
)
}
class
PreDecodeInfo
extends
XSBundle
{
// 8 bit
val
isRVC
=
Bool
()
val
brType
=
UInt
(
2.
W
)
val
isCall
=
Bool
()
val
isRet
=
Bool
()
val
excType
=
UInt
(
3.
W
)
}
// class PDPacket extends PreDecodeInfo{
// val pc = UInt(VAddrBits.W)
// val inst = UInt(32.W)
// val mask = Bool()
// }
class
PreDecodeResp
extends
XSBundle
{
val
instrs
=
Vec
(
PredictWidth
,
UInt
(
32.
W
))
val
pc
=
Vec
(
PredictWidth
,
UInt
(
VAddrBits
.
W
))
val
mask
=
UInt
(
PredictWidth
.
W
)
val
pd
=
Vec
(
PredictWidth
,
(
new
PreDecodeInfo
))
}
// class ICacheResp extends XSBundle {
// val fetchPc = UInt(VAddrBits.W)
// val data = UInt((FetchWidth * 32).W)
// val mask = UInt((FetchWidth * 2).W)
// }
class
FakeIcacheResp
extends
XSBundle
{
val
pc
=
UInt
(
VAddrBits
.
W
)
// val data = Vec(FetchWidth, UInt(32.W))
val
data
=
UInt
((
FetchWidth
*
32
).
W
)
val
mask
=
UInt
(
PredictWidth
.
W
)
}
class
PreDecode
extends
XSModule
with
HasPdconst
{
val
io
=
IO
(
new
Bundle
()
{
val
in
=
Input
(
new
FakeIcacheResp
)
// val prevHalf = Input(UInt(16.W))
// val prevValid = Input(false.B)
val
prev
=
ValidIO
(
UInt
(
16.
W
))
// val out = Output(Vec(PredictWidth, new PDPacket))
val
out
=
Output
(
new
PreDecodeResp
)
})
// val gpc = groupPC(io.in.pc)
val
data
=
io
.
in
.
data
val
mask
=
io
.
in
.
mask
val
insts
=
Wire
(
Vec
(
PredictWidth
,
UInt
(
32.
W
)))
val
instsMask
=
Wire
(
Vec
(
PredictWidth
,
Bool
()))
val
instsRVC
=
Wire
(
Vec
(
PredictWidth
,
Bool
()))
val
instsPC
=
Wire
(
Vec
(
PredictWidth
,
UInt
(
VAddrBits
.
W
)))
val
nextHalf
=
Wire
(
UInt
(
16.
W
))
for
(
i
<-
0
until
PredictWidth
)
{
val
inst
=
Wire
(
UInt
(
32.
W
))
val
valid
=
Wire
(
Bool
())
val
pc
=
io
.
in
.
pc
+
(
i
<<
1
).
U
-
Mux
(
io
.
prev
.
valid
&&
(
i
.
U
===
0.
U
),
2.
U
,
0.
U
)
if
(
i
==
0
)
{
inst
:=
Mux
(
io
.
prev
.
valid
,
Cat
(
data
(
15
,
0
),
io
.
prev
.
bits
),
data
(
31
,
0
))
valid
:=
true
.
B
}
else
if
(
i
==
1
)
{
inst
:=
data
(
47
,
16
)
valid
:=
io
.
prev
.
valid
||
!(
instsMask
(
0
)
&&
!
isRVC
(
insts
(
0
)))
}
else
if
(
i
==
PredictWidth
-
1
)
{
inst
:=
Cat
(
0.
U
(
16.
W
),
data
(
i
*
16
+
15
,
i
*
16
))
valid
:=
!(
instsMask
(
i
-
1
)
&&
!
isRVC
(
insts
(
i
-
1
))
||
!
isRVC
(
inst
))
}
else
{
inst
:=
data
(
i
*
16
+
31
,
i
*
16
)
valid
:=
!(
instsMask
(
i
-
1
)
&&
!
isRVC
(
insts
(
i
-
1
)))
}
insts
(
i
)
:=
inst
instsRVC
(
i
)
:=
isRVC
(
inst
)
instsMask
(
i
)
:=
mask
(
i
)
&&
valid
instsPC
(
i
)
:=
pc
val
brType
::
isCall
::
isRet
::
Nil
=
brInfo
(
inst
)
io
.
out
.
pd
(
i
).
isRVC
:=
instsRVC
(
i
)
io
.
out
.
pd
(
i
).
brType
:=
brType
io
.
out
.
pd
(
i
).
isCall
:=
isCall
io
.
out
.
pd
(
i
).
isRet
:=
isRet
io
.
out
.
pd
(
i
).
excType
:=
ExcType
.
notExc
io
.
out
.
instrs
(
i
)
:=
insts
(
i
)
io
.
out
.
pc
(
i
)
:=
instsPC
(
i
)
}
io
.
out
.
mask
:=
instsMask
.
asUInt
for
(
i
<-
0
until
PredictWidth
)
{
XSDebug
(
true
.
B
,
p
"instr ${Hexdecimal(io.out.instrs(i))}, "
+
p
"mask ${Binary(instsMask(i))}, "
+
p
"pc ${Hexdecimal(io.out.pc(i))}, "
+
p
"isRVC ${Binary(io.out.pd(i).isRVC)}, "
+
p
"brType ${Binary(io.out.pd(i).brType)}, "
+
p
"isRet ${Binary(io.out.pd(i).isRet)}, "
+
p
"isCall ${Binary(io.out.pd(i).isCall)}\n"
)
}
}
src/test/scala/xiangshan/frontend/PDtest.scala
0 → 100644
浏览文件 @
1854804d
package
xiangshan.frontend
import
chisel3._
import
chiseltest._
import
org.scalatest._
class
PDtest
extends
FlatSpec
with
ChiselScalatestTester
with
Matchers
{
val
cacheLine2
=
(
"b"
+
"100_1_00001_00000_10"
+
//rvc jalr
"100_0_00001_00000_10"
+
//rvc jr
"101_00000000000_01"
+
//rvc j
"001_00000000000_01"
+
//rvc jal
"111_000_001_00000_01"
+
//RVC bnez
"0000000_00000_00001_000_10000_1100111"
+
//RET
"0000000_00000_00101_000_10000_1100111"
+
//RET
"0000000_00000_00000_000_00101_1100111"
+
//JALR_CALL
"0000000_00000_00000_000_00001_1100111"
+
//JALR_CALL
"0000000_00000_00000_000_00101_1101111"
+
//JAL_CALL
"0000000_00000_0000"
).
U
//JAL_CALL_height-half
val
cacheLine1
=
(
"b"
+
"0_000_00001_1101111"
+
//JAL_CALL_low-half
"110_000_001_00000_01"
+
//RVC beqz
"0000000_00010_00011_000_10000_1100111"
+
//JARL
"0000000_00000_00000_000_10000_1101111"
+
//JAR
"0000000_00010_00001_101_00000_1100011"
+
//Branch bge
"0000000_00010_00001_100_00000_1100011"
+
//Branch blt
"0000000_00010_00001_001_00000_1100011"
+
//Branch bne
"0000000_00010_00001_000_00000_1100011"
+
//Branch beq
"0000000_00010_00001_000_00001_0000011"
).
U
//Notbr
it
should
"test PDecode"
in
{
test
(
new
PreDecode
)
{
c
=>
println
(
s
"\n--------------------cycle 1------------------\n"
)
c
.
io
.
in
.
fetchPc
.
poke
(
0.
U
)
c
.
io
.
in
.
mask
.
poke
(
"b1111_1111_1111_0000"
.
U
)
c
.
io
.
in
.
data
.
poke
(
cacheLine1
)
c
.
clock
.
step
()
println
(
s
"\n--------------------cycle 2------------------\n"
)
c
.
io
.
in
.
fetchPc
.
poke
((
1
<<
5
).
U
)
c
.
io
.
in
.
mask
.
poke
(
"b1111_1111_1111_1111"
.
U
)
c
.
io
.
in
.
data
.
poke
(
cacheLine2
)
c
.
clock
.
step
()
println
(
s
"\n--------------------cycle 3------------------\n"
)
c
.
io
.
in
.
fetchPc
.
poke
((
2
<<
5
).
U
)
c
.
io
.
in
.
mask
.
poke
(
"b1111_1111_1111_1111"
.
U
)
c
.
io
.
in
.
data
.
poke
(
cacheLine1
)
c
.
clock
.
step
()
println
(
s
"\n--------------------cycle 4------------------\n"
)
c
.
io
.
in
.
fetchPc
.
poke
((
3
<<
5
).
U
)
c
.
io
.
in
.
mask
.
poke
(
"b1111_1111_1111_1111"
.
U
)
c
.
io
.
in
.
data
.
poke
(
cacheLine2
)
c
.
clock
.
step
()
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录