junctions: refactor the Crossing type
This commit is contained in:
		@@ -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 deq_clock = Clock(INPUT)
 | 
					  val enq = Decoupled(gen).flip()
 | 
				
			||||||
    val enq_reset = Bool(INPUT)
 | 
					  // Dequeue clock domain
 | 
				
			||||||
    val deq_reset = Bool(INPUT)
 | 
					  val deq_clock = Clock(INPUT)
 | 
				
			||||||
 | 
					  val deq_reset = Bool(INPUT) // synchronously deasserted wrt. deq_clock
 | 
				
			||||||
 | 
					  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))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user