Deep Dive into Connection Operators

Chisel contains two connection operators, := and <>. This document provides a deeper explanation of the differences of the two and when to use one or the other. The differences are demonstrated with experiments using Scastie examples which use DecoupledIO.

Experiment Setup

// Imports used by the following examples
import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

The diagram for the experiment can be viewed here. Experiment Image


class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(DecoupledIO(UInt(8.W)))
  val out = DecoupledIO(UInt(8.W))
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  // connect Producer to IO
  p.io.a <> io.in
  // connect producer to consumer
  c.io.a <> p.io.b
  // connect consumer to IO
  io.out <> c.io.b
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.b <> io.a
}

Below we can see the resulting Verilog for this example:

ChiselStage.emitVerilog(new Wrapper)
// res0: String = """module PipelineStage(
//   output       io_a_ready,
//   input        io_a_valid,
//   input  [7:0] io_a_bits,
//   input        io_b_ready,
//   output       io_b_valid,
//   output [7:0] io_b_bits
// );
//   assign io_a_ready = io_b_ready; // @[connection-operators.md 41:8]
//   assign io_b_valid = io_a_valid; // @[connection-operators.md 41:8]
//   assign io_b_bits = io_a_bits; // @[connection-operators.md 41:8]
// endmodule
// module Wrapper(
//   input        clock,
//   input        reset,
//   output       io_in_ready,
//   input        io_in_valid,
//   input  [7:0] io_in_bits,
//   input        io_out_ready,
//   output       io_out_valid,
//   output [7:0] io_out_bits
// );
//   wire  p_io_a_ready; // @[connection-operators.md 25:17]
//   wire  p_io_a_valid; // @[connection-operators.md 25:17]
//   wire [7:0] p_io_a_bits; // @[connection-operators.md 25:17]
//   wire  p_io_b_ready; // @[connection-operators.md 25:17]
//   wire  p_io_b_valid; // @[connection-operators.md 25:17]
//   wire [7:0] p_io_b_bits; // @[connection-operators.md 25:17]
//   wire  c_io_a_ready; // @[connection-operators.md 26:17]
//   wire  c_io_a_valid; // @[connection-operators.md 26:17]
//   wire [7:0] c_io_a_bits; // @[connection-operators.md 26:17]
//   wire  c_io_b_ready; // @[connection-operators.md 26:17]
//   wire  c_io_b_valid; // @[connection-operators.md 26:17]
//   wire [7:0] c_io_b_bits; // @[connection-operators.md 26:17]
//   PipelineStage p ( // @[connection-operators.md 25:17]
//     .io_a_ready(p_io_a_ready),
//     .io_a_valid(p_io_a_valid),
//     .io_a_bits(p_io_a_bits),
//     .io_b_ready(p_io_b_ready),
//     .io_b_valid(p_io_b_valid),
//     .io_b_bits(p_io_b_bits)
//   );
//   PipelineStage c ( // @[connection-operators.md 26:17]
//     .io_a_ready(c_io_a_ready),
//     .io_a_valid(c_io_a_valid),
//     .io_a_bits(c_io_a_bits),
//     .io_b_ready(c_io_b_ready),
//     .io_b_valid(c_io_b_valid),
//     .io_b_bits(c_io_b_bits)
// ...

Concept 1: <> is Commutative

This experiment is set up to test for the function of <> using the experiment above.

Achieving this involves flipping the RHS and LHS of the <> operator and seeing how <> will react. ( Scastie link for the experiment:https://scastie.scala-lang.org/Shorla/LVhlbkFQQnq7X3trHfgZZQ )

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(DecoupledIO(UInt(8.W)))
  val out = DecoupledIO(UInt(8.W))
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  // connect producer to I/O
  io.in <> p.io.a
  // connect producer  to consumer
  p.io.b <> c.io.a
  // connect consumer to I/O
  c.io.b <> io.out
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.a <> io.b
}

Below we can see the resulting Verilog for this example:

