diff options
| author | Richard Lin | 2016-02-26 12:51:13 -0800 |
|---|---|---|
| committer | Richard Lin | 2016-02-26 12:51:13 -0800 |
| commit | a2173d2bba816d174372a5198de3af14cd908f12 (patch) | |
| tree | 85b2bb4f748f4de9e94dca39b657f2c9f784cf57 /src/main | |
| parent | b7b5d8932d92ed90ef2f69e4d542bf97536f9db1 (diff) | |
| parent | 2e4d7869400f121bdae692f5c5b7976b1cb58438 (diff) | |
Merge pull request #109 from ucb-bar/Fix-init-in-DeqIO
Fix init in deq io
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/Chisel/util/Decoupled.scala | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/main/scala/Chisel/util/Decoupled.scala b/src/main/scala/Chisel/util/Decoupled.scala index 23a08d52..ba33e6c7 100644 --- a/src/main/scala/Chisel/util/Decoupled.scala +++ b/src/main/scala/Chisel/util/Decoupled.scala @@ -22,21 +22,48 @@ 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) { + /** push dat onto the output bits of this interface to let the consumer know it has happened. + * @param dat the values to assign to bits. + * @return dat. + */ def enq(dat: T): T = { valid := Bool(true); bits := dat; dat } - valid := Bool(false) - for (io <- bits.flatten) - io := UInt(0) + + /** Initialize this Bundle. Valid is set to false, and all bits are set to zero. + * NOTE: This method of initialization is still being discussed and could change in the + * future. + */ + 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) + /** Assert ready on this port and return the associated data bits. + * This is typically used when valid has been asserted by the producer side. + * @param b ignored + * @return the data for this device, + */ def deq(b: Boolean = false): T = { ready := Bool(true); bits } + + /** Initialize this Bundle. + * NOTE: This method of initialization is still being discussed and could change in the + * future. + */ + def init(): Unit = { + ready := Bool(false) + } override def cloneType: this.type = { new DeqIO(gen).asInstanceOf[this.type]; } } @@ -54,7 +81,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 */ |
