Skip to content

Commit

Permalink
Added Support of Q0 Zcb Instructions.
Browse files Browse the repository at this point in the history
- Implement the 16 to 32 bit Decoder for `Zcb` Instructions having OP[1:0] == 00
- This decodes the following compressed instructions into its 32-bit equivalent instructions.
	c.lbu, c.lhu, c.lh, c.cb, c.sh

Signed-off-by: Abdul Wadood <[email protected]>
  • Loading branch information
Abdulwadoodd committed May 21, 2023
1 parent e160e98 commit b943cfb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/scala/rocket/RVC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class RVCDecoder(x: UInt, xLen: Int, useAddiForMv: Boolean = false) {
def rs2 = x(6,2)
def rd = x(11,7)
def addi4spnImm = Cat(x(10,7), x(12,11), x(5), x(6), 0.U(2.W))
def lbImm = Cat(x(5), x(6))
def lhImm = Cat(x(5), 0.U(1.W))
def lwImm = Cat(x(5), x(12,10), x(6), 0.U(2.W))
def ldImm = Cat(x(6,5), x(12,10), 0.U(3.W))
def lwspImm = Cat(x(3,2), x(12), x(6,4), 0.U(2.W))
Expand Down Expand Up @@ -60,15 +62,24 @@ class RVCDecoder(x: UInt, xLen: Int, useAddiForMv: Boolean = false) {
if (xLen == 32) inst(Cat(lwImm, rs1p, 2.U(3.W), rs2p, 0x07.U(7.W)), rs2p, rs1p, rs2p)
else ld
}
def unimp = inst(Cat(lwImm >> 5, rs2p, rs1p, 2.U(3.W), lwImm(4,0), 0x3F.U(7.W)), rs2p, rs1p, rs2p)
def zcb_q0 = {
def lbu = Cat(lbImm, rs1p, 4.U(3.W), rs2p, 0x03.U(7.W))
def lh = {
val func3 = Mux(x(6), 1.U(3.W), 5.U(3.W))
Cat(lhImm, rs1p, func3, rs2p, 0x03.U(7.W))
}
def sb = Cat(rs2p, rs1p, 0.U(3.W), 0.U(3.W), lbImm(1,0), 0x23.U(7.W))
def sh = Cat(rs2p, rs1p, 1.U(3.W), 0.U(3.W), lhImm(1,0), 0x23.U(7.W))
inst(Seq(lbu, lh, sb, sh)(x(11,10)), rs2p, rs1p, rs2p)
}
def sd = inst(Cat(ldImm >> 5, rs2p, rs1p, 3.U(3.W), ldImm(4,0), 0x23.U(7.W)), rs2p, rs1p, rs2p)
def sw = inst(Cat(lwImm >> 5, rs2p, rs1p, 2.U(3.W), lwImm(4,0), 0x23.U(7.W)), rs2p, rs1p, rs2p)
def fsd = inst(Cat(ldImm >> 5, rs2p, rs1p, 3.U(3.W), ldImm(4,0), 0x27.U(7.W)), rs2p, rs1p, rs2p)
def fsw = {
if (xLen == 32) inst(Cat(lwImm >> 5, rs2p, rs1p, 2.U(3.W), lwImm(4,0), 0x27.U(7.W)), rs2p, rs1p, rs2p)
else sd
}
Seq(addi4spn, fld, lw, flw, unimp, fsd, sw, fsw)
Seq(addi4spn, fld, lw, flw, zcb_q0, fsd, sw, fsw)
}

def q1 = {
Expand Down

0 comments on commit b943cfb

Please sign in to comment.