diff options
| author | Adam Izraelevitz | 2018-02-22 17:25:55 -0800 |
|---|---|---|
| committer | GitHub | 2018-02-22 17:25:55 -0800 |
| commit | 46b78943a726e4c9bf85ffb25a2ccf926b10dda7 (patch) | |
| tree | 39f9363400fdd39e2e55f3dc8c5221461941edec /src/main/scala/firrtl/Emitter.scala | |
| parent | 65bbf155003a86cd836f7ff4a2def6af91794780 (diff) | |
Add tests for #702. Adds Utility functions. Allows clock muxing in FIRRTL, but not Emitter. (#717)
Diffstat (limited to 'src/main/scala/firrtl/Emitter.scala')
| -rw-r--r-- | src/main/scala/firrtl/Emitter.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/scala/firrtl/Emitter.scala b/src/main/scala/firrtl/Emitter.scala index 5753fc17..cf356dcb 100644 --- a/src/main/scala/firrtl/Emitter.scala +++ b/src/main/scala/firrtl/Emitter.scala @@ -218,7 +218,10 @@ class VerilogEmitter extends SeqTransform with Emitter { } x match { case (e: DoPrim) => emit(op_stream(e), top + 1) - case (e: Mux) => emit(Seq(e.cond," ? ",cast(e.tval)," : ",cast(e.fval)),top + 1) + case (e: Mux) => { + if(e.tpe == ClockType) throw EmitterException("Cannot emit clock muxes directly") + emit(Seq(e.cond," ? ",cast(e.tval)," : ",cast(e.fval)),top + 1) + } case (e: ValidIf) => emit(Seq(cast(e.value)),top + 1) case (e: WRef) => w write e.serialize case (e: WSubField) => w write LowerTypes.loweredName(e) @@ -319,7 +322,7 @@ class VerilogEmitter extends SeqTransform with Emitter { } case AsUInt => Seq("$unsigned(", a0, ")") case AsSInt => Seq("$signed(", a0, ")") - case AsClock => Seq("$unsigned(", a0, ")") + case AsClock => Seq(a0) case Dshlw => Seq(cast(a0), " << ", a1) case Dshl => Seq(cast(a0), " << ", a1) case Dshr => doprim.tpe match { @@ -433,6 +436,7 @@ class VerilogEmitter extends SeqTransform with Emitter { } expr match { case m: Mux if canFlatten(m) => + if(m.tpe == ClockType) throw EmitterException("Cannot emit clock muxes directly") val ifStatement = Seq(tabs, "if (", m.cond, ") begin") val trueCase = addUpdate(m.tval, tabs + tab) val elseStatement = Seq(tabs, "end else begin") |
