Skip to content

Commit 0fe0ac3

Browse files
authored
Update Decoder.scala
原译码器对AUIPC指令及LUI指令译码有误,现已修改
1 parent e9fcf70 commit 0fe0ac3

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/main/scala/rv32isc/Decoder.scala

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,37 @@ class Decoder extends Module {
4343
val ctrlStore = WireDefault(false.B)
4444
val ctrlALUSrc = WireDefault(false.B)
4545
val ctrlJAL = WireDefault(false.B)
46+
val ctrlAUIPC = WireDefault(false.B)//判断指令是否为AUIPC指令,如果是,操作数1的值应当为当前PC的值 新增 corrected by rainman
47+
val ctrlLUI = WireDefault(false.B) //判断是否为LUI指令,如果是,操作数1的值应当为0 新增
4648
val ctrlOP = WireDefault(0.U(OP_TYPES_WIDTH.W))
4749
val ctrlSigned = WireDefault(true.B)
4850
val ctrlLSType = WireDefault(LS_W)
4951

5052
// 根据opcode对控制信号赋值
5153
switch (io.inst(6, 2)) {
5254
// U: LUI, AUIPC
53-
is ("b01101".U, "b00101".U) {
55+
/*is ("b01101".U, "b00101".U) {
5456
ctrlALUSrc := true.B
5557
ctrlOP := OP_ADD
5658
imm := imm_u
59+
}*/
60+
//新增 corrected
61+
//U: LUI
62+
is ("b01101".U){
63+
ctrlALUSrc := true.B
64+
ctrlOP := OP_ADD
65+
ctrlLUI :=true.B
66+
imm := imm_u
67+
}
68+
//U: AUIPC
69+
is ("b00101".U){
70+
ctrlALUSrc := true.B
71+
ctrlOP := OP_ADD
72+
ctrlAUIPC := true.B
73+
//ctrlJAL := true.B
74+
imm := imm_u
5775
}
76+
5877
// J: JAL
5978
is ("b11011".U) {
6079
ctrlALUSrc := true.B
@@ -238,6 +257,8 @@ class Decoder extends Module {
238257
io.bundleCtrl.ctrlALUSrc := ctrlALUSrc
239258
io.bundleCtrl.ctrlBranch := ctrlBranch
240259
io.bundleCtrl.ctrlJAL := ctrlJAL
260+
io.bundleCtrl.ctrlLUI := ctrlLUI //新增 corrected
261+
io.bundleCtrl.ctrlAUIPC := ctrlAUIPC //新增 corrected
241262
io.bundleCtrl.ctrlJump := ctrlJump
242263
io.bundleCtrl.ctrlLoad := ctrlLoad
243264
io.bundleCtrl.ctrlOP := ctrlOP
@@ -246,4 +267,4 @@ class Decoder extends Module {
246267
io.bundleCtrl.ctrlStore := ctrlStore
247268
io.bundleCtrl.ctrlLSType := ctrlLSType
248269
io.imm := imm
249-
}
270+
}

0 commit comments

Comments
 (0)