summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel
diff options
context:
space:
mode:
authorchick2016-02-24 23:05:11 -0800
committerchick2016-02-24 23:05:11 -0800
commit3c0a67889280803c22fff441462d06bb5081a558 (patch)
tree6871a959477f9a88d5aae08e8bb1e94e7d84149d /src/main/scala/Chisel
parent5d278605f2f398b17e7059a70ccd7420aa555cf8 (diff)
Remove the assignment statements in EnqIO and DeqIO Bundle constructors.
Make the corresponding test run faster by giving it a Counter.
Diffstat (limited to 'src/main/scala/Chisel')
-rw-r--r--src/main/scala/Chisel/util/Decoupled.scala22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/main/scala/Chisel/util/Decoupled.scala b/src/main/scala/Chisel/util/Decoupled.scala
index 23a08d52..e06e899a 100644
--- a/src/main/scala/Chisel/util/Decoupled.scala
+++ b/src/main/scala/Chisel/util/Decoupled.scala
@@ -22,21 +22,29 @@ object Decoupled {
def apply[T <: Data](gen: T): DecoupledIO[T] = new DecoupledIO(gen)
}
-/** An I/O bundle for enqueuing data with valid/ready handshaking */
+/** An I/O bundle for enqueuing data with valid/ready handshaking
+ * initialization must be handled, if necessary, by the parent circuit
+ */
class EnqIO[T <: Data](gen: T) extends DecoupledIO(gen)
{
def enq(dat: T): T = { valid := Bool(true); bits := dat; dat }
- valid := Bool(false)
- for (io <- bits.flatten)
- io := UInt(0)
+ def init(): Unit = {
+ valid := Bool(false)
+ for (io <- bits.flatten)
+ io := UInt(0)
+ }
override def cloneType: this.type = { new EnqIO(gen).asInstanceOf[this.type]; }
}
-/** An I/O bundle for dequeuing data with valid/ready handshaking */
+/** An I/O bundle for dequeuing data with valid/ready handshaking
+ * initialization must be handled, if necessary, by the parent circuit
+ */
class DeqIO[T <: Data](gen: T) extends DecoupledIO(gen) with Flipped
{
- ready := Bool(false)
def deq(b: Boolean = false): T = { ready := Bool(true); bits }
+ def init(): Unit = {
+ ready := Bool(false)
+ }
override def cloneType: this.type = { new DeqIO(gen).asInstanceOf[this.type]; }
}
@@ -54,7 +62,7 @@ class DecoupledIOC[+T <: Data](gen: T) extends Bundle
class QueueIO[T <: Data](gen: T, entries: Int) extends Bundle
{
/** I/O to enqueue data, is [[Chisel.DecoupledIO]] flipped */
- val enq = Decoupled(gen.cloneType).flip
+ val enq = Decoupled(gen.cloneType).flip()
/** I/O to enqueue data, is [[Chisel.DecoupledIO]]*/
val deq = Decoupled(gen.cloneType)
/** The current amount of data in the queue */