From 319e2fcff501ac0e8c34625b35b154c5f6c0c4c3 Mon Sep 17 00:00:00 2001 From: John Ingalls Date: Mon, 13 Apr 2020 12:05:28 -0700 Subject: move asyncInitials inside initial block RANDOMIZE ifdef (#1510) --- src/main/scala/firrtl/Emitter.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main') 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")) } -- cgit v1.2.3