From 5608aa8f42c1d69b59bee158d14fc6cef9b19a47 Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Fri, 22 Feb 2019 15:30:27 -0800 Subject: Add Width Constraints with Annotations (#956) * refactor InferWidths to allow for extra contraints, add InferWidthsWithAnnos * add test cases * add ResolvedAnnotationPaths trait to InferWidthsWithAnnos * remove println * cleanup tests * remove extraneous constraints * use foreachStmt instead of mapStmt * remove support for aggregates * fold InferWidthsWithAnnos into InferWidths * throw exception if ref not found, check for annos before AST walk --- .../firrtlTests/fixed/FixedTypeInferenceSpec.scala | 26 +++++++++++----------- .../firrtlTests/fixed/RemoveFixedTypeSpec.scala | 20 ++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/test/scala/firrtlTests/fixed') diff --git a/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala b/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala index a866836f..667db7b0 100644 --- a/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala +++ b/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala @@ -10,10 +10,10 @@ import firrtl.passes._ import firrtl.Parser.IgnoreInfo class FixedTypeInferenceSpec extends FirrtlFlatSpec { - private def executeTest(input: String, expected: Seq[String], passes: Seq[Pass]) = { - val c = passes.foldLeft(Parser.parse(input.split("\n").toIterator)) { - (c: Circuit, p: Pass) => p.run(c) - } + private def executeTest(input: String, expected: Seq[String], passes: Seq[Transform]) = { + val c = passes.foldLeft(CircuitState(Parser.parse(input.split("\n").toIterator), UnknownForm)) { + (c: CircuitState, p: Transform) => p.runTransform(c) + }.circuit val lines = c.serialize.split("\n") map normalized expected foreach { e => @@ -30,7 +30,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -60,7 +60,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -86,7 +86,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -112,7 +112,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -138,7 +138,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -164,7 +164,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -190,7 +190,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -230,7 +230,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths) val input = """circuit Unit : @@ -256,7 +256,7 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths, ConvertFixedToSInt) val input = diff --git a/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala b/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala index 8645fa62..21a39e83 100644 --- a/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala +++ b/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala @@ -9,10 +9,10 @@ import firrtl.passes._ import firrtl.Parser.IgnoreInfo class RemoveFixedTypeSpec extends FirrtlFlatSpec { - private def executeTest(input: String, expected: Seq[String], passes: Seq[Pass]) = { - val c = passes.foldLeft(Parser.parse(input.split("\n").toIterator)) { - (c: Circuit, p: Pass) => p.run(c) - } + private def executeTest(input: String, expected: Seq[String], passes: Seq[Transform]) = { + val c = passes.foldLeft(CircuitState(Parser.parse(input.split("\n").toIterator), UnknownForm)) { + (c: CircuitState, p: Transform) => p.runTransform(c) + }.circuit val lines = c.serialize.split("\n") map normalized println(c.serialize) @@ -30,7 +30,7 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths, ConvertFixedToSInt) val input = @@ -60,7 +60,7 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths, ConvertFixedToSInt) val input = @@ -91,7 +91,7 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths, ConvertFixedToSInt) val input = @@ -118,7 +118,7 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths, ConvertFixedToSInt) val input = @@ -145,7 +145,7 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths, ConvertFixedToSInt) val input = @@ -197,7 +197,7 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec { CheckTypes, ResolveGenders, CheckGenders, - InferWidths, + new InferWidths, CheckWidths, ConvertFixedToSInt) val input = -- cgit v1.2.3