ChiselStage.emitVerilog(new Wrapper)
// res2: String = """module PipelineStage(
//   output       io_a_ready,
//   input        io_a_valid,
//   input  [7:0] io_a_bits,
//   input        io_b_ready,
//   output       io_b_valid,
//   output [7:0] io_b_bits
// );
//   assign io_a_ready = io_b_ready; // @[connection-operators.md 87:8]
//   assign io_b_valid = io_a_valid; // @[connection-operators.md 87:8]
//   assign io_b_bits = io_a_bits; // @[connection-operators.md 87:8]
// endmodule
// module Wrapper(
//   input        clock,
//   input        reset,
//   output       io_in_ready,
//   input        io_in_valid,
//   input  [7:0] io_in_bits,
//   input        io_out_ready,
//   output       io_out_valid,
//   output [7:0] io_out_bits
// );
//   wire  p_io_a_ready; // @[connection-operators.md 71:17]
//   wire  p_io_a_valid; // @[connection-operators.md 71:17]
//   wire [7:0] p_io_a_bits; // @[connection-operators.md 71:17]
//   wire  p_io_b_ready; // @[connection-operators.md 71:17]
//   wire  p_io_b_valid; // @[connection-operators.md 71:17]
//   wire [7:0] p_io_b_bits; // @[connection-operators.md 71:17]
//   wire  c_io_a_ready; // @[connection-operators.md 72:17]
//   wire  c_io_a_valid; // @[connection-operators.md 72:17]
//   wire [7:0] c_io_a_bits; // @[connection-operators.md 72:17]
//   wire  c_io_b_ready; // @[connection-operators.md 72:17]
//   wire  c_io_b_valid; // @[connection-operators.md 72:17]
//   wire [7:0] c_io_b_bits; // @[connection-operators.md 72:17]
//   PipelineStage p ( // @[connection-operators.md 71:17]
//     .io_a_ready(p_io_a_ready),
//     .io_a_valid(p_io_a_valid),
//     .io_a_bits(p_io_a_bits),
//     .io_b_ready(p_io_b_ready),
//     .io_b_valid(p_io_b_valid),
//     .io_b_bits(p_io_b_bits)
//   );
//   PipelineStage c ( // @[connection-operators.md 72:17]
//     .io_a_ready(c_io_a_ready),
//     .io_a_valid(c_io_a_valid),
//     .io_a_bits(c_io_a_bits),
//     .io_b_ready(c_io_b_ready),
//     .io_b_valid(c_io_b_valid),
//     .io_b_bits(c_io_b_bits)
// ...

Conclusion:

The Verilog remained the same without incurring errors, showing that the <> operator is commutative.

Concept 2: := means assign ALL LHS signals from the RHS, regardless of the direction on the LHS.

Using the same experiment code as above, we set to test for the function of := We replace all instances of <> with := in the sample code above. (Scastie link to the experiment: https://scastie.scala-lang.org/Shorla/o1ShdaY3RWKf0IIFwwQ1UQ/1)

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(DecoupledIO(UInt(8.W)))
  val out = DecoupledIO(UInt(8.W))
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  // connect producer to I/O
  p.io.a := io.in
  // connect producer  to consumer
  c.io.a := p.io.b
  // connect consumer to I/O
  io.out := c.io.b
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.a := io.b
}

Below we can see the resulting error message for this example:

ChiselStage.emitVerilog(new Wrapper)
// chisel3.internal.ChiselException: Connection between sink (PipelineStage.io.a: IO[DecoupledIO]) and source (PipelineStage.io.b: IO[DecoupledIO]) failed @: .bitsio.a.bits in PipelineStage cannot be written from module PipelineStage.
// 	at ... ()
// 	at repl.MdocSession$App3$PipelineStage.<init>(connection-operators.md:133)
// 	at repl.MdocSession$App3$Wrapper$$anonfun$32$$anonfun$apply$10.apply(connection-operators.md:117)
// 	at repl.MdocSession$App3$Wrapper$$anonfun$32$$anonfun$apply$10.apply(connection-operators.md:117)
// 	at chisel3.Module$.do_apply(Module.scala:53)
// 	at repl.MdocSession$App3$Wrapper$$anonfun$32.apply(connection-operators.md:117)
// 	at repl.MdocSession$App3$Wrapper$$anonfun$32.apply(connection-operators.md:117)
// 	at chisel3.internal.plugin.package$.autoNameRecursively(package.scala:33)
// 	at repl.MdocSession$App3$Wrapper.<init>(connection-operators.md:117)
// 	at repl.MdocSession$App3$$anonfun$41$$anonfun$apply$13.apply(connection-operators.md:141)
// 	at repl.MdocSession$App3$$anonfun$41$$anonfun$apply$13.apply(connection-operators.md:141)
// 	at ... ()
// 	at ... (Stack trace trimmed to user code only. Rerun with --full-stacktrace to see the full stack trace)

