Skip to content

Commit

Permalink
WIP: omreader improvements and introduce omreaderlib
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Apr 24, 2024
1 parent ee90bb0 commit 69c7d1a
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions omreader/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

package org.chipsalliance.t1.omreader

import java.io.BufferedInputStream

import mainargs._
import chisel3.panamalib.option._
import chisel3.panamaom._
import chisel3.panamaconverter.PanamaCIRCTConverter
import org.chipsalliance.t1.omreaderlib

Expand All @@ -16,11 +19,20 @@ object Main {

@main
def run(
@arg(name = "mlirbc-file") mlirbc: os.Path,
@arg(name = "mlirbc-file") mlirbcFile: Option[os.Path],
@arg(name = "class-name") className: String,
@arg(name = "dump") dump: Flag,
@arg(name = "eval") eval: Option[String],
) = {
omreaderlib.Hello()

val cvt = PanamaCIRCTConverter.newWithMlirBc(os.read.bytes(mlirbc))
val inputs = mlirbcFile match {
case Some(path) => os.read.bytes(path)
case None =>
val stdin = new BufferedInputStream(System.in)
Stream.continually(stdin.read).takeWhile(_ != -1).map(_.toByte).toArray
}
val cvt = PanamaCIRCTConverter.newWithMlirBc(inputs)

val pm = cvt.passManager()
assert(pm.populatePreprocessTransforms())
Expand All @@ -33,8 +45,15 @@ object Main {

val om = cvt.om()
val evaluator = om.evaluator()
val t1 = evaluator.instantiate("T1_1_Class", Seq(om.newBasePathEmpty))
t1.foreachField((name, value) => println(s".$name => { ${value.toString} }"))
val entry = evaluator.instantiate(className, Seq(om.newBasePathEmpty))

if (dump.value) {
entry.foreachField((name, value) => println(s".$name => $value"))
}
else if (eval.nonEmpty) {
val result = InputEval(entry, eval.get)
println(result)
}
}

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
Expand Down

0 comments on commit 69c7d1a

Please sign in to comment.