Skip to content

Commit

Permalink
[rtl] Replace field.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinjun-li committed Jun 11, 2024
1 parent b1d73a5 commit 705c0c8
Showing 1 changed file with 258 additions and 5 deletions.
263 changes: 258 additions & 5 deletions t1/src/decoder/Decoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,277 @@ import chisel3.util.experimental.decode.{BoolDecodeField, DecodeBundle, DecodeFi
import org.chipsalliance.rvdecoderdb
import org.chipsalliance.rvdecoderdb.{Encoding, Instruction, InstructionSet}
import org.chipsalliance.t1.rtl.T1Parameter
import org.chipsalliance.t1.rtl.decoder.attribute.TriState

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

trait T1BoolField extends T1DecodeFiled[Bool] with BoolDecodeField[T1DecodePattern]
trait T1BoolField extends T1DecodeFiled[Bool] with BoolDecodeField[T1DecodePattern] {
def getTriState(pattern: T1DecodePattern): TriState

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

trait T1UopField extends T1DecodeFiled[UInt] with FieldName {
def chiselType: UInt = UInt(4.W)
}

object logic extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isLogic.value
}

object adder extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isAdder.value
}

object shift extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isShift.value
}

object multiplier extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isMultiplier.value
}

object divider extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isDivider.value
}

object multiCycle extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isMulticycle.value
}

object other extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isOther.value
}

object unsigned0 extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isUnsigned0.value
}

object unsigned1 extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isUnsigned1.value
}

object itype extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isItype.value
}

object nr extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isNr.value
}

object red extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isRed.value
}

object widenReduce extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isWidenreduce.value
}

object targetRd extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isTargetrd.value
}

object slid extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isSlid.value
}

object gather extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isGather.value
}

object gather16 extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isGather16.value
}

object compress extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isCompress.value
}

object unOrderWrite extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isUnorderwrite.value
}

object extend extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isExtend.value
}

object mv extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isMv.value
}

object iota extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isIota.value
}

object maskLogic extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isMasklogic.value
}

object maskDestination extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isMaskdestination.value
}

object maskSource extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isMasksource.value
}

object readOnly extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isReadonly.value
}

object vwmacc extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isVwmacc.value
}

object saturate extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isSaturate.value
}

object special extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isSpecial.value
}

object maskUnit extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isMaskunit.value
}

object crossWrite extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isCrosswrite.value
}

object crossRead extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isCrossread.value
}

object sWrite extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isSwrite.value
}

object vtype extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isVtype.value
}

object sReadVD extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isSreadvd.value
}

object scheduler extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isScheduler.value
}

object dontNeedExecuteInLane extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isDontneedexecuteinlane.value
}

object reverse extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isReverse.value
}

object average extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isAverage.value
}

object ffo extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isFfo.value
}

object popCount extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isPopcount.value
}

object specialSlot extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isSpecialslot.value
}

object float extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isFloat.value
}

object floatMul extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isFloatmul.value
}

object orderReduce extends T1BoolField {
override def getTriState(pattern: T1DecodePattern): TriState = pattern.isOrderreduce.value
}

object topUop extends T1UopField {
override def genTable(pattern: T1DecodePattern): BitPat = ???
}

object uop extends T1UopField {
override def genTable(pattern: T1DecodePattern): BitPat = ???
}

object fpExecutionType extends T1UopField {
override def genTable(pattern: T1DecodePattern): BitPat = ???
}

class Decoder(t1Parameter: T1Parameter) {
def allFields: Seq[T1DecodeFiled[_ >: Bool <: UInt]] = Seq(
logic
)
logic,
adder,
shift,
multiplier,
divider,
multiCycle,
other,
unsigned0,
unsigned1,
itype,
nr,
red,
// top only
widenReduce,
targetRd,
slid,
gather,
gather16,
compress,
unOrderWrite,
// top uop
extend, // top uop
mv, // top uop
iota, // top uop
uop,
maskLogic,
maskDestination,
maskSource,
readOnly,
vwmacc,
saturate,
special,
maskUnit,
crossWrite,
crossRead,
// state
sWrite,
//sRead1 -> vType
vtype,
sReadVD,
scheduler,
dontNeedExecuteInLane,
reverse, // uop
average, // uop
ffo, // todo: add mask select -> top uop
popCount, // top uop add, red, uop popCount
topUop,
specialSlot
) ++ {
if (t1Parameter.fpuEnable)
Seq(
float,
fpExecutionType,
floatMul,
orderReduce
)
else Seq()
}
def allDecodePattern = t1Parameter.allInstuctions.map(T1DecodePattern(_, t1Parameter)).toSeq.sortBy(_.instruction.name)

def decodeTable: DecodeTable[T1DecodePattern] =
Expand Down

0 comments on commit 705c0c8

Please sign in to comment.