[Chisel] About Queue
Introduction
If you want to use a queue to pass data in Chisel, Queue class is provided.
I will explain how to use it.
Basic usage
Definition
val buf = Module(new Queue(gen = new UInt, entries = 10))
For 'gen', specify an instance of the type of data to be passed. For 'entries', specify the upper limit on the number of data that can be queued.
Input/output
Connect the data to be input to io.enq.bits.
buf.io.enq.bits := data
Set 'valid' and 'ready' to true when input data.
buf.io.enq.valid := true.B
buf.io.enq.ready := true.B
Similarly, connect io.deq.bits to the extraction destination and set 'valid' and 'ready'.
eXUnit.io.input := buf.io.deq.bits
buf.io.deq.valid := true.B
buf.io.deq.ready := true.B
In practice, since you want to use a queue, you would like to do something like "take something out of the queue when a certain condition is met.''
For example, when a calculation is completed, the next instruction is taken out of the instruction queue.
In such a case, you can define a "condition signal" and connect it to ready.
var complete = Wire(Bool())
・・・ //complete = true.B when calculation completes
buf.io.deq.valid := complete
This is a bit difficult to understand for a software developer's point of view, that instead of "calling the enq() method when a certain condition is met," control is done using signal values like this.
Reference
Recent Posts
See AllPhenomenon There is an array Check whether the index variable is within the size of the array, and access the element only if it is...
Overview When communicating data using a Queue, the following operations are possible: Queue.io.enq.valid: When set to false, data will...
What I want to do There are multiple similar units Most of processes are the same, only some differences. Select an appropriate unit...
Comments