aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Ingalls2020-04-13 12:05:28 -0700
committerGitHub2020-04-13 19:05:28 +0000
commit319e2fcff501ac0e8c34625b35b154c5f6c0c4c3 (patch)
tree5951daa630b409da3eb3b3641d99355b641a7bd7 /src
parent12446751964b5a765db12bb1f665c3ec1e6f1c6c (diff)
move asyncInitials inside initial block RANDOMIZE ifdef (#1510)
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/Emitter.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/scala/firrtl/Emitter.scala b/src/main/scala/firrtl/Emitter.scala
index 6ab9427e..91b04349 100644
--- a/src/main/scala/firrtl/Emitter.scala
+++ b/src/main/scala/firrtl/Emitter.scala
@@ -563,10 +563,13 @@ class VerilogEmitter extends SeqTransform with Emitter {
// if (reset) ...
// There is a fundamental mismatch between this representation which treats async reset
// registers as edge-triggered when in reality they are level-triggered.
- // This can result in silicon-simulation mismatch in the case where async reset is held high
+ // When not randomized, there is no mismatch because the async reset transition at the start
+ // of simulation from X to 1 triggers the posedge block for async reset.
+ // When randomized, this can result in silicon-simulation mismatch when async reset is held high
// upon power on with no clock, then async reset is dropped before the clock starts. In this
// circumstance, the async reset register will be randomized in simulation instead of being
- // reset. To fix this, we need extra initial block logic for async reset registers
+ // reset. To fix this, we need extra initial block logic to reset async reset registers again
+ // post-randomize.
val asyncInitials = ArrayBuffer[Seq[Any]]()
val simulates = ArrayBuffer[Seq[Any]]()
@@ -993,8 +996,8 @@ class VerilogEmitter extends SeqTransform with Emitter {
emit(Seq(" `endif"))
emit(Seq(" `endif"))
for (x <- initials) emit(Seq(tab, x))
- emit(Seq(" `endif // RANDOMIZE"))
for (x <- asyncInitials) emit(Seq(tab, x))
+ emit(Seq(" `endif // RANDOMIZE"))
emit(Seq("end // initial"))
emit(Seq("`endif // SYNTHESIS"))
}