diff options
| author | Adam Izraelevitz | 2016-04-19 09:58:43 -0700 |
|---|---|---|
| committer | jackkoenig | 2016-04-26 12:10:17 -0700 |
| commit | a45c131952aa3239241ed5e730c38ef61a8f86b7 (patch) | |
| tree | c4db1279cfdd9d5fa48abb70e865b830a6fa4159 /src/test | |
| parent | 797110f5f9d96590016d74de0611021c13f31bec (diff) | |
Fixed the check for bundle equality to allow relative flips to be wrong, but the leaf directions are the same
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/UnitTests.scala | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/test/scala/firrtlTests/UnitTests.scala b/src/test/scala/firrtlTests/UnitTests.scala index 14e8562b..f8af4943 100644 --- a/src/test/scala/firrtlTests/UnitTests.scala +++ b/src/test/scala/firrtlTests/UnitTests.scala @@ -30,10 +30,11 @@ package firrtlTests import java.io._ import org.scalatest._ import org.scalatest.prop._ -import firrtl.{Parser,Circuit} -import firrtl.passes.{Pass,ToWorkingIR,CheckHighForm,ResolveKinds,InferTypes,CheckTypes,PassExceptions} +import firrtl.{Parser,Circuit,FIRRTLEmitter} +import firrtl.passes.{Pass,ToWorkingIR,CheckHighForm,ResolveKinds,InferTypes,CheckTypes,ExpandConnects,PassExceptions} class UnitTests extends FlatSpec with Matchers { + def parse (input:String) = Parser.parse("",input.split("\n").toIterator,false) "Connecting bundles of different types" should "throw an exception" in { val passes = Seq( ToWorkingIR, @@ -48,7 +49,7 @@ class UnitTests extends FlatSpec with Matchers { | output x: {a : UInt<1>, b : UInt<1>} | x <= y""".stripMargin intercept[PassExceptions] { - passes.foldLeft(Parser.parse("",input.split("\n").toIterator)) { + passes.foldLeft(parse(input)) { (c: Circuit, p: Pass) => p.run(c) } } @@ -70,9 +71,37 @@ class UnitTests extends FlatSpec with Matchers { | reg y : { valid : UInt<1>, bits : UInt<3> }, clk with : | reset => (reset, x)""".stripMargin intercept[PassExceptions] { - passes.foldLeft(Parser.parse("",input.split("\n").toIterator)) { + passes.foldLeft(parse(input)) { (c: Circuit, p: Pass) => p.run(c) } } } + + "Partial connection two bundle types whose relative flips don't match but leaf node directions do" should "connect correctly" in { + val passes = Seq( + ToWorkingIR, + CheckHighForm, + ResolveKinds, + InferTypes, + CheckTypes, + ExpandConnects) + val input = + """circuit Unit : + | module Unit : + | wire x : { flip a: { b: UInt<32> } } + | wire y : { a: { flip b: UInt<32> } } + | x <- y""".stripMargin + val check = + """circuit Unit : + | module Unit : + | wire x : { flip a: { b: UInt<32> } } + | wire y : { a: { flip b: UInt<32> } } + | y.a.b <= x.a.b""".stripMargin + val c_result = passes.foldLeft(parse(input)) { + (c: Circuit, p: Pass) => p.run(c) + } + val writer = new StringWriter() + FIRRTLEmitter.run(c_result,writer) + (parse(writer.toString())) should be (parse(check)) + } } |
