-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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 --enable-preview -Djava.library.path=%JAVALIBRARYPATH" %s | FileCheck %s | ||
|
||
import chisel3._ | ||
import circt.stage.ChiselStage | ||
class FooBundle extends Bundle { | ||
val foo = Input(UInt(3.W)) | ||
} | ||
// CHECK-LABEL: module FooModule | ||
// CHECK: input clock : Clock | ||
// CHECK: input reset : UInt<1> | ||
class FooModule extends Module { | ||
// CHECK: output io : { flip foo : UInt<3>} | ||
val io = IO(new FooBundle) | ||
// CHECK: skip | ||
} | ||
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,12 @@ | ||
// RUN: not scala-cli --server=false --java-home=%JAVAHOME --extra-jars=%RUNCLASSPATH --scala-version=%SCALAVERSION --java-opt="--enable-native-access=ALL-UNNAMED --enable-preview -Djava.library.path=%JAVALIBRARYPATH" %s 2>&1 | FileCheck %s | ||
|
||
import chisel3._ | ||
import circt.stage.ChiselStage | ||
class FooBundle extends Bundle { | ||
val foo = Input(UInt(3.W)) | ||
} | ||
class FooModule extends Module { | ||
// CHECK: assertion failed: The Chisel compiler plugin is now required for compiling Chisel code. | ||
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,16 @@ | ||
import platform | ||
import lit.formats | ||
from lit.llvm import llvm_config | ||
from lit.llvm.subst import ToolSubst | ||
|
||
config.name = 'CHISEL' | ||
config.test_format = lit.formats.ShTest(True) | ||
config.suffixes = [".sc"] | ||
config.substitutions = [ | ||
('%SCALAVERSION', config.scala_version), | ||
('%RUNCLASSPATH', ':'.join(config.run_classpath)), | ||
('%SCALAPLUGINJARS', ':'.join(config.scala_plugin_jars)), | ||
('%JAVAHOME', config.java_home), | ||
('%JAVALIBRARYPATH', ':'.join(config.java_library_path)) | ||
] | ||
config.test_source_root = os.path.dirname(__file__) |
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,9 @@ | ||
import sys | ||
config.scala_version = "@SCALA_VERSION@" | ||
config.run_classpath = "@RUN_CLASSPATH@".split(",") | ||
config.scala_plugin_jars = "@SCALA_PLUGIN_JARS@".split(",") | ||
config.java_home = "@JAVA_HOME@" | ||
config.java_library_path = "@JAVA_LIBRARY_PATH@".split(",") | ||
config.chisel_lit_dir = "@CHISEL_LIT_DIR@".split(",") | ||
config.test_exec_root = os.path.dirname(__file__) | ||
lit_config.load_config(config, "@CHISEL_LIT_DIR@/tests/lit.cfg.py") |
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) | ||
} | ||
} |