| |||
| Home > Coprocessor Interface > Token queue management > Queue modification | |||
The queue is written to on each cycle. Buffer A accepts the data arriving at the interface, and the buffer A flag accepts the valid bit associated with the data. If the queue is not full, this results in no loss of data because the contents of buffer A are moved to buffer B during the same cycle.
If the queue is full, then the loading of buffer A is inhibited to prevent loss of data. In any case, no valid data is presented by the interface when the queue is full, so no data loss ensues.
The state of the three buffer flags is used to decide which buffer provides the queue output during each cycle. The output is always provided by the buffer containing the oldest data. This is buffer C if it is full, or buffer B or, if that is empty, buffer A.
A simple priority encoder, looking at the three flags, can supply the correct multiplexor select signals. The state of the three flags can also determine how data are moved from one buffer to another in the queue. Table 11.4 shows how the three flags are decoded.
Table 11.4. Addressing of queue buffers
| Flag C | Flag B | Flag A | S1 | S0 | Remarks |
|---|---|---|---|---|---|
| 0 | 0 | 0 | X | X | Queue is empty |
| 0 | 0 | 1 | 0 | 0 | B = A |
| 0 | 1 | 0 | 0 | 1 | C = B |
| 0 | 1 | 1 | 0 | 1 | C = B, B = A |
| 1 | 0 | 0 | 1 | X | - |
| 1 | 0 | 1 | 1 | X | B = A |
| 1 | 1 | 0 | 1 | X | - |
| 1 | 1 | 1 | 1 | X | Queue is full. Input inhibited |
New data can be moved into buffer A, provided the queue is not full, even if its flag is set, because the current contents of buffer A are moved to buffer B. When the queue is read, the flag associated with the buffer providing the information must be cleared. This operation can be combined with an input operation so that the buffer is overwritten at the end of the cycle during which it provides the queue output. This can be implemented by using the read enable signal to mask the flag of the selected stage, making it available for input. Figure 11.5 shows reading and writing a queue.
Four valid inputs (labeled One, Two, Three, and Four) are written into the queue, and are clocked into buffer A as they arrive. Figure 11.5 shows how these inputs are clocked from buffer to buffer until the first input reaches buffer C. At this point a read from the queue is required. Because buffer C is full, it is chosen to supply the data. Because it is being read, it is free to accept more input, and so it receives the value Two from buffer B, which in turn receives the value Three from buffer A. Because buffer A is being emptied by writing to buffer B, it can accept the value Four from the input.