Closed yelbuod closed 3 years ago
OK, I check the Verilog generated by this example:
module Queue(
input clock,
input reset,
output io_enq_ready,
input io_enq_valid,
input [8:0] io_enq_bits,
input io_deq_ready,
output io_deq_valid,
output [8:0] io_deq_bits
);
......
......
module QueueModule(
input clock,
input reset,
output in_ready,
input in_valid,
input [8:0] in_bits,
input out_ready,
output out_valid,
output [8:0] out_bits
);
wire q_clock; // @[Decoupled.scala 296:21]
wire q_reset; // @[Decoupled.scala 296:21]
wire q_io_enq_ready; // @[Decoupled.scala 296:21]
wire q_io_enq_valid; // @[Decoupled.scala 296:21]
wire [8:0] q_io_enq_bits; // @[Decoupled.scala 296:21]
wire q_io_deq_ready; // @[Decoupled.scala 296:21]
wire q_io_deq_valid; // @[Decoupled.scala 296:21]
wire [8:0] q_io_deq_bits; // @[Decoupled.scala 296:21]
Queue q ( // @[Decoupled.scala 296:21]
.clock(q_clock),
.reset(q_reset),
.io_enq_ready(q_io_enq_ready),
.io_enq_valid(q_io_enq_valid),
.io_enq_bits(q_io_enq_bits),
.io_deq_ready(q_io_deq_ready),
.io_deq_valid(q_io_deq_valid),
.io_deq_bits(q_io_deq_bits)
);
assign in_ready = q_io_enq_ready; // @[Decoupled.scala 299:17]
assign out_valid = q_io_deq_valid; // @[cmd2.sc 4:7]
assign out_bits = q_io_deq_bits; // @[cmd2.sc 4:7]
assign q_clock = clock;
assign q_reset = reset;
assign q_io_enq_valid = in_valid; // @[Decoupled.scala 297:22]
assign q_io_enq_bits = in_bits; // @[Decoupled.scala 298:21]
assign q_io_deq_ready = out_ready; // @[cmd2.sc 4:7]
endmodule
I found that there is simply inputs connect inputs and outputs connect outputs between Queue
and QueueModule
. As far as I understand it, there is a instantiation of Queue
module in QueueModule
, so QueueModule
and Queue
match the parent/child modules and <>
bulk-connect operator connects interfaces of the same gender as the documentation
So I understand that I ignored the Queue
itself is also a module and the format of the example:
case class QueueModule[T <: Data](ioType: T, entries: Int) extends MultiIOModule {
val in = IO(Flipped(Decoupled(ioType)))
val out = IO(Decoupled(ioType))
out <> Queue(in, entries)
}
will match QueueModule
/Queue
to parent/child modules.
In 2.6 chiseltest of chisel-bootcamp tutorials, there is a example about create a Queue using
Decoupled
interface:the
<>
operator's direction in the last lineout <> Queue(in, entries)
is really confusing to me as I check<>
operator of classDecoupledIO
in chisel-api and got the definition is "Connect this data to that data bi-directionally and element-wise." which meansout
andQueue(in, entries)
's return must be bi-directionally. However, I found theQueue
source code:which return
q.io.deq
byTransitName
method, andq.io.deq
are defined as follows:that means
q.io.deq
is No-FlippedDecoupledIO
and has the same interface direction ofout
. So I really want to know that how<>
works inout <> Queue(in, entries)
???? Is that wrong OR I got the version mismatch.