diff options
Diffstat (limited to 'src/main/scala/firrtl/Utils.scala')
| -rw-r--r-- | src/main/scala/firrtl/Utils.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala index 2264a0e4..0a067c04 100644 --- a/src/main/scala/firrtl/Utils.scala +++ b/src/main/scala/firrtl/Utils.scala @@ -764,6 +764,15 @@ object Utils extends LazyLogging { .toSeq .foldLeft(Seq[String]()){ case (seq, id) => seq :+ name.splitAt(id)._1 } } + + /** Returns the value masked with the width. + * + * This supports truncating negative values as well as values that are too + * wide for the width + */ + def maskBigInt(value: BigInt, width: Int): BigInt = { + value & ((BigInt(1) << width) - 1) + } } object MemoizedHash { |