Conclusion:

The := operator goes field-by-field on the LHS and attempts to connect it to the same-named signal from the RHS. If something on the LHS is actually an Input, or the corresponding signal on the RHS is an Output, you will get an error as shown above.

Concept 3: Always Use := to assign DontCare to Wires

When assigning DontCare to something that is not directioned, should you use := or <>? We will find out using the sample codes below: ( Scastie link for the experiment:https://scastie.scala-lang.org/Shorla/ZIGsWcylRqKJhZCkKWlSIA/1)

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(DecoupledIO(UInt(8.W)))
  val out = DecoupledIO(UInt(8.W))
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  //connect Producer to IO
  io.in := DontCare
  p.io.a <> DontCare
  val tmp = Wire(Flipped(DecoupledIO(UInt(8.W))))
  tmp := DontCare
  p.io.a <> io.in
  // connect producer to consumer
  c.io.a <> p.io.b
  //connect consumer to IO
  io.out <> c.io.b
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.b <> io.a
}

Below we can see the resulting Verilog for this example:

ChiselStage.emitVerilog(new Wrapper)
// res5: String = """module PipelineStage(
//   output       io_a_ready,
//   input        io_a_valid,
//   input  [7:0] io_a_bits,
//   input        io_b_ready,
//   output       io_b_valid,
//   output [7:0] io_b_bits
// );
//   assign io_a_ready = io_b_ready; // @[connection-operators.md 187:8]
//   assign io_b_valid = io_a_valid; // @[connection-operators.md 187:8]
//   assign io_b_bits = io_a_bits; // @[connection-operators.md 187:8]
// endmodule
// module Wrapper(
//   input        clock,
//   input        reset,
//   output       io_in_ready,
//   input        io_in_valid,
//   input  [7:0] io_in_bits,
//   input        io_out_ready,
//   output       io_out_valid,
//   output [7:0] io_out_bits
// );
//   wire  p_io_a_ready; // @[connection-operators.md 167:17]
//   wire  p_io_a_valid; // @[connection-operators.md 167:17]
//   wire [7:0] p_io_a_bits; // @[connection-operators.md 167:17]
//   wire  p_io_b_ready; // @[connection-operators.md 167:17]
//   wire  p_io_b_valid; // @[connection-operators.md 167:17]
//   wire [7:0] p_io_b_bits; // @[connection-operators.md 167:17]
//   wire  c_io_a_ready; // @[connection-operators.md 168:17]
//   wire  c_io_a_valid; // @[connection-operators.md 168:17]
//   wire [7:0] c_io_a_bits; // @[connection-operators.md 168:17]
//   wire  c_io_b_ready; // @[connection-operators.md 168:17]
//   wire  c_io_b_valid; // @[connection-operators.md 168:17]
//   wire [7:0] c_io_b_bits; // @[connection-operators.md 168:17]
//   PipelineStage p ( // @[connection-operators.md 167:17]
//     .io_a_ready(p_io_a_ready),
//     .io_a_valid(p_io_a_valid),
//     .io_a_bits(p_io_a_bits),
//     .io_b_ready(p_io_b_ready),
//     .io_b_valid(p_io_b_valid),
//     .io_b_bits(p_io_b_bits)
//   );
//   PipelineStage c ( // @[connection-operators.md 168:17]
//     .io_a_ready(c_io_a_ready),
//     .io_a_valid(c_io_a_valid),
//     .io_a_bits(c_io_a_bits),
//     .io_b_ready(c_io_b_ready),
//     .io_b_valid(c_io_b_valid),
//     .io_b_bits(c_io_b_bits)
// ...

Conclusion:

If <> were used to assign the unidrectioned wire tmp to DontCare, we would get an error. But in the example above, we used := and no errors occurred. But when := was used to assign the wire to DontCare, no errors will occur.

Thus, when assigning DontCare to a Wire, always use :=.

Concept 4: You can use <> or := to assign DontCare to directioned things (IOs)

When assigning DontCare to something that is directioned, should you use := or <>? We will find out using the sample codes below: ( Scastie link for the experiment:https://scastie.scala-lang.org/Shorla/ZIGsWcylRqKJhZCkKWlSIA/1)

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(DecoupledIO(UInt(8.W)))
  val out = DecoupledIO(UInt(8.W))
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  //connect Producer to IO
  io.in := DontCare
  p.io.a <> DontCare
  val tmp = Wire(Flipped(DecoupledIO(UInt(8.W))))
  tmp := DontCare
  p.io.a <> io.in
  // connect producer to consumer
  c.io.a <> p.io.b
  //connect consumer to IO
  io.out <> c.io.b
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.b <> io.a
}

Below we can see the resulting Verilog for this example:

ChiselStage.emitVerilog(new Wrapper)
// res7: String = """module PipelineStage(
//   output       io_a_ready,
//   input        io_a_valid,
//   input  [7:0] io_a_bits,
//   input        io_b_ready,
//   output       io_b_valid,
//   output [7:0] io_b_bits
// );
//   assign io_a_ready = io_b_ready; // @[connection-operators.md 237:8]
//   assign io_b_valid = io_a_valid; // @[connection-operators.md 237:8]
//   assign io_b_bits = io_a_bits; // @[connection-operators.md 237:8]
// endmodule
// module Wrapper(
//   input        clock,
//   input        reset,
//   output       io_in_ready,
//   input        io_in_valid,
//   input  [7:0] io_in_bits,
//   input        io_out_ready,
//   output       io_out_valid,
//   output [7:0] io_out_bits
// );
//   wire  p_io_a_ready; // @[connection-operators.md 217:17]
//   wire  p_io_a_valid; // @[connection-operators.md 217:17]
//   wire [7:0] p_io_a_bits; // @[connection-operators.md 217:17]
//   wire  p_io_b_ready; // @[connection-operators.md 217:17]
//   wire  p_io_b_valid; // @[connection-operators.md 217:17]
//   wire [7:0] p_io_b_bits; // @[connection-operators.md 217:17]
//   wire  c_io_a_ready; // @[connection-operators.md 218:17]
//   wire  c_io_a_valid; // @[connection-operators.md 218:17]
//   wire [7:0] c_io_a_bits; // @[connection-operators.md 218:17]
//   wire  c_io_b_ready; // @[connection-operators.md 218:17]
//   wire  c_io_b_valid; // @[connection-operators.md 218:17]
//   wire [7:0] c_io_b_bits; // @[connection-operators.md 218:17]
//   PipelineStage p ( // @[connection-operators.md 217:17]
//     .io_a_ready(p_io_a_ready),
//     .io_a_valid(p_io_a_valid),
//     .io_a_bits(p_io_a_bits),
//     .io_b_ready(p_io_b_ready),
//     .io_b_valid(p_io_b_valid),
//     .io_b_bits(p_io_b_bits)
//   );
//   PipelineStage c ( // @[connection-operators.md 218:17]
//     .io_a_ready(c_io_a_ready),
//     .io_a_valid(c_io_a_valid),
//     .io_a_bits(c_io_a_bits),
//     .io_b_ready(c_io_b_ready),
//     .io_b_valid(c_io_b_valid),
//     .io_b_bits(c_io_b_bits)
// ...

Conclusion:

Both <> and := can be used to assign directioned things (IOs) to DontCare as shown in io.in and p.io.a respectively. This is basically equivalent because in this case both <> and := will determine the direction from the LHS.

Concept 5: <> works between things with at least one known flow (An IO or child’s IO).

If there is at least one known flow what will <> do? This will be shown using the experiment code below: ( Scastie link for the experiment:https://scastie.scala-lang.org/Shorla/gKx9ReLVTTqDTk9vmw5ozg)

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(DecoupledIO(UInt(8.W)))
  val out = DecoupledIO(UInt(8.W))
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  //connect Producer to IO
    // For this experiment, we add a temporary wire and see if it works...
  //p.io.a <> io.in
  val tmp = Wire(DecoupledIO(UInt(8.W)))
  // connect intermediate wire
  tmp <> io.in
  p.io.a <> tmp
  // connect producer to consumer
  c.io.a <> p.io.b
  //connect consumer to IO
  io.out <> c.io.b
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.b <> io.a
}

