From 162704ebe4723237a28b6df6fbd080c04db97f1c Mon Sep 17 00:00:00 2001 From: Asuna Date: Sun, 28 Jul 2024 09:05:25 +0200 Subject: [PATCH] [om] export ISA extensions and march --- README.md | 8 ++++++++ omreader/src/Main.scala | 10 ++++++++++ omreaderlib/src/Interface.scala | 6 ++++++ t1/src/T1.scala | 14 ++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/README.md b/README.md index ed8a58166..78e5c6bb9 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,14 @@ $ nix run .#t1..ip.emu-omreader -- run --dump-methods ##### `dlen` : Integer + ##### `extensionsJson` : Json + + | Field | Type | + |---------------------------------|--------| + | `[*]` | string | + + ##### `march` : String + ##### `decoderInstructionsJson` | `decoderInstructionsJsonPretty` : Json | Field | Type | diff --git a/omreader/src/Main.scala b/omreader/src/Main.scala index 78a377349..97ebcb81c 100644 --- a/omreader/src/Main.scala +++ b/omreader/src/Main.scala @@ -47,6 +47,16 @@ object Main { println(simplyGetT1Reader(mlirbcFile).dlen) } + @main + def march(@arg(name = "mlirbc-file") mlirbcFile: os.Path) = { + println(simplyGetT1Reader(mlirbcFile).march) + } + + @main + def extensionsJson(@arg(name = "mlirbc-file") mlirbcFile: os.Path) = { + println(simplyGetT1Reader(mlirbcFile).extensionsJson) + } + @main def decoderInstructionsJson(@arg(name = "mlirbc-file") mlirbcFile: os.Path) = { println(simplyGetT1Reader(mlirbcFile).decoderInstructionsJson) diff --git a/omreaderlib/src/Interface.scala b/omreaderlib/src/Interface.scala index 56e5293f1..298b21469 100644 --- a/omreaderlib/src/Interface.scala +++ b/omreaderlib/src/Interface.scala @@ -69,6 +69,12 @@ class T1Reader private[omreaderlib](evaluator: PanamaCIRCTOMEvaluator, basePath: } def decoderInstructionsJson: String = ujson.write(decoderInstructionsJsonImpl) def decoderInstructionsJsonPretty: String = ujson.write(decoderInstructionsJsonImpl, 2) + def extensionsJson: String = { + val extensions = t1.field("extensions").asInstanceOf[PanamaCIRCTOMEvaluatorValueList] + val j = extensions.elements.map(_.asInstanceOf[PanamaCIRCTOMEvaluatorValuePrimitiveString].toString) + ujson.write(j) + } + def march: String = t1.field("march").asInstanceOf[PanamaCIRCTOMEvaluatorValuePrimitiveString].toString def dumpMethods(): Unit = { val mirror = runtimeMirror(getClass.getClassLoader).reflect(this) diff --git a/t1/src/T1.scala b/t1/src/T1.scala index 64daf2ddc..4dca51f4e 100644 --- a/t1/src/T1.scala +++ b/t1/src/T1.scala @@ -37,6 +37,18 @@ class T1OM extends Class { val dlenIn = IO(Input(Property[Int]())) dlen := dlenIn + @public + val extensions = IO(Output(Property[Seq[String]]())) + @public + val extensionsIn = IO(Input(Property[Seq[String]]())) + extensions := extensionsIn + + @public + val march = IO(Output(Property[String]())) + @public + val marchIn = IO(Input(Property[String]())) + march := marchIn + @public val lanes = IO(Output(Property[Seq[AnyClassType]]())) @public @@ -340,6 +352,8 @@ class T1(val parameter: T1Parameter) omInstance.vlenIn := Property(parameter.vLen) omInstance.dlenIn := Property(parameter.dLen) + omInstance.extensionsIn := Property(parameter.extensions) + omInstance.marchIn := Property(s"rv32gc_${parameter.extensions.mkString("_").toLowerCase}_zvl${parameter.vLen}b") /** the LSU Module */