diff options
| author | Deborah Soung | 2020-05-14 12:47:00 -0700 |
|---|---|---|
| committer | GitHub | 2020-05-14 15:47:00 -0400 |
| commit | 1c8cec060f76f6a07996d2673b4e6b7471af2d7e (patch) | |
| tree | 4bce0b185519044f56760f5d268242de9029c817 | |
| parent | dd619167cd21e0f101cf931071d41e6b5ab90565 (diff) | |
Move Reg/Mem initializations to end of module (#1613)
* Move reg/mem initializations to end of module
* Add comment before reg/mem init if inits exist
| -rw-r--r-- | src/main/scala/firrtl/Emitter.scala | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/main/scala/firrtl/Emitter.scala b/src/main/scala/firrtl/Emitter.scala index f97ab7ca..aa2cdc18 100644 --- a/src/main/scala/firrtl/Emitter.scala +++ b/src/main/scala/firrtl/Emitter.scala @@ -999,7 +999,21 @@ class VerilogEmitter extends SeqTransform with Emitter { for (x <- attachAliases) emit(Seq(tab, x)) emit(Seq("`endif")) } + + for ((clk, content) <- noResetAlwaysBlocks if content.nonEmpty) { + emit(Seq(tab, "always @(posedge ", clk, ") begin")) + for (line <- content) emit(Seq(tab, tab, line)) + emit(Seq(tab, "end")) + } + + for ((clk, reset, content) <- asyncResetAlwaysBlocks if content.nonEmpty) { + emit(Seq(tab, "always @(posedge ", clk, " or posedge ", reset, ") begin")) + for (line <- content) emit(Seq(tab, tab, line)) + emit(Seq(tab, "end")) + } + if (initials.nonEmpty || ifdefInitials.nonEmpty) { + emit(Seq("// Register and memory initialization")) emit(Seq("`ifdef RANDOMIZE_GARBAGE_ASSIGN")) emit(Seq("`define RANDOMIZE")) emit(Seq("`endif")) @@ -1064,17 +1078,6 @@ class VerilogEmitter extends SeqTransform with Emitter { emit(Seq("`endif // SYNTHESIS")) } - for ((clk, content) <- noResetAlwaysBlocks if content.nonEmpty) { - emit(Seq(tab, "always @(posedge ", clk, ") begin")) - for (line <- content) emit(Seq(tab, tab, line)) - emit(Seq(tab, "end")) - } - - for ((clk, reset, content) <- asyncResetAlwaysBlocks if content.nonEmpty) { - emit(Seq(tab, "always @(posedge ", clk, " or posedge ", reset, ") begin")) - for (line <- content) emit(Seq(tab, tab, line)) - emit(Seq(tab, "end")) - } emit(Seq("endmodule")) } |
