Skip to content

Commit f1f2645

Browse files
authored
Ensure all output signals are driven - prep for InvalidateAPI. (freechipsproject#175)
* support for InvalidateAPI pending FIRRTL .when ... .otherwise fix * Ensure all output signals are driven - prep for InvalidateAPI. * Revert hacks to deal with InvalidateAPI (except for Router.scala). * Eliminate when(reset.toBool) so all outputs are initialized.
1 parent 2942c41 commit f1f2645

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/test/scala/examples/BundleInitSpec.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ object MyBundle {
3535
*/
3636
def setYTo5(): MyBundle = {
3737
val wire = Wire(new MyBundle)
38+
// Initialize all elements. We don't want firrtl complaining about "not fully initialized" connections.
39+
wire.x := 0.U
3840
wire.y := 5.U
3941
wire
4042
}

src/test/scala/examples/DecoupledAdder.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ class SlowDecoupledAdder extends Module {
2626
val in = Flipped(Decoupled(new SlowDecoupledAdderIn))
2727
val out = Decoupled(new SlowDecoupledAdderOut)
2828
})
29+
// Initialize all elements. We don't want firrtl complaining about "not fully initialized" connections.
2930
val busy = RegInit(false.B)
3031
val a_reg = RegInit(0.U(16.W))
3132
val b_reg = RegInit(0.U(16.W))
33+
val o_reg = RegInit(0.U(16.W))
3234
val wait_counter = RegInit(0.U(16.W))
3335

3436
io.in.ready := !busy
@@ -45,11 +47,12 @@ class SlowDecoupledAdder extends Module {
4547
}
4648
when(busy) {
4749
when(wait_counter > delay_value.asUInt) {
48-
io.out.bits.c := a_reg + b_reg
50+
o_reg := a_reg + b_reg
4951
}.otherwise {
5052
wait_counter := wait_counter + 1.U
5153
}
5254
}
55+
io.out.bits.c := o_reg
5356

5457
io.out.valid := (io.out.bits.c === a_reg + b_reg ) && busy
5558

src/test/scala/examples/InterpreterVerilatorConsistencySpec.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
package examples
44

5-
import chisel3._
6-
import chisel3.util._
75
import chisel3._
86
import chisel3.util._
97
import chisel3.iotesters._
10-
import org.scalatest.{Matchers, FlatSpec}
118

129
class ExampleModule extends Module {
1310
val io = IO(new Bundle {
@@ -39,6 +36,8 @@ class ExampleModule extends Module {
3936
io.out.bits := 0.U
4037
wait_counter := wait_counter + 1.U
4138
}
39+
}.otherwise {
40+
io.out.bits := 0.U
4241
}
4342

4443
io.out.valid := (io.out.bits === in_reg) && (wait_counter === delay_value) && busy

src/test/scala/examples/Router.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
package examples
44

55
import chisel3._
6-
import chisel3.util.{EnqIO, DeqIO, log2Ceil}
6+
import chisel3.util.{DeqIO, EnqIO, log2Ceil}
77
import chisel3.iotesters.{ChiselFlatSpec, OrderedDecoupledHWIOTester}
88

99
object Router {
@@ -53,12 +53,14 @@ class Router extends Module {
5353
val io = IO(new RouterIO(n))
5454
val tbl = Mem(depth, UInt(BigInt(n).bitLength.W))
5555

56-
when(reset.toBool) {
57-
io.read_routing_table_request.nodeq()
58-
io.load_routing_table_request.nodeq()
59-
io.read_routing_table_response.noenq()
60-
io.in.nodeq()
61-
io.outs.foreach { out => out.noenq() }
56+
io.read_routing_table_request.nodeq()
57+
io.load_routing_table_request.nodeq()
58+
io.read_routing_table_response.noenq()
59+
io.read_routing_table_response.bits := 0.U
60+
io.in.nodeq()
61+
io.outs.foreach { out =>
62+
out.bits := 0.U.asTypeOf(out.bits)
63+
out.noenq()
6264
}
6365

6466
when(io.read_routing_table_request.valid && io.read_routing_table_response.ready) {

0 commit comments

Comments
 (0)