Skip to content

Commit

Permalink
add false check for Property
Browse files Browse the repository at this point in the history
  • Loading branch information
sequencer committed Jan 28, 2024
1 parent 72f6c9d commit 3537227
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
11 changes: 11 additions & 0 deletions lit/tests/Property/Bad.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: not scala-cli --server=false --java-home=%JAVAHOME --extra-jars=%RUNCLASSPATH --scala-version=%SCALAVERSION --scala-option="-Xplugin:%SCALAPLUGINJARS" %s -- 2>&1 | FileCheck %s

import chisel3.properties._

class MyLit
// CHECK: error: unsupported Property type Bad.MyLit
val badPropLiteral = Property(new MyLit)

// CHECK: error: unsupported Property type Bad.MyTpe
class MyTpe
val badPropType = Property[MyTpe]()
39 changes: 28 additions & 11 deletions lit/tests/OMTest.sc → lit/tests/Property/Good.sc
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
// RUN: scala-cli --server=false --java-home=%JAVAHOME --extra-jars=%RUNCLASSPATH --scala-version=%SCALAVERSION --scala-option="-Xplugin:%SCALAPLUGINJARS" --java-opt="--enable-native-access=ALL-UNNAMED" --java-opt="--enable-preview" --java-opt="-Djava.library.path=%JAVALIBRARYPATH" %s -- panama-omstring | FileCheck %s
// RUN: scala-cli --server=false --java-home=%JAVAHOME --extra-jars=%RUNCLASSPATH --scala-version=%SCALAVERSION --scala-option="-Xplugin:%SCALAPLUGINJARS" %s -- chirrtl | FileCheck %s -check-prefix=SFC-FIRRTL
// RUN: scala-cli --server=false --java-home=%JAVAHOME --extra-jars=%RUNCLASSPATH --scala-version=%SCALAVERSION --scala-option="-Xplugin:%SCALAPLUGINJARS" --java-opt="--enable-native-access=ALL-UNNAMED" --java-opt="--enable-preview" --java-opt="-Djava.library.path=%JAVALIBRARYPATH" %s -- panama-om | FileCheck %s -check-prefix=MFC-OM

import chisel3._
import chisel3.properties._
import chisel3.panamaom._
import chisel3.panamaconverter._
import lit.utility._

// SFC-FIRRTL-LABEL: circuit IntPropTest :
// SFC-FIRRTL-NEXT: module IntPropTest :
// SFC-FIRRTL-NEXT: output intProp : Integer

// MFC-OM-LABEL: circuit IntPropTest :
// MFC-OM-NEXT: module IntPropTest :
// MFC-OM-NEXT: output intProp : Integer
class IntPropTest extends RawModule {
val intProp = IO(Output(Property[Int]()))
intProp := Property(1)
}

args.head match {
case "chirrtl" =>
println(circt.stage.ChiselStage.emitCHIRRTL(new IntPropTest))
case "panama-om" =>
println(lit.utility.panamaconverter.firrtlString(new IntPropTest))
case _ =>
}

class PropertyTest extends RawModule {
val i = IO(Input(UInt(8.W)))
Expand All @@ -18,14 +39,9 @@ class PropertyTest extends RawModule {
}

args.head match {
case "panama-omstring" =>
val converter: PanamaCIRCTConverter = lit.utility.panamaconverter.getConverter(new PropertyTest)
val pm = converter.passManager()
assert(pm.populatePreprocessTransforms())
assert(pm.populateCHIRRTLToLowFIRRTL())
assert(pm.populateLowFIRRTLToHW())
assert(pm.populateFinalizeIR())
assert(pm.run())
case "panama-om" =>
val converter = lit.utility.panamaconverter.getConverter(new PropertyTest)
lit.utility.panamaconverter.runAllPass(converter)

val om = converter.om()
val evaluator = om.evaluator()
Expand All @@ -38,4 +54,5 @@ args.head match {
// CHECK-NEXT: .b => { [ [ prim{omInteger{456}} ] ] }
// CHECK-NEXT: .p => { path{OMReferenceTarget:~PropertyTest|PropertyTest>i} }
obj.foreachField((name, value) => println(s".$name => { ${value.display} }"))
}
case _ =>
}

0 comments on commit 3537227

Please # to comment.