The present invention relates to semiconductor integrated circuits and, more particularly, to a leading zero counter for use with aligning data within a binary word.
There are many applications in which there is a desire to align or normalize data within a binary word. For example, data normalization is often used in floating point arithmetic. In a binary computer, all numbers are stored in base two. For this reason, normalization of a binary floating point number simply requires that there be no leading zeros after the binary point that separates the 20 place from the 2-1 place. Other normalization and data alignment applications also exist.
A leading zero counter or search is therefore an integral part of a normalization procedure. A leading zero counter provides a shift count, which represents the number of single bit shifts that are required to align the leading-most “1” in the binary word to the left-most significant bit position in the binary word. The same technique can be used to align data in a networking application. For example, if each data segment has a preamble with a leading “1” and trailing zero padding, a leading zero counter can provide information for purging the zero padding and aligning the first bit of the next data segment using a shifter.
Conventional methods of counting or detecting leading zeros use a binary tree detection circuit. The number of logic levels in a binary tree detection circuit is logarithmic to the base two of the number of bits in the binary word. Therefore, the number of bits in the binary word directly translates to the propagation delay through the binary tree detection circuit. The greater the number of bits in the binary word, the greater the propagation delay through the circuit. Another difficulty with binary tree detection circuits is that once a leading zero count value has been determined, that count value must often be further decoded in order to control a shifter. This adds further delay and complexity to the circuit.
Improved leading zero counters and data alignment circuits are therefore desired.
One embodiment of the present invention is directed to a method of aligning data in a binary word. The method includes: (a) providing a coded address for each bit of the binary word; (b) modifying each coded address as a function of a logic state of the respective bit of the binary word to produce respective modified addresses; (c) generating a shift control word based on bit positions at which the modified addresses have a predetermined logic state; and (d) shifting bits in the binary word as a function of the shift control word to produce an aligned binary word.
Another embodiment of the present invention is directed to a data alignment circuit. The circuit includes a binary word input and a coded address for each bit of the binary word input. A first logic circuit modifies each coded address as a function of a logic state of the respective bit of the binary word input to produce respective modified addresses. A second logic circuit generates a shift control word based on bit positions at which the modified addresses have a predetermined logic state. A shift circuit shifts bits in the binary word input as a function of the shift control word to produce an aligned binary word output.
Another embodiment of the present invention is directed to a data alignment circuit having a binary word input and a thermometer-coded address for each bit of the binary word input. Each thermometer-coded address is modified as a function of a logic state of the respective bit of the binary word input to produce respective modified addresses. A shift control word is generated based on bit positions at which the modified addresses have a predetermined logic state. Bits in the binary word input are shifted as a function of the shift control word to produce an aligned binary word output.
Another embodiment of the present invention is directed to a method of generating a leading zero count. The method includes: receiving a binary word and generating a count of leading zeros in the binary word with a substantially constant delay regardless of a number of bits in the binary word, except for changes in loading delay caused by changes in the number of bits in the binary word.
A leading zero detector is used to count the number of leading zeros in a binary word and provide a shift control word to a shifter for aligning data in the binary word. The shift control word represents the number of single bit shifts that are required to remove any leading zeros in the binary word and to align the leading “1” in the binary word to the left-most significant bit position.
In one embodiment of the present invention, the leading zero counter has a substantially constant propagation delay regardless of the number of input bits and provides a decoded version of the leading zero count. This decoded leading zero count can be directly applied to the shifter without any further decoding or intermediate circuitry. Such a leading zero detector can be used for aligning data in a data networking application or for normalizing data in floating point arithmetic, for example. Other applications also exist.
One embodiment of the leading zero detector will be described with the following example. In this example, the leading zero detector receives an 8-bit binary word, counts the number of leading zeros in the word and outputs an 8-bit shift control word, which represents the number of single-bit shifts required to align or normalize the data. The binary word and the shift control word can have any number of bits in alternative embodiments of the present invention and can have a variety of data formats.
Assume that the binary word to be aligned or normalized has following value:
In the above binary word, the right-most bit position is the least significant bit position, and the left-most bit position is the most significant bit position. This binary word has three leading zeros. For a data normalization procedure, the remaining bits should be shifted to the left by three bits to produce the following aligned binary word:
In order to count the number of leading zeros in the original binary word input, each bit of the binary word is assigned with an coded address. One embodiment of the present invention uses a thermometer code format. In this embodiment, the thermometer code format represents the significance of the corresponding bit position. For example, the number of logic “1” symbols in the coded address represents the significance of the bit position, where a coded address having a single “1” represents the least-significant bit position and a coded address having eight “1's” represents the most-significant bit position.
Each thermometer-coded address 16 is then modified as a function of a logic state of the respective bit of the binary word 10 to produce respective modified addresses. For example if the corresponding bit in binary word 10 is “1”, the respective thermometer-coded address 16 is preserved unchanged in the modified address. Otherwise if the corresponding bit is “0”, the respective modified address is reset to all zeros.
The modification of the coded addresses can be accomplished by a variety of logic circuits or by software. For example,
Once the modified addresses 30 are generated, a shift control word 60 is generated based on the bit positions at which the modified addresses have a predetermined logic state (such as a logic “1” state). Shift control word 60 has one bit for each bit position of modified addresses 30. Each bit of the shift control word is generated by detecting whether there is a logic “1” state in any of the corresponding bit positions that have the same significance in modified addresses 30. Looking at
If the shift control word “11100000” is inverted, it becomes “000111111”, which corresponds to column address five. This reflects that the most significant “1” in binary word 10 appears at the fifth bit (bit position four when counting from zero). Also, if the order of the bits in shift control word 60 are reversed from “11100000” to “00000111”, this produces a thermometer-coded value that represents the number (three) of single-bit left shifts required to normalize this particular binary word 10. Thus, a shift circuit can receive shift control word 60 directly and use the shift control word for controlling the operation of internal shift multiplexers without any intermediate decoding. This further reduces the overall delay of the data alignment for a normalization process.
If any of the address bits for the respective row is a logic “1”, then the corresponding transistor will pull common node N1 low toward ground terminal GND, thereby producing a logic “0” for the corresponding shift control word bit. If none of the address bits for that row is a logic “1”, then common node N1 remains in the logic high state such that BIT 0 of the bit control word is a logic “1”.
In the example shown in
The wire-NOR circuit 100 shown in
In this example, the binary word 10 has four bits labeled d3, d2, d1 and d0, with bit d3 being the most significant and bit d0 being the least significant. Bits d3-d0 are provided as inputs to leading zero counter 201 and shifter 220. Leading zero counter 201 includes and array of multiplexers 50 and a plurality of logic NOR circuits 100.
Block 202 represents the bits of binary word 10 being applied to the select inputs of respective multiplexers 50. Block 203 represents a predetermined thermometer-coded address “0001” that is assigned to bit zero of binary word 10. Each bit of address 203 is coupled to one of the data inputs of a respective multiplexer 50. Similarly, block 204 represents a predetermined thermometer-coded address “0011” that is assigned to bit one of binary word 10. Block 205 represents a predetermined thermometer-coded address “0111” that is assigned to bit two of binary word 10. Block 206 represents a predetermined thermometer-coded address “1111” that is assigned to bit three of binary word 10. Again, each bit of addresses 204-206 is coupled to one of the data inputs of a respective multiplexer 50. As described above with respect to
Each column of multiplexers 50 in
The output of each logic NOR circuit 100 at the respective node N1 generates a corresponding bit of shift control word 60. Leading zero counter 201 therefore generates a thermometer-coded shift control word, which is simply a decoded binary number. Block 210 represents the shift control word that is generated by leading zero counter 201. Shift control word 210 has four bits labeled SHIFT0 to SHIFT3, with SHIFT0 being the least significant and SHIFT3 being the most significant. Shift circuit 220 can use the shift control word directly to control the number of bits for the shift operation without any further decoding.
Shift circuit 220 can include any type of shifter, such as a barrel shifter. Shift circuit 220 includes a data input 222 and a plurality of shift control inputs SH0 to SH3. Data input 222 is coupled to binary word 10. Shift control inputs SH0 to SH3 are coupled directly to respective bits of the shift control word in an order of reverse significance. Although the bits of the shift control word are reversed, it is only a matter of connection to the appropriate shift control inputs of shift circuit 220. No additional decoding circuit is required. In one embodiment, shift circuit 220 includes internal shift multiplexers having select inputs that are directly controlled by the bits of the shift control word.
The normalization circuit shown in
Although the present invention has been described with reference to preferred embodiments, workers skilled in the art will recognize that changes may be made in form and detail without departing from the spirit and scope of the invention. For example, the various function blocks of the present invention can be implemented in hardware, software or a combination of both hardware and software. Also, a variety of circuit configurations can be used in replace of the circuit configurations shown in the figures. The term “coupled” can include a direct connection or a connection through one or more intermediate components. Further, it is to be understood that particular logic states are interchangeable, and any circuitry can be inverted or otherwise modified to implement a particular convention or technology.