From 28e1a244bcc75a1138d25f5aa43ef22e23ef3ed7 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Mon, 22 Jun 2020 12:32:36 -0700 Subject: Canonicalize construction of Decoupled with no payload (#785) * Canonicalize construction of empty Decoupled * Change signature after dev meeting discussion * Make EmptyBundle private and final * Add test case for Decoupled with no payload * Apply suggestions from code review Co-authored-by: Richard Lin Co-authored-by: Albert Magyar Co-authored-by: Schuyler Eldridge Co-authored-by: Adam Izraelevitz Co-authored-by: Richard Lin Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>--- src/main/scala/chisel3/util/Decoupled.scala | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main') diff --git a/src/main/scala/chisel3/util/Decoupled.scala b/src/main/scala/chisel3/util/Decoupled.scala index 6a3aad24..82511ee5 100644 --- a/src/main/scala/chisel3/util/Decoupled.scala +++ b/src/main/scala/chisel3/util/Decoupled.scala @@ -92,6 +92,15 @@ object Decoupled /** Wraps some Data with a DecoupledIO interface. */ def apply[T <: Data](gen: T): DecoupledIO[T] = new DecoupledIO(gen) + // TODO: use a proper empty data type, this is a quick and dirty solution + private final class EmptyBundle extends Bundle + + // Both of these methods return DecoupledIO parameterized by the most generic type: Data + /** Returns a [[DecoupledIO]] inteface with no payload */ + def apply(): DecoupledIO[Data] = apply(new EmptyBundle) + /** Returns a [[DecoupledIO]] inteface with no payload */ + def empty: DecoupledIO[Data] = Decoupled() + /** Downconverts an IrrevocableIO output to a DecoupledIO, dropping guarantees of irrevocability. * * @note unsafe (and will error) on the producer (input) side of an IrrevocableIO -- cgit v1.2.3