From 24492361da393a5b4d3e023b6511693125f4f254 Mon Sep 17 00:00:00 2001 From: Stephen Twigg Date: Tue, 26 Apr 2016 19:39:18 -0700 Subject: Rewrite BlackBox IO contract, replace _clock|_reset The old blackbox behavior still emitted extmodules that have a clk, reset pin and prepended all io's with io_ (ultimately). Most verilog modules do not follow this distinction (or use a slightly different name for clock and so on). Thus, instead BlackBox has been rewritten to not assume a clk or reset pin. Instead, the io Bundle specified is flattened directly into the Module.ports declaration. The tests have been rewritten to compensate for this. Also, added a test that uses the clock pin. As a secondary change, the _clock and _reset module parameters were bad for two reasons. One, they used null as a default, which is a scala best practices violation. Two, they were just not good names. Instead the primary constructor has been rewritten to take an Option[Clock] called override_clock and an Option[Bool] called override_reset, which default to None. (Note how the getOrElse call down below is much more natural now.) However, users may not want to specify the Some(their_clock) so I also added secondary constructors that take parameters named clock and reset and wrap them into Some calls into the primary constructor. This is a better UX because now you can just stipulate clock=blah in instantiation of that module in symmetry with using the clock in the definition of the module by invoking clock. PS: We could also back out of allowing any overrides via the Module constructor and just require the instantiating Module to do submodule.clock := newclock, etc. --- src/main/scala/Chisel/util/Decoupled.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main/scala/Chisel/util/Decoupled.scala') diff --git a/src/main/scala/Chisel/util/Decoupled.scala b/src/main/scala/Chisel/util/Decoupled.scala index faee2a5f..6c7787f8 100644 --- a/src/main/scala/Chisel/util/Decoupled.scala +++ b/src/main/scala/Chisel/util/Decoupled.scala @@ -104,8 +104,11 @@ class QueueIO[T <: Data](gen: T, entries: Int) extends Bundle class Queue[T <: Data](gen: T, val entries: Int, pipe: Boolean = false, flow: Boolean = false, - _reset: Bool = null) extends Module(_reset=_reset) -{ + override_reset: Option[Bool] = None) +extends Module(override_reset=override_reset) { + def this(gen: T, entries: Int, pipe: Boolean, flow: Boolean, reset: Bool) = + this(gen, entries, pipe, flow, Some(reset)) + val io = new QueueIO(gen, entries) val ram = Mem(entries, gen) -- cgit v1.2.3