Skip to content

Commit 9789ee4

Browse files
committed
Fix type with cast and some test cases
1 parent 58e9569 commit 9789ee4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/main/scala/Decoder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Decoder(bitWidth: Int = 32) extends Module {
124124
0.S // padding for InstructionType
125125
)
126126
)
127-
io.DecoderPort.inst := signals.inst
127+
io.DecoderPort.inst := signals.inst.asTypeOf(new Instruction.Type)
128128
io.DecoderPort.toALU := signals.to_alu
129129
io.DecoderPort.branch := signals.branch
130130
io.DecoderPort.use_imm := signals.use_imm

src/test/scala/DecoderSpec.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with should.Mat
2525
// ?????????????????000?????0010011
2626
c.io.DecoderPort.op.poke(makeBin("andi x7, x24, -1"))
2727
c.clock.step()
28-
validateResult(c, ANDI, 7, 24, 0, -1, true.B, false.B)
28+
validateResult(c, ANDI, 7, 24, 31, -1, true.B, false.B)
2929
}
3030
}
3131
it should "Decode an SB instruction (type S)" in {
3232
test(new Decoder()) { c =>
3333
// Template: b?????????????????000?????0100011
3434
c.io.DecoderPort.op.poke(makeBin("sb x10, -81(x21)"))
3535
c.clock.step()
36-
validateResult(c, SB, 0, 21, 10, -81, false.B, false.B)
36+
validateResult(c, SB, 15, 21, 10, -81, false.B, false.B)
3737
}
3838
}
3939
it should "Decode an BEQ instruction (type B)" in {
4040
test(new Decoder()) { c =>
4141
c.io.DecoderPort.op.poke(makeBin("beq x21, x10, -1366"))
4242
c.clock.step()
43-
validateResult(c, BEQ, 0, 21, 10, -1366, false.B, true.B)
43+
validateResult(c, BEQ, 11, 21, 10, -1366, false.B, true.B)
4444
}
4545
}
4646
it should "Decode an LUI instruction (type U)" in {
@@ -50,8 +50,8 @@ class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with should.Mat
5050
c.clock.step()
5151
c.io.DecoderPort.inst.expect(LUI)
5252
c.io.DecoderPort.rd.peek().litValue should be(23)
53-
c.io.DecoderPort.rs1.peek().litValue should be(0)
54-
c.io.DecoderPort.rs2.peek().litValue should be(0)
53+
c.io.DecoderPort.rs1.peek().litValue should be(21)
54+
c.io.DecoderPort.rs2.peek().litValue should be(10)
5555
c.io.DecoderPort.imm.peek().litValue should be(-1431658496L)
5656
c.io.DecoderPort.toALU.expect(false.B)
5757
c.io.DecoderPort.branch.expect(false.B)
@@ -62,7 +62,7 @@ class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with should.Mat
6262
// Template: b?????????????????????????1101111
6363
c.io.DecoderPort.op.poke(makeBin("jal x21, -699052"))
6464
c.clock.step()
65-
validateResult(c, JAL, 21, 0, 0, -699052, false.B, false.B)
65+
validateResult(c, JAL, 21, 10, 20, -699052, false.B, false.B)
6666
}
6767
}
6868

0 commit comments

Comments
 (0)