Skip to content

Commit

Permalink
[rtl] draft new decode framework
Browse files Browse the repository at this point in the history
  • Loading branch information
sequencer committed Jun 7, 2024
1 parent da14b25 commit b1d73a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions t1/src/VectorDecoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import chisel3.util.experimental.decode._
import org.chipsalliance.t1.rtl.decoder.Decoder

@instantiable
class VectorDecoder(fpuEnable: Boolean) extends Module {
class VectorDecoder(decoder: Decoder) extends Module {
@public
val decodeInput: UInt = IO(Input(UInt(32.W)))
@public
val decodeResult: DecodeBundle = IO(Output(new DecodeBundle(Decoder.all(fpuEnable))))
val decodeResult: DecodeBundle = IO(Output(new DecodeBundle(decoder.all)))

decodeResult := Decoder.decode(fpuEnable)(decodeInput)
}
29 changes: 28 additions & 1 deletion t1/src/decoder/Decoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,36 @@ package org.chipsalliance.t1.rtl.decoder

import chisel3._
import chisel3.util.BitPat
import chisel3.util.experimental.decode.{DecodeField, BoolDecodeField, DecodeTable, DecodeBundle, DecodePattern}
import chisel3.util.experimental.decode.{BoolDecodeField, DecodeBundle, DecodeField, DecodePattern, DecodeTable}
import org.chipsalliance.rvdecoderdb
import org.chipsalliance.rvdecoderdb.{Encoding, Instruction, InstructionSet}
import org.chipsalliance.t1.rtl.T1Parameter

trait T1DecodeFiled[D <: Data] extends DecodeField[T1DecodePattern, D] with FieldName

trait T1BoolField extends T1DecodeFiled[Bool] with BoolDecodeField[T1DecodePattern]

object logic extends T1BoolField {
override def genTable(pattern: T1DecodePattern): BitPat =
pattern.isLogic.value match {
case attribute.Y => y
case attribute.N => n
case attribute.DC => dc
}
}

class Decoder(t1Parameter: T1Parameter) {
def allFields: Seq[T1DecodeFiled[_ >: Bool <: UInt]] = Seq(
logic
)
def allDecodePattern = t1Parameter.allInstuctions.map(T1DecodePattern(_, t1Parameter)).toSeq.sortBy(_.instruction.name)

def decodeTable: DecodeTable[T1DecodePattern] =
new DecodeTable[T1DecodePattern](
allDecodePattern,
allFields
)
}

trait FieldName {
def name: String = this.getClass.getSimpleName.replace("$", "")
Expand Down

0 comments on commit b1d73a5

Please sign in to comment.