Below we can see the resulting Verilog for this example:

ChiselStage.emitVerilog(new Wrapper)
// res9: String = """module PipelineStage(
//   output       io_a_ready,
//   input        io_a_valid,
//   input  [7:0] io_a_bits,
//   input        io_b_ready,
//   output       io_b_valid,
//   output [7:0] io_b_bits
// );
//   assign io_a_ready = io_b_ready; // @[connection-operators.md 288:8]
//   assign io_b_valid = io_a_valid; // @[connection-operators.md 288:8]
//   assign io_b_bits = io_a_bits; // @[connection-operators.md 288:8]
// endmodule
// module Wrapper(
//   input        clock,
//   input        reset,
//   output       io_in_ready,
//   input        io_in_valid,
//   input  [7:0] io_in_bits,
//   input        io_out_ready,
//   output       io_out_valid,
//   output [7:0] io_out_bits
// );
//   wire  p_io_a_ready; // @[connection-operators.md 267:17]
//   wire  p_io_a_valid; // @[connection-operators.md 267:17]
//   wire [7:0] p_io_a_bits; // @[connection-operators.md 267:17]
//   wire  p_io_b_ready; // @[connection-operators.md 267:17]
//   wire  p_io_b_valid; // @[connection-operators.md 267:17]
//   wire [7:0] p_io_b_bits; // @[connection-operators.md 267:17]
//   wire  c_io_a_ready; // @[connection-operators.md 268:17]
//   wire  c_io_a_valid; // @[connection-operators.md 268:17]
//   wire [7:0] c_io_a_bits; // @[connection-operators.md 268:17]
//   wire  c_io_b_ready; // @[connection-operators.md 268:17]
//   wire  c_io_b_valid; // @[connection-operators.md 268:17]
//   wire [7:0] c_io_b_bits; // @[connection-operators.md 268:17]
//   PipelineStage p ( // @[connection-operators.md 267:17]
//     .io_a_ready(p_io_a_ready),
//     .io_a_valid(p_io_a_valid),
//     .io_a_bits(p_io_a_bits),
//     .io_b_ready(p_io_b_ready),
//     .io_b_valid(p_io_b_valid),
//     .io_b_bits(p_io_b_bits)
//   );
//   PipelineStage c ( // @[connection-operators.md 268:17]
//     .io_a_ready(c_io_a_ready),
//     .io_a_valid(c_io_a_valid),
//     .io_a_bits(c_io_a_bits),
//     .io_b_ready(c_io_b_ready),
//     .io_b_valid(c_io_b_valid),
//     .io_b_bits(c_io_b_bits)
// ...

Conclusion:

The connection above went smoothly with no errors, this goes to show <> will work as long as there is at least one directioned thing (IO or submodule’s IO) to “fix” the direction.

Concept 6: <> and := connect signals by field name.

This experiment creates a MockDecoupledIO which has the same fields by name as a DecoupledIO. Chisel lets us connect it and produces the same verilog, even though MockDecoupledIO and DecoupledIO are different types. ( Scastie link for the experiment:https://scastie.scala-lang.org/Uf4tQquvQYigZAW705NFIQ)

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

class MockDecoupledIO extends Bundle {
  val valid = Output(Bool())
  val ready = Input(Bool())
  val bits = Output(UInt(8.W))
}
class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(new MockDecoupledIO())
  val out = new MockDecoupledIO()
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  // connect producer to I/O
  p.io.a <> io.in
  // connect producer  to consumer
  c.io.a <> p.io.b
  // connect consumer to I/O
  io.out <> c.io.b
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.a <> io.b
}

Below we can see the resulting Verilog for this example:

ChiselStage.emitVerilog(new Wrapper)
// res11: String = """module PipelineStage(
//   output       io_a_ready,
//   input        io_a_valid,
//   input  [7:0] io_a_bits,
//   input        io_b_ready,
//   output       io_b_valid,
//   output [7:0] io_b_bits
// );
//   assign io_a_ready = io_b_ready; // @[connection-operators.md 341:8]
//   assign io_b_valid = io_a_valid; // @[connection-operators.md 341:8]
//   assign io_b_bits = io_a_bits; // @[connection-operators.md 341:8]
// endmodule
// module Wrapper(
//   input        clock,
//   input        reset,
//   input        io_in_valid,
//   output       io_in_ready,
//   input  [7:0] io_in_bits,
//   output       io_out_valid,
//   input        io_out_ready,
//   output [7:0] io_out_bits
// );
//   wire  p_io_a_ready; // @[connection-operators.md 325:17]
//   wire  p_io_a_valid; // @[connection-operators.md 325:17]
//   wire [7:0] p_io_a_bits; // @[connection-operators.md 325:17]
//   wire  p_io_b_ready; // @[connection-operators.md 325:17]
//   wire  p_io_b_valid; // @[connection-operators.md 325:17]
//   wire [7:0] p_io_b_bits; // @[connection-operators.md 325:17]
//   wire  c_io_a_ready; // @[connection-operators.md 326:17]
//   wire  c_io_a_valid; // @[connection-operators.md 326:17]
//   wire [7:0] c_io_a_bits; // @[connection-operators.md 326:17]
//   wire  c_io_b_ready; // @[connection-operators.md 326:17]
//   wire  c_io_b_valid; // @[connection-operators.md 326:17]
//   wire [7:0] c_io_b_bits; // @[connection-operators.md 326:17]
//   PipelineStage p ( // @[connection-operators.md 325:17]
//     .io_a_ready(p_io_a_ready),
//     .io_a_valid(p_io_a_valid),
//     .io_a_bits(p_io_a_bits),
//     .io_b_ready(p_io_b_ready),
//     .io_b_valid(p_io_b_valid),
//     .io_b_bits(p_io_b_bits)
//   );
//   PipelineStage c ( // @[connection-operators.md 326:17]
//     .io_a_ready(c_io_a_ready),
//     .io_a_valid(c_io_a_valid),
//     .io_a_bits(c_io_a_bits),
//     .io_b_ready(c_io_b_ready),
//     .io_b_valid(c_io_b_valid),
//     .io_b_bits(c_io_b_bits)
// ...

And here is another experiment, where we remove one of the fields of MockDecoupledIO: ( Scastie link for the experiment:https://scastie.scala-lang.org/ChtkhKCpS9CvJkjjqpdeIA)

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.DecoupledIO

class MockDecoupledIO extends Bundle {
  val valid = Output(Bool())
  val ready = Input(Bool())
  //val bits = Output(UInt(8.W))
}
class Wrapper extends Module{
  val io = IO(new Bundle {
  val in = Flipped(new MockDecoupledIO())
  val out = new MockDecoupledIO()
  })
  val p = Module(new PipelineStage)
  val c = Module(new PipelineStage) 
  // connect producer to I/O
  p.io.a <> io.in
  // connect producer  to consumer
  c.io.a <> p.io.b
  // connect consumer to I/O
  io.out <> c.io.b
}
class PipelineStage extends Module{
  val io = IO(new Bundle{
    val a = Flipped(DecoupledIO(UInt(8.W)))
    val b = DecoupledIO(UInt(8.W))
  })
  io.a <> io.b
}

Below we can see the resulting error for this example:

ChiselStage.emitVerilog(new Wrapper)
// chisel3.internal.ChiselException: Connection between left (PipelineStage.io.a: IO[DecoupledIO]) and source (Wrapper.io.in: IO[MockDecoupledIO]) failed @.bits: Right Record missing field (bits).
// 	at ... ()
// 	at repl.MdocSession$App12$Wrapper.<init>(connection-operators.md:381)
// 	at repl.MdocSession$App12$$anonfun$126$$anonfun$apply$37.apply(connection-operators.md:402)
// 	at repl.MdocSession$App12$$anonfun$126$$anonfun$apply$37.apply(connection-operators.md:402)
// 	at ... ()
// 	at ... (Stack trace trimmed to user code only. Rerun with --full-stacktrace to see the full stack trace)

This one fails because there is a field bits missing.

Conclusion:

For :=, the Scala types do not need to match but all the signals on the LHS must be provided by the RHS or you will get a Chisel elaboration error. There may be additional signals on the RHS, these will be ignored. For <>, the Scala types do not need to match, but all signals must match exactly between LHS and RHS. In both cases, the order of the fields does not matter.