summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSchuyler Eldridge2020-10-21 19:57:38 -0400
committerGitHub2020-10-21 23:57:38 +0000
commit26deb7703389b78a9b2a61f7e191f3f0e2a6623b (patch)
tree366896d06e5f9e38e18ec2774b98219be8d82a42 /src/test
parentfef0b68a465875ab74b2b1339b29254c762d3c53 (diff)
Make `-e` option work with ChiselStage methods (#1630)
* Fix `-e` option causing ChiselStage.emit* to error Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com> * Add test of `-e` ChiselStage behavior Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com> * fixup! Add test of `-e` ChiselStage behavior
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/chiselTests/stage/ChiselStageSpec.scala27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/test/scala/chiselTests/stage/ChiselStageSpec.scala b/src/test/scala/chiselTests/stage/ChiselStageSpec.scala
index 09fb3429..e640def8 100644
--- a/src/test/scala/chiselTests/stage/ChiselStageSpec.scala
+++ b/src/test/scala/chiselTests/stage/ChiselStageSpec.scala
@@ -4,6 +4,7 @@ package chiselTests.stage
import chisel3._
import chisel3.stage.ChiselStage
+import chisel3.testers.TesterDriver.createTestDirectory
import chiselTests.Utils
@@ -14,11 +15,19 @@ import firrtl.options.Dependency
object ChiselStageSpec {
+ class Bar extends MultiIOModule {
+ val in = IO(Input(UInt(4.W)))
+ val out = IO(Output(UInt(4.W)))
+ out := ~in
+ }
+
class Foo extends MultiIOModule {
val addr = IO(Input(UInt(4.W)))
val out = IO(Output(Bool()))
- val bar = SyncReadMem(8, Bool())
- out := bar(addr)
+ val memory = SyncReadMem(8, Bool())
+ val bar = Module(new Bar)
+ bar.in := addr
+ out := memory(bar.out)
}
}
@@ -40,7 +49,13 @@ class ChiselStageSpec extends AnyFlatSpec with Matchers with Utils {
behavior of "ChiselStage.emitFirrtl"
it should "return a High FIRRTL string" in {
- ChiselStage.emitFirrtl(new Foo) should include ("mem bar")
+ ChiselStage.emitFirrtl(new Foo) should include ("mem memory")
+ }
+
+ it should "return a flattened FIRRTL string with '-e high'" in {
+ val args = Array("-e", "high", "-td", createTestDirectory(this.getClass.getSimpleName).toString)
+ (new ChiselStage)
+ .emitFirrtl(new Foo, args) should include ("module Bar")
}
behavior of "ChiselStage.emitVerilog"
@@ -49,6 +64,12 @@ class ChiselStageSpec extends AnyFlatSpec with Matchers with Utils {
ChiselStage.emitVerilog(new Foo) should include ("endmodule")
}
+ it should "return a flattened Verilog string with '-e verilog'" in {
+ val args = Array("-e", "verilog", "-td", createTestDirectory(this.getClass.getSimpleName).toString)
+ (new ChiselStage)
+ .emitVerilog(new Foo, args) should include ("module Bar")
+ }
+
behavior of "ChiselStage$.elaborate"
it should "generate a Chisel circuit from a Chisel module" in {