-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a simple scala-cli based filecheck framework
- Loading branch information
Showing
7 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//> RUN: scala-cli $THIS | ||
//> using options -Xplugin:$PLUGINJAR | ||
//> using javaHome $JAVAHOME | ||
//> using javaOpt --enable-native-access=ALL-UNNAMED --enable-preview $JAVACNATIVELIBPATH | ||
import chisel3._ | ||
import utility.binding._ | ||
|
||
class FooBundle extends Bundle { | ||
val foo = Input(UInt(3.W)) | ||
} | ||
class FooModule extends Module { | ||
val io = IO(new FooBundle) | ||
} | ||
firrtlString(new FooModule) | ||
verilogString(new FooModule) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//> RUN: scala-cli $THIS | firtool -format=fir | ||
import chisel3._ | ||
import circt.stage.ChiselStage | ||
class EmptyModule extends Module | ||
println(ChiselStage.emitCHIRRTL(new EmptyModule)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//> RUN: scala-cli $THIS | ||
//> using options -Xplugin:$PLUGINJAR | ||
import chisel3._ | ||
import circt.stage.ChiselStage | ||
class FooBundle extends Bundle { | ||
val foo = Input(UInt(3.W)) | ||
} | ||
class FooModule extends Module { | ||
val io = IO(new FooBundle) | ||
} | ||
println(ChiselStage.emitCHIRRTL(new FooModule)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//> RUN: scala-cli $THIS | ||
import chisel3._ | ||
import circt.stage.ChiselStage | ||
class FooBundle extends Bundle { | ||
val foo = Input(UInt(3.W)) | ||
} | ||
class FooModule extends Module { | ||
val io = IO(new FooBundle) | ||
} | ||
println(ChiselStage.emitCHIRRTL(new FooModule)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import chisel3._ | ||
|
||
package object utility { | ||
object binding { | ||
def streamString(module: => RawModule, stream: chisel3.internal.CIRCTConverter => geny.Writable): String = Seq( | ||
new chisel3.stage.phases.Elaborate, | ||
chisel3.internal.panama.Convert | ||
).foldLeft( | ||
firrtl.AnnotationSeq(Seq(chisel3.stage.ChiselGeneratorAnnotation(() => module))) | ||
) { case (annos, phase) => phase.transform(annos) } | ||
.collectFirst { | ||
case chisel3.internal.panama.circt.PanamaCIRCTConverterAnnotation(converter) => | ||
val string = new java.io.ByteArrayOutputStream | ||
stream(converter).writeBytesTo(string) | ||
new String(string.toByteArray) | ||
} | ||
.get | ||
|
||
def firrtlString(module: => RawModule): String = streamString(module, _.firrtlStream) | ||
|
||
def verilogString(module: => RawModule): String = streamString(module, _.verilogStream) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters