Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
LOOK AHEAD FLAG FOR FIFO
Document Type and Number:
WIPO Patent Application WO/1994/012983
Kind Code:
A1
Abstract:
The invention provides fast generation of flag signals for devices, such as first-in first-out buffers, by looking-ahead and predetermining flag signals for possible future states of the device. The look-ahead signal generator, in one embodiment of the invention, uses odd/even read counters (203, 204) and odd/even write counters (201, 202), controlled by clock signals (WEVEN, WODD, REVEN, RODD), which outputs thereof are coupled, respectively, to comparators (205, 206) for generating flag signals EQE and EQO which in turn are multiplexed through pass-gates (503, 512) to the FLAG output terminal of the look-ahead signal generator. Pass-gates (503, 512) are respectively controlled by inverters (502, 511) connected in series with NAND gates (501, 510). The other two series connections of NAND gates (504, 507) and inverters (505, 508) control the multiplexing of other possible future states of the device, to the FLAG output terminal of the look-ahead signal generator.

Inventors:
LEE TSU-WEI FRANK
Application Number:
PCT/US1993/010859
Publication Date:
June 09, 1994
Filing Date:
November 10, 1993
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
PARADIGM TECHNOLOGY INC (US)
International Classes:
G06F5/10; G06F5/14; (IPC1-7): G11C7/00
Foreign References:
US4888741A1989-12-19
US5084841A1992-01-28
US5121346A1992-06-09
US5206817A1993-04-27
US5214607A1993-05-25
US5267191A1993-11-30
Download PDF:
Claims:
CLAIMS
1. I claim: An apparatus for setting a flag signal to indicate a status of a device, the apparatus comprising: (a) a look ahead signal generator having a plurality of output leads, the look ahead signal generator generating a plurality of flag signals one on each of the plurality of output leads, each flag signal of the plurality of flag signals corresponding to a possible state of the device and indicating the status of the device if the device where in the corresponding state; and (b) a signal selector having a plurality of input leads and an output lead, the plurality of input leads of the signal selector being electrically coupled to the plurality of output leads of the look ahead signal generator, the signal selector setting a flag signal on the output lead of the signal selector by selecting one of the plurality of status' signals generated by the status signal generator.
2. The apparatus of claim 1, wherein the device is a firstin firstout buffer capable of conducting write operations and read operations and wherein: the plurality of output leads of the look ahead signal generator comprises four output leads, one of the four output leads providing a flag signal indicating the current status of the firstin firstout buffer, another of the four output leads providing a flag signal indicating the status the firstin firstout buffer would have after a single write operation, another of the four output leads providing a flag signal indicating the status the firstin firstout buffer would have after a single read operation, and another of the four output leads providing a flag signal indicating the status the firstin firstout buffer would have after a single write operation and a single read operation.
3. The apparatus of claim 1, wherein the device is a firstin firstout buffer having a read pointer and a write pointer, the read pointer having an associated read pointer value indicating where a next piece of data may be read, the write pointer having an associated write pointer value indicating where a next piece of data may be written.
4. The apparatus of claim 3, wherein the look ahead signal generator further comprises: (a) a plurality of read counters, each read counter having a plurality of output leads and a clock lead, the plurality of output leads of each read counter providing signals that represent a read counter value, the read counter value being a possible value for the read pointer; (b) a plurality of write counters, each write counter having a plurality of output leads and a clock lead, the plurality of output leads of each write counter providing signals that represent a write counter value, the write counter value being a possible value for the write pointer; and (c) a plurality of comparison circuits, each comparison circuit having a first plurality of input leads, a second plurality of input leads and an output lead, the first plurality of input leads of each comparison circuit being connected to the output leads of one of the plurality of read counters, the second plurality of input leads of each comparison circuit being connected to the output leads of one of the plurality of write counters, the output leads of the plurality of comparison circuits being the output leads of the look ahead signal generator, each comparison circuit providing on the output lead of the comparison circuit a flag signal which indicates the status that the firstin firstout buffer would have if the read pointer value equaled the read counter value provided by the connected read counter and the write pointer value equalled to the write counter value provided by the connected write counter.
5. The apparatus of claim 4, wherein the signal selector further comprises a multiplexer having an output lead, a plurality of select leads, and a plurality of input leads, the plurality of input leads of the multiplexer being the input leads of the signal selector, the output lead of the multiplexer being on the output lead of the signal selector.
6. The apparatus of claim 5, further comprising a clock signal generator having a plurality of output leads connected to the clock leads of the plurality of read counters, the clock leads of the plurality of write counters, and the plurality of select leads of the multiplexer, the clock signal generating signals which select the flag signal on the output lead of the multiplexer and cause the counters to increment.
7. The apparatus of claim 6, wherein: (a) the plurality of read counters comprise a read odd counter and a read even counter; (b) the plurality of write counters comprise a write odd counter and a write even counter; (c) the plurality of comparison circuits comprise an eveneven comparator and an oddodd comparator, the read even counter and write even counter being the read counter and write counter connected to the eveneven comparator, the read odd counter and write odd counter being the read counter and write counter connected to the oddodd comparator, the flag signal provided by the eveneven comparator indicating if the read counter value on even read counter equals the write counter value on even write counter, the flag signal provided by the oddodd comparator indicating if the read counter value on odd read counter equals the write counter value on odd write counter; and (d) the plurality of output leads of the clock signal generator comprising a read even lead connected to the clock lead of the read odd counter and connected to a select lead of the plurality of select leads of the multiplexer, a read odd lead connected to the clock lead of the read even counter and a select lead of the plurality of select leads of the multiplexer, a write even lead connected to the clock lead of the odd write counter and a select lead of the plurality of select leads of the multiplexer, and a write odd lead connected to the clock lead of the even write counter and a select lead of the plurality of select leads of the multiplexer, the signals generated by the clock signal generator causing the read even counter to increment by two when the read pointer value changes from even to odd, causing the read odd counter to increment by two when the read pointer value changes from odd to even, causing the write even counter to increment by two when the write pointer value changes from even to odd, and causing the write odd counter to increment by two when the write pointer value changes from odd to even.
8. A method for changing a flag signal which indicates a status of a device, the method comprising the steps of: (a) predetermining flag signals corresponding to possible new states of the device, such that each predetermined flag signal indicates the status that the device would have if the device where in the corresponding possible new state; and (b) selecting a flag signal from the predetermined flag signals when the state of the device changes from an old state to a new state.
9. The method of claim 8, wherein the device is a firstin firstout buffer and the step of predetermining flag signals corresponding to possible new states comprises: (a) determining a flag signal corresponding to the state of the firstin firstout buffer after a read operation; (b) determining a flag signal corresponding to the state of the firstin firstout buffer after a write operation; and (c) determining a flag signal corresponding to the state of the firstin firstout buffer after a read operation and a write operation.
10. The method of claim 9, wherein the step of selecting the flag signal when the state of the device changes further comprises: (a) asserting a flag signal corresponding to a current state of the device to an input lead of a multiplexer; (b) asserting the predetermined flag signals corresponding to the possible new states to the inputs of a multiplexer; (c) asserting a select signal to the select lines of the multiplexer, the select signal selecting an output of the multiplexer to be the flag signal corresponding to the current state of the device for long as the device remains in the current state, but when the state of the device changes to a new state then the select signal selects a flag signal corresponding to the new state.
11. A method for generating flag signals for possible states of a device wherein each possible state of the device is determined by an associated first and second integer value, the method comprising the steps of: determining a current difference which equals difference between the first integer value associated with the current state and the second integer value associated with a current state; determining if the current difference is greater than a constant; determining if the current difference equals the constant; and if the current difference is greater than or equal to the constant then generating for a first possible state a flag signal that indicates the associated first integer value minus the associated second integer value is greater than the constant, wherein the first integer value associated with the first possible state is greater than the first integer value associated with the current state and the second integer value associated with the first possible state is not greater than the second integer value associated with the current state.
12. The method of claim 11 further comprising: determining if the current difference equals the constant plus one; and if the current difference is greater than the constant and is not equal to the constant plus one then generating for a second possible state a flag signal that indicates the associated first integer value minus the associated second integer value is greater than the constant, wherein the first integer value associated with the second possible state is not less than the first integer value associated with the current state, and the second integer value associated with the second possible state is one greater than the second integer value associated with the current state.
13. The method of claim 11 further comprising: determining if the current difference equals the constant minus one; and if the current difference is not greater than the constant and not equal to the constant and not equal to the constant minus one then generating for a second possible state a flag signal that indicates the associated first integer value minus the associated second integer value is less than the constant, wherein the first integer value associated with the second possible state one greater than the first integer value associated with the current state, and the second integer value associated with the second possible state is not less than the second integer value associated with the current state.
14. The method of claim 12 wherein the flag values which indicate whether the first integer value minus the second integer value is greater than the constant are used to indicate that the first integer value minus the second integer value is greater than or equal to the constant plus one.
15. The method of claim 12 wherein the flag values which indicate whether the first integer value minus the second integer value is greater than the constant are used to indicate that the first integer value minus the second integer value is less than or equal to the constant.
16. The method of claim 12 wherein the flag values which indicate whether the first integer value minus the second integer value is greater than the constant are used to indicate that the first integer value minus the second integer value is less than the constant minus one.
Description:
Look Ahead Flag for FIFO

BACKGROUND OF THE INVENTION

Field of the Invention The present invention relates to the setting of flag signals which indicate the status of a device such as an first-in first-out buffer.

Description of Related Art

A first-in first-out (FIFO) buffer often is useful between devices with different clock frequencies. In typical operation of a FIFO, a first device, such as micro-processor writes to the FIFO buffer and a second device, such as a peripheral or a second microprocessor, reads from the FIFO buffer. Each device reads or writes according to its own clock. Because two different clocks control the timing of read and write operations, the buffer handles the operations asynchronously, and the devices may write then read with a very short time separation. To maximize data flow the FIFO buffer must be ready to respond to the next operation quickly. Any processing time required between one operation and a subsequent operation can delay the subsequent operation and slow the rate of data flow through the buffer. In particular, the time that the buffer takes to recalculate status flags after an action by one processor tends to slows down the buffer.

Figure 1 show a typical application of a FIFO buffer 103. The FIFO buffer 103 holds data that is written to the buffer 103 by a first device 101 and read from the buffer 103 by a second device 102. Besides holding the data, the buffer 103 sends flag signals to the attached devices 101 and 102. For example the buffer 103 could send a full signal to the first device on a flag line 106

when the buffer is full, or could send an empty signal to the second device 102 on line 107 when the buffer is empty.

When the first device 101 has data to write to the buffer 103, the first device 101 checks for the full flag signal on line 106. If the flag signal indicates the buffer 103 is full the first device 101 must wait before sending data to buffer 103. If the buffer 103 is not full the first device 101 asserts data signals to the data lines 104 and sends a write clock or control signal to the buffer 103 on a line 108. The buffer 103 stores the data in a memory location pointed to by a write pointer and then increments the write pointer.

When data is in the buffer 103 the buffer 103 clears the empty signal on line 107, which indicates to the second device 102 that data is available to be read from the buffer 103. The second device 102 sends a clock or control signal to the buffer 103 on line 109, and the buffer 103 asserts to data lines 105 the data pointed to by a read pointer. After the second device 102 reads the data, the buffer 103 increments the read pointer.

With this architecture if the read pointer and the write pointer point to the same location then the FIFO buffer is either empty or full. It is full if enough data has been written so that the write pointer has just incremented to equal the read pointer. It is empty if the read pointer has just incremented to equal the write pointer. The FIFO buffer needs to signal these two conditions to the devices connected to the buffer. When the two devices connected to a FIFO buffer do not have synchronized clocks, reads and writes to the buffer occur asynchronously, so the read pointer and write pointer change asynchronously. Still, when one of the devices connected to the buffer takes an action, the various status flags need to be changed to reflect the new values of the pointers. The devices connected to the buffer either wait while the new flags are calculated or

take actions based on incorrect flags. The speed of the FIFO buffer, therefore, may be limited by the speed of flag output. If the speed of the flag output is improved then the speed of the FIFO can be improved. In a FIFO buffer, flag output is normally generated from the values of the two pointers. For example, immediately after a device writes data to the buffer the read pointer may point to location i and the write pointer may point to location j. The full flag needs to be activated if the two pointers point to the same location, i.e. i=j. In typical prior art architecture the FIFO buffer would compare the two pointer values and generate the flag for the connected device act on. The connected devices normally have to wait the time it takes a comparator to generate a flag signal. Accordingly, a need exists to reduce or eliminate this wait and thereby speed up the operation of the system including the FIFO buffer.

SUMMARY OF THE INVENTION

Embodiments of the present invention speed up a flag output from a FIFO buffer by looking ahead and predetermining possible new flag signals. When the state of the FIFO buffer changes, the buffer switches the flag output from the old signal to one of the predetermined flag signals. The FIFO buffer is ready to handle data as soon as the flag output is switched. Generally, switching time is considerably shorter than the time for a comparator to calculate a new flag value. The faster response decreases the time that flag signals incorrectly indicate the state of the FIFO buffer. Calculating all possible next flag signals does not delay device actions because the possible flag signals are calculated ahead of time.

Embodiments of the invention described in detail below include a look ahead signal generator which generates four flags signals. One of the flag signals is the current flag signal corresponding to the current state

of the FIFO buffer. The other three signals correspond to possible states that the buffer would have after one read, or one write, or one read and one write. These three states are the only states that can be reached by read and/or write operations within a time interval less than the shortest clock period of devices attached to the buffer. Any other state of the buffer takes more than a clock period to reach.

For example to reach the state that occurs after two writes takes at least one clock period of the device writing to the buffer. The buffer cannot predict when a write will occur. However, because write operations are controlled by the clock of the writing device, after a first write operation occurs a second write operation comes at the soonest in the next clock cycle of the writing device. The flag generator uses the time between the first write and the second write to predetermine the flag corresponding to the state the buffer would have after the second write. The four flag signals are connected to the inputs of a signal selector. In some embodiments, the signal selector is just a multiplexer. The signal selector chooses the flag signal corresponding to the current state of the FIFO buffer as an output signal. When a device reads or writes to the buffer the multiplexer passes the predetermined flag signal corresponding to the new current state of the FIFO buffer. The flag generator then calculates possible new flag signals based on the new current state. Since the previously generated possible states includes all of the states that could be reached within the shortest clock period of a device attached to the FIFO buffer, the flag generator has at least a clock cycle to calculate new possible flag signals. The flag signals change as quickly as the signal selector can select an output signal.

The look ahead signal generator in some embodiments of the invention employs a method which quickly determines

half full, almost full, or almost empty flags. Half full flags and almost full flags indicate whether the buffer is more than half full or is almost full. Almost empty flags indicate whether the buffer is almost empty. The method does a single subtraction of the current value of the read pointer from the current value of the write pointer. The values of the status flags for the current state of the buffer and the three possible new states are generated relying on the arithmatic relationships between the possible pointer values.

This invention will be more fully understood in light of the following detailed description taken together with the drawings.

BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 shows a diagram of a typical FIFO buffer attached to two devices.

Figure 2 shows a block diagram of an embodiment of a look ahead signal generator.

Figure 3 is a timing diagram showing signals that control the operation of the look ahead signal generator of figure 2 and the signal selector of figure 5.

Figure 4 shows a circuit diagram which may be used to generate signals REVEN and RODD from a read clock signal or WEVEN and WODD from a write clock signal. Figure 5 shows a circuit diagram of a signal selector which takes the form of a multiplexer that may be use in conjunction with the circuit of figure 2.

Figure 6 shows a circuit diagram of a portion of a look ahead signal generator used to generate flags indicating that the difference between the read and the write pointer values is greater than a constant C.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Embodiments of the invention described here provide fast generation of flag signals by predetermining a set of possible flag signals for possible future states and

switching to the appropriate predetermined signal when the state changes. An embodiment of the invention can be used with the FIFO buffer described above to generate the flag signals for a current state and for future possible states.

One way to name the states of a FIFO buffer is by the values of the read and the write pointers. If the current value of the read pointer is i and the current value of the read pointer is j, the current state of the buffer can be referred to as (i,j).

The look ahead signal generator generates a flag signal for the current state (i,j) and for three possible new states (i,j+l), (i+l,j), and (i+i,j+i). These are the four states that can be reached in less than a clock cycle as described above and therefore need to be generated ahead of time to prevent delays.

Another way to name the four states is according to whether the read pointer and write pointer values are even or odd. Flag signals can be generated for the four states (even read, even write) , (odd read, odd write) , (even read, odd write) , and (odd read, odd write) . Any of these four state could be the current state depending on the values of i and j. If i and j are both even then the current state (i,j) is (even read, even write), (i,j+l) is (even read, odd write), (i+1, j) is (odd read, even write), and (i+l,j+l) is (odd read, odd write). If i and j are both odd the current state (i,j) is (odd read, odd write) , etc.

Figure 2 shows a circuit diagram of part of a look ahead signal generator used to generate either a full flag signal or an empty flag signal. The circuit shown generates flag signals EQE and EQO for the states (even read, even write) and (odd read, odd write) . The flag signals for (even read, odd write) and (odd read, even write) are always low in the full flag or empty flag case because an even number can never equal an odd number.

An even read counter 204 holds an even value corresponding to either i or i+1. If i is even, read counter 204 holds the value i. If i is odd, read counter 204 holds the value i+l. An odd read counter 203 holds an odd value corresponding to i+l or i (if i is odd, counter 203 holds i; if i is even, counter 203 holds i+l) . In the same way, an even write counter 202 holds an even value corresponding to j or j+1 and an odd write counter 201 holds an odd value corresponding to j+1 or j. Comparator 205 compares the value in the even read counter 204 to the value in the even write counter 202 and generates the flag signal EQE for the state (even read, even write) . Comparator 206 similarly compares the values in the odd read counter 203 to the value in the odd write counter 201 and generates the flag signal EQO for the state (odd read, odd write) . Again, no calculation is necessary for the state (even read, odd write) or (odd read, even write) because an even value can never equal an odd value, and the flags for (even read, odd write) or (odd read, even write) should never indicate a full or empty buffer.

Each of the counters 201-204 increments by 2 every time the counter is clocked. This keeps even counts even and odd counts odd. Figure 3 shows a voltage verses time plot for a number of clock signals. A write clock signal is generated by the device that writes to the buffer. The buffer latches data from the data lines and increments the write pointer on the rising edge of the write clock signal. A read clock signal controls the reading of data by the second device. On a rising edge of the read clock signal the buffer increments the read pointer. REVEN (RODD) is a signal that is high when the value held in the read pointer is even (odd) . WEVEN (WODD) is a signal that is high when the value held in the write pointer is even (odd) .

The signals REVEN and RODD may be easily generated from the read clock signal using a D flip-flop 401 as

shown in Figure 4. The read clock signal is asserted to lead 402 and produces signals REVEN and RODD on leads 404 and 403. WEVEN and WODD are generated from the write clock signal in the same fashion using a structure the 5 same as that shown in Figure 4.

Again considering figure 3, on every rising edge of the read clock the read pointer increments and the signal REVEN changes voltage level. Initially REVEN is high, and the read pointer value is zero. Every time a read is done

10 REVEN alternates between high and low, and the value of the read pointer alternates between even and odd. Thus, as stated above, signal REVEN indicates if the read counter is even as stated above. Similarly, RODD indicates if the read counter is odd, and WEVEN and WODD

15 indicates if the write counter is even and odd.

At start up of the buffer both pointer values are zero. Signals REVEN and WEVEN are high. Signals RODD and WODD are low. The even read counter 204, the odd read counter 203, the even write counter 202, and the odd write

20 counter 201 hold values 0, 1, 0, and 1 respectively. The flag signal EQE indicates the read and write pointers are equal for the (even read, even write) state, and the flag signal EQO indicates the read and write pointers are equal for the (odd read, odd write) state.

25 If a write operation is performed just after start up the current state goes from (even read, even write) to (even read, odd write) , and a signal selector switches the current flag output as will be described below. In Figure 3 the rising edge 301 of the write clock signal signals a

30 write operation. Signal WEVEN drops to low and signal WODD rises to high. The rising edge 303 of signal WODD clocks the even write counter 202 and the even write counter 202 increments by 2. As a result the even read counter 204, odd read counter 203, the even write counter

35 202, and the odd write counter 201 hold values 0, 1, 2, and 1 respectively. The comparator 205 now compares 0 and

2 and drops the EQE signal to low indicating the flag signal for (even read, even write) state.

There is a comparator delay time before the flag signal for (even read, even write) is ready. But the (even read, even write) flag is not needed immediately because the current values of the read and write pointers are 0 and 1. The current flag signal is the (even read, odd write) signal which was predetermined and is ready. The (even read, even write) signal would only be needed after a second write operation. Because successive write operations are separated in time by at least one clock cycle of the writing device there is time for the comparator to complete its operation.

The next write operation causes the odd write counter to increment by 2, from 1 to 3. Subsequent write operations alternate between causing the even write and the odd write counter to increment by 2. Read operations cause exactly analogous increments of the even read and odd read counters. The outputs signals EQE for the (even read, even write) state, EQO for the (odd read, odd write) state, and permanently low signals for (even read, odd write) and (odd read, even write) are input into a multiplexer which selects the correct signal for flag output. Figure 5 shows a circuit diagram of a signal selector which in this embodiment is a typical multiplexer that uses the signals REVEN, RODD, WEVEN, and WODD to select the correct flag signal.

In figure 5 a NAND gate 501 and an inverter 502 activate pass gate 503 thereby making a signal FLAG equal to the signal EQE when both the read pointer and the write pointer are even. NAND gate 510 and an inverter 511 activate pass gate 512 thereby making a signal FLAG equal to the signal EQO when both the read pointer and the write pointer are odd. When the read pointer is odd and the write pointer is even output from NAND gate 504 is low, output from inverter 505 is high, and n channel transistor

506 switches on. The output signal FLAG is set to low reference voltage GND. Similarly NAND gate 507, inverter 508, and n channel transistor 509 set the signal FLAG to low when the read pointer is even and the write pointer is odd.

The signal flag is set whenever the read pointer and write pointer are equal. Making the signal FLAG an empty flag or a full flag requires additional circuitry that can be coupled to the FLAG output lead. There are many known ways to make the additional circuitry. One way is to combine the signal FLAG with a half full flag through a AND gate for a full flag or a NAND gate for a empty flag. If the buffer is at least half full and the pointers are equal then the buffer is full. If the buffer is less than half full and the pointers are equal then the buffer is empty. Additional circuitry could alternatively check if the last operation was a write. If the last operation was a write to the buffer then there is data in the buffer. The read and write pointer being equal indicates the buffer is full, and the full flag should be set.

Otherwise, the last operation must have been a read which emptied the buffer and the empty flag should be set.

Embodiments of the invention may also be used to generate flag signals that are set whenever the difference between the write pointer value and the read pointer value is less than, less than or equal to, greater than, greater than or equal to, or equal to any fixed value. For example a half full flag may be set whenever the buffer is more than half full, or an almost full flag may be set when the buffer is 90% full, or an almost empty flag may be set if the buffer is less than 10% full. To generate these flags a flag generator needs to compare the difference between the pointer values to the fixed value. For a half full flag or an almost full flag, if i and j are the current values of the read and write pointer, a flag needs to be set if j-i is greater than a value C. For look ahead the current state and three possible future

states need to be considered. The look ahead signal generator must determine if j-(i+l), (j+l)-i, and (j+1)- (i+1) are greater than C. Clearly, j-i = (j+1)-(i+l) so states (i,j) and (i+l,j+1) always have the same flag signal, and only three states need to be considered. One method to calculate these flags is to do three multibit subtractions followed by three comparisons to C.

Another method only requires a single multibit subtraction. The subtraction calculates a number X = j-i then relies on (j+l)-i > j-i > j-(i+l), and the fact that all four states have the same flag signal unless j-i = C or j-i = C+l. If j-i = C then the flag is not set for state (i,j) or state (i+l,j), but would be set for state (i,j+l). If j-i = C+l the flag for states (i,j) and (i,j+l) would be set but the flags for (i+l,j) would not be set.

The look ahead signal generator of figure 6 generates the four flag signals fy, fy +1 , fj + i j , f .+ i j+ i for the states (i,j), (i,j+l), (i+l,j) and (i+l,j+1). These four flag signal are for input into a signal selector which selects a correct predetermined flag signal as the new output flag when the state of the buffer changes.

As shown in figure 6, the current flag value may be used in the calculation of flags of the next set of possible states. In the look ahead method the flag for the current state (i,j) is predetermined and therefore available.

XNOR gates 605-608 compare signals representing a four bit binary representation of C with the binary representation of X = j-i. The signals for C 0 -C 3 are either VCC or are ground and can be hard wired for a fixed value of C or can be a programmable value read from a memory. The signals X 0 -X 3 come from a subtractor that subtracts i from j. The output signal from XNOR gate 605 is high if two binary digits X 0 and C 0 are equal, both low or both high. An output signal fj from AND gate 604 is high only if all the binary digits are equal.

The logic assumes that C and X are four bit numbers. If C and X contain more than four bits then more XNOR gates are needed and the number of inputs of the AND gate 604 and NAND gate 603 need to be increased but the rest of the circuit remains unchanged.

OR gate 601 sets the signal f iJ+1 high if f y is high or if f j is high. That the flag signal is correct is shown by simple relationships, if j-i > C then (j+l)-i > C or if j- i = C then (j+l)-i = C+l > C. The inputs signals on the XNOR gates 609-612 are binary digits of X and (C+l) . The output signal f 2 of NAND gate 603 is high unless X = C+l. AND gate 602 sets flag signal f i+ i j high if f y is high and X does not equal C+l. Again arithmatic relationships show that this is the correct logic. If j-i = C+l > C then j-(i+l) = C and is not greater than C, but if j-i > C and j-i does not equal C+l then j-i > C+l, because j-i is an integer, and j-(i+l) = (j-i)-l > (C+l)-l = C.

Although the above paragraphs dealt with a flag such as an half full or almost full flag that was set when the difference between pointers is greater than some value C, the technique applies to flags that are set when the difference between pointer values is greater than or equal to, less than, or less than or equal to a value C. The "greater than or equal to C" flags are equivalent to "greater than C-l" flags, since pointer are integer values. The "less than C" flags such as an almost empty flag can be generated by inverting the value of "greater than C-l" flag. The look ahead circuits and methods described above have mostly been described in connection with a FIFO buffer. It should be apparent that the invention can be more generally applied to other systems that need to generate status flags. Although the present invention has been described in detail, the description is only illustrative and not limiting. Other embodiments of this invention will be

obvious in view of this disclosure to those skilled in the relevant arts.