diff options
| author | Adam Izraelevitz | 2016-07-27 13:53:30 -0700 |
|---|---|---|
| committer | GitHub | 2016-07-27 13:53:30 -0700 |
| commit | 486cdb5ea4a3450c81231f09488b5b166c363133 (patch) | |
| tree | 0df3abbd5ee94a1d221b5d798e2722dfe9844028 /src/main/scala/firrtl/Utils.scala | |
| parent | 42d38081f19b25ccb78f81f451b58e77b3e96d53 (diff) | |
| parent | a6c8493e907dedcbb289f6d4f6323cc26fb1edc0 (diff) | |
Merge pull request #198 from ucb-bar/add-chirrtl-check
Added a Chirrtl check for undeclared wires, etc.
Diffstat (limited to 'src/main/scala/firrtl/Utils.scala')
| -rw-r--r-- | src/main/scala/firrtl/Utils.scala | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala index 2053a70d..76c8e61e 100644 --- a/src/main/scala/firrtl/Utils.scala +++ b/src/main/scala/firrtl/Utils.scala @@ -203,6 +203,22 @@ object Utils extends LazyLogging { } } + /** Returns true if t, or any subtype, contains a flipped field + * @param t [[firrtl.ir.Type]] + * @return if t contains [[firrtl.ir.Flip]] + */ + def hasFlip(t: Type): Boolean = { + var has = false + def findFlip(t: Type): Type = t map (findFlip) match { + case t: BundleType => + for (f <- t.fields) { if (f.flip == Flip) has = true } + t + case t: Type => t + } + findFlip(t) + has + } + //============== TYPES ================ def mux_type (e1:Expression,e2:Expression) : Type = mux_type(tpe(e1),tpe(e2)) def mux_type (t1:Type,t2:Type) : Type = { @@ -268,7 +284,11 @@ object Utils extends LazyLogging { } def long_BANG (t:Type) : Long = { (t) match { - case g: GroundType => g.width.as[IntWidth].get.width.toLong + case g: GroundType => + g.width match { + case IntWidth(x) => x.toLong + case _ => throw new FIRRTLException(s"Expecting IntWidth, got: ${g.width}") + } case (t:BundleType) => { var w = 0 for (f <- t.fields) { w = w + long_BANG(f.tpe).toInt } |
