diff options
| author | Andrew Waterman | 2019-01-17 13:59:31 -0800 |
|---|---|---|
| committer | Andrew Waterman | 2019-01-17 13:59:31 -0800 |
| commit | 1e4fef2e933e01b692c57af1fd64b271829ab283 (patch) | |
| tree | 24c749a0e2221a40512de428500e36e19c0420b3 /chiselFrontend/src | |
| parent | 9a0ce2272c9d5d0a8bdc90e84269749ce054664d (diff) | |
Generate better code for UInt.andR
In the case that the width is known, we can emit one fewer Firrtl node.
This obviously synthesizes the same way, but compiles/simulates faster.
Diffstat (limited to 'chiselFrontend/src')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Bits.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index b5de1317..cf015e60 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -812,7 +812,11 @@ sealed class UInt private[core] (width: Width) extends Bits(width) with Num[UInt /** @group SourceInfoTransformMacro */ def do_orR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this =/= 0.U /** @group SourceInfoTransformMacro */ - def do_andR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = ~this === 0.U + def do_andR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = width match { + // Generate a simpler expression if the width is known + case KnownWidth(w) => this === ((BigInt(1) << w) - 1).U + case UnknownWidth() => ~this === 0.U + } /** @group SourceInfoTransformMacro */ def do_xorR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = redop(sourceInfo, XorReduceOp) |
