Skip to content

Commit

Permalink
[om] get instruction om to work
Browse files Browse the repository at this point in the history
  • Loading branch information
sequencer committed Jun 22, 2024
1 parent 396e32e commit a9ee870
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
7 changes: 7 additions & 0 deletions t1/src/T1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class T1OM extends Class {
@public
val lanesIn = IO(Input(Property[Seq[AnyClassType]]()))
lanes := lanesIn

@public
val decoder = IO(Output(Property[AnyClassType]()))
@public
val decoderIn = IO(Input(Property[AnyClassType]()))
decoder := decoderIn
}

object T1Parameter {
Expand Down Expand Up @@ -320,6 +326,7 @@ class T1(val parameter: T1Parameter) extends Module with SerializableModule[T1Pa

val lsu: Instance[LSU] = Instantiate(new LSU(parameter.lsuParameters))
val decode: Instance[VectorDecoder] = Instantiate(new VectorDecoder(parameter.decoderParam))
omInstance.decoderIn := Property(decode.om.asAnyClassType)

// TODO: cover overflow
// TODO: uarch doc about the order of instructions
Expand Down
21 changes: 20 additions & 1 deletion t1/src/VectorDecoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,35 @@
package org.chipsalliance.t1.rtl

import chisel3._
import chisel3.experimental.hierarchy.{instantiable, public}
import chisel3.experimental.hierarchy.{Instance, Instantiate, instantiable, public}
import chisel3.properties.{AnyClassType, Class, ClassType, Property}
import chisel3.util.experimental.decode._
import org.chipsalliance.t1.rtl.decoder.{Decoder, DecoderParam}


@instantiable
class VectorDecoderOM extends Class {
@public
val instructions = IO(Output(Property[Seq[AnyClassType]]()))
@public
val instructionsIn = IO(Input(Property[Seq[AnyClassType]]()))
instructions := instructionsIn
}

@instantiable
class VectorDecoder(param: DecoderParam) extends Module {
val omInstance: Instance[VectorDecoderOM] = Instantiate(new VectorDecoderOM)
val omType: ClassType = omInstance.toDefinition.getClassType
@public
val om: Property[ClassType] = IO(Output(Property[omType.Type]()))
om := omInstance.getPropertyReference

@public
val decodeInput: UInt = IO(Input(UInt(32.W)))
@public
val decodeResult: DecodeBundle = IO(Output(new DecodeBundle(Decoder.allFields(param))))

omInstance.instructionsIn := Property(Decoder.allDecodePattern(param).map(_.om.asAnyClassType))

decodeResult := Decoder.decode(param)(decodeInput)
}
17 changes: 5 additions & 12 deletions t1/src/decoder/T1DecodePattern.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package org.chipsalliance.t1.rtl.decoder
import chisel3._
import chisel3.experimental.hierarchy.core.Definition
import chisel3.experimental.hierarchy.{Instantiate, instantiable, public}
import chisel3.properties.{Class, ClassType, Property}
import chisel3.properties.{AnyClassType, Class, ClassType, Property}
import chisel3.util.BitPat
import chisel3.util.experimental.decode.DecodePattern
import org.chipsalliance.rvdecoderdb.Instruction
Expand All @@ -28,19 +28,15 @@ class T1DecodeAttributeOM extends Class {

@instantiable
class T1InstructionOM extends Class {
// get type of [[T1DecodeAttributeOM]]
val attributeClass = Instantiate.definition(new T1DecodeAttributeOM)
val attributeClassTpe = attributeClass.getClassType

val instructionName = IO(Output(Property[String]()))
val documentation = IO(Output(Property[String]()))
val bitPat = IO(Output(Property[String]()))
val attributes = IO(Output(Property[Seq[attributeClassTpe.Type]]))
val attributes = IO(Output(Property[Seq[AnyClassType]]))

@public val instructionNameIn = IO(Input(Property[String]()))
@public val documentationIn = IO(Input(Property[String]()))
@public val bitPatIn = IO(Input(Property[String]()))
@public val attributesIn = IO(Input(Property[Seq[attributeClassTpe.Type]]))
@public val attributesIn = IO(Input(Property[Seq[AnyClassType]]))

instructionName := instructionNameIn
documentation := documentationIn
Expand Down Expand Up @@ -120,14 +116,11 @@ case class T1DecodePattern(instruction: Instruction, param: DecoderParam) extend
// This is the OM for this instruction
def om: Property[ClassType] = {
val obj = Instantiate(new T1InstructionOM)
// get type of [[T1DecodeAttributeOM]]
val attributeClass = Definition(new T1DecodeAttributeOM)
val attributeClassTpe = attributeClass.getClassType

obj.instructionNameIn := Property(instruction.name)
obj.bitPatIn := Property(bitPat.rawString)
obj.documentationIn := Property(documentation)
// convert in-memory attributes to Chisel Property
// get type of [[T1DecodeAttributeOM]]
obj.attributesIn :#= Property(
Seq(
isVector,
Expand Down Expand Up @@ -185,7 +178,7 @@ case class T1DecodePattern(instruction: Instruction, param: DecoderParam) extend
isVtype,
isVwmacc,
isWidenreduce,
).map(_.om.as(attributeClassTpe))
).map(_.om.asAnyClassType)
)
obj.getPropertyReference
}
Expand Down

0 comments on commit a9ee870

Please sign in to comment.