1
0

junctions: refactor the Crossing type

This commit is contained in:
Wesley W. Terpstra 2016-09-13 15:34:56 -07:00
parent ecdfb528c5
commit 8142406d2e
2 changed files with 16 additions and 10 deletions

View File

@ -1,13 +1,19 @@
package junctions package junctions
import Chisel._ import Chisel._
class Crossing[T <: Data](gen: T) extends Bundle { class CrossingIO[T <: Data](gen: T) extends Bundle {
val enq = Decoupled(gen).flip() // Enqueue clock domain
val deq = Decoupled(gen)
val enq_clock = Clock(INPUT) val enq_clock = Clock(INPUT)
val enq_reset = Bool(INPUT) // synchronously deasserted wrt. enq_clock
val enq = Decoupled(gen).flip()
// Dequeue clock domain
val deq_clock = Clock(INPUT) val deq_clock = Clock(INPUT)
val enq_reset = Bool(INPUT) val deq_reset = Bool(INPUT) // synchronously deasserted wrt. deq_clock
val deq_reset = Bool(INPUT) val deq = Decoupled(gen)
}
abstract class Crossing[T <: Data] extends Module {
val io: CrossingIO[T]
} }
// Output is 1 for one cycle after any edge of 'in' // Output is 1 for one cycle after any edge of 'in'
@ -86,8 +92,8 @@ class AsyncHandshakeSink[T <: Data](gen: T, sync: Int, clock: Clock, reset: Bool
} }
} }
class AsyncHandshake[T <: Data](gen: T, sync: Int = 2) extends Module { class AsyncHandshake[T <: Data](gen: T, sync: Int = 2) extends Crossing[T] {
val io = new Crossing(gen) val io = new CrossingIO(gen)
require (sync >= 2) require (sync >= 2)
val source = Module(new AsyncHandshakeSource(gen, sync, io.enq_clock, io.enq_reset)) val source = Module(new AsyncHandshakeSource(gen, sync, io.enq_clock, io.enq_reset))

View File

@ -121,5 +121,5 @@ class AsyncMailbox extends BlackBox {
// this mailbox just has a fixed width of 64 bits, which is enough // this mailbox just has a fixed width of 64 bits, which is enough
// for our specific purpose here. // for our specific purpose here.
val io = new Crossing(UInt(width=64)) val io = new CrossingIO(UInt(width=64))
} }