By the release of 3.5.0, I'd like to include a new method "FlatIO" that does what you're asking for. We'd discussed ways to accomplish this in the past, but our previous ideas all had implementation or API difficulties. Chisel 3.5 has a new feature, DataView (
https://github.com/chipsalliance/chisel3/pull/1955), that makes it easier to implement this sort of feature, for example:
class Example extends Module {
val in = FlatIO(Flipped(Decoupled(UInt(8.W))))
val out = IO(Decoupled(UInt(8.W)))
out <> in
}
would emit as:
module Example(
input clock,
input reset,
input [7:0] bits,
input valid,
output ready,
input out_ready,
output out_valid,
output [7:0] out_bits
);
assign ready = out_ready; // @[main.scala 10:7]
assign out_valid = valid; // @[main.scala 10:7]
assign out_bits = bits; // @[main.scala 10:7]
endmodule
The 1 challenge is that dynamic indexing of Vecs that are views does not currently work, so while you could copy-paste this code and use it if you're on 3.5.0-RC1 or 3.5-SNAPSHOT, it does have some current limitations.