Abstract:
Division can be performed in a programmable integrated circuit device by computing a relatively small number of bits of the inverse of the divisor, and then programming multipliers in a specialized processing block of the device to perform multiplication of the dividend and the inverted divisor. The specialized processing block is constructed to be able to be programmed to support such asymmetric multiplication by providing programmable shifting of partial products, so that the partial products can be shifted one number of bits for symmetric multiplication and a different number of bits for asymmetric multiplication. The process is performed recursively, by chaining a plurality of the specialized processing blocks, so that the result converges notwithstanding the relatively low precision of the inverted divisor.

Description:
BACKGROUND OF THE INVENTION 
     This invention relates to implementing division in programmable integrated circuit devices such as, e.g., programmable logic devices (PLDs). 
     As applications for which PLDs are used increase in complexity, it has become more common to design PLDs to include specialized processing blocks in addition to blocks of generic programmable logic resources. Such specialized processing blocks may include a concentration of circuitry on a PLD that has been partly or fully hardwired to perform one or more specific tasks, such as a logical or a mathematical operation. A specialized processing block may also contain one or more specialized structures, such as an array of configurable memory elements. Examples of structures that are commonly implemented in such specialized processing blocks include: multipliers, arithmetic logic units (ALUs), barrel-shifters, various memory elements (such as FIFO/LIFO/SIPO/RAM/ROM/CAM blocks and register files), AND/NAND/OR/NOR arrays, etc., or combinations thereof. 
     One particularly useful type of specialized processing block that has been provided on PLDs is a digital signal processing (DSP) block, which may be used to process, e.g., audio signals. Such blocks are frequently also referred to as multiply-accumulate (“MAC”) blocks, because they include structures to perform multiplication operations, and sums and/or accumulations of multiplication operations. 
     For example, PLDs sold by Altera Corporation, of San Jose, Calif., as part of the STRATIX® family, include DSP blocks, each of which may include four 18-by-18 multipliers. Each of those DSP blocks also may include adders and registers, as well as programmable connectors (e.g., multiplexers) that allow the various components to be configured in different ways. In each such block, the multipliers can be configured not only as four individual 18-by-18 multipliers, but also as four smaller multipliers, or as one larger (36-by-36) multiplier. In addition, one 18-by-18 complex multiplication (which decomposes into two 18-by-18 multiplication operations for each of the real and imaginary parts) can be performed. 
     Larger multiplications can be performed by using more of the 18-by-18 multipliers—e.g., from other DSP blocks. For example, a 54-by-54 multiplier can be decomposed, by linear decomposition, into a 36-by-36 multiplier (which uses the four 18-by-18 multipliers of one DSP block), two 36-by-18 multipliers (each of which uses two 18-by-18 multipliers, for a total of four additional 18-by-18 multipliers, consuming another DSP block), and one 18-by-18 multiplier, consuming a portion of a third DSP block. Thus, using 18-by-18 multipliers, nine multipliers are required to perform a 54-by-54 multiplication. 
     One type of mathematical function that heretofore has not been easily implemented in a PLD or other programmable device is division. Division, especially double-precision floating point division, which may be required for High Performance Computing, is expensive and slow on current FPGAs. A common implementation in general-purpose programmable logic of an FPGA uses a network of 64 80-bit adders, typically requiring between 6,000 and 9,000 four-input look-up tables. Moreover, the resulting operation is slow, typically having a 150 MHz system speed and about 57 clock cycles of latency. 
     SUMMARY OF THE INVENTION 
     The present invention implements multiplier-based division in a programmable device. For example, convergence-type multiplier-based approaches offer the possibility of higher system speeds (on the order of about 300 MHz), lower latency (on the order of 10-20 clock cycles), and lower logic utilization (as most of the calculations are done in multipliers rather than in general-purpose programmable logic). 
     As described above, the DSP blocks provided on PLDs from Altera Corporation support, inter alia, a 36-bit-by-36-bit multiplier mode. In accordance with the present invention, such a DSP block may be modified to support also a 72-bit-by-18-bit multiplier mode. The resulting asymmetric multiplier can then be used to implement a recursive algorithm to perform division operations, as described in more detail below. 
     Therefore, in accordance with the present invention, there is provided a method of configuring a programmable integrated circuit device to use multipliers to perform a division operation that provides a quotient of a dividend input value and a divisor input value, where the quotient has a first precision. The method includes configuring logic of the programmable integrated circuit device to use at least a first of the multipliers to operate on said divisor input value to provide an inverted divisor approximation having a second precision less precise than the first precision; configuring logic of the programmable integrated circuit device to recursively compute a remainder by initializing the remainder to said dividend input value at the first precision and then, in each recursive stage, subtracting from the remainder a product of (a) the remainder represented at the second precision, (b) the divisor input value represented at the first precision, and (c) the inverted divisor approximation. Logic of the programmable integrated circuit device is configured to compute a respective component of the quotient in each of the recursive stages, by computing a product of (1) the remainder represented at the second precision, and (2) the inverted divisor approximation. Logic of the programmable integrated circuit device is further configured to add the respective components of the quotient to provide the quotient. 
     A programmable logic device so configurable or configured, and a machine-readable data storage medium encoded with software for performing the method, are also provided. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       Further features of the invention, its nature and various advantages, will be apparent upon consideration of the following detailed description, taken in conjunction with the accompanying drawings, in which like reference characters refer to like parts throughout, and in which: 
         FIG. 1  is a schematic representation of a previously-known specialized processing block in a programmable integrated circuit device; 
         FIG. 2  is a diagram showing the decomposition of a 36-bit-by-36-bit multiplication to be performed in a specialized processing block such as that of  FIG. 1 ; 
         FIG. 3  is a diagram of the logic flow, and a circuit configuration with which a specialized processing block such as that of  FIG. 1  may be programmed, for performing the multiplication of  FIG. 2 ; 
         FIG. 4  is a diagram showing the decomposition of a 72-bit-by-18-bit multiplication to be performed in a specialized processing block in accordance with an embodiment of the present invention, for implementing division; 
         FIG. 5  is a diagram of the logic flow, and a circuit configuration with which a specialized processing block may be programmed, for performing the multiplication of  FIG. 4  to implement division in accordance with an embodiment of the present invention; 
         FIG. 6  is a diagram of the logic flow, and a circuit configuration with which a specialized processing block may be programmed, for implementing division in accordance with an embodiment of the present invention; 
         FIG. 7  is a diagram of a logical equivalent of the configuration of  FIG. 6 ; 
         FIG. 8  is a schematic representation of a divider structure in accordance with an embodiment of the present invention; 
         FIG. 9  is a cross-sectional view of a magnetic data storage medium encoded with a set of machine executable instructions for performing the method according to the present invention; 
         FIG. 10  is a cross-sectional view of an optically readable data storage medium encoded with a set of machine executable instructions for performing the method according to the present invention; and 
         FIG. 11  is a simplified block diagram of an illustrative system employing a programmable logic device incorporating the present invention. 
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The following division problem: 
             Q   =     X   Y           
can be broken down into the following recursive problem:
 
                     Q     i   +   1       =       Q   i     +       Rh   i     ⁢     1   Yh                       R     i   +   1       =       R   i     -       Rh   i     ⁢     1   Yh     ⁢   Y                   
where:
     Q i =the partial quotient in the ith iteration, initialized to 0 in the 0th iteration,   R i =the partial remainder in the ith iteration, initialized to X in the 0th iteration,   Rh i =some number, h, of significant bits of R i , and   Yh=some number, h, of significant bits of the divisor Y.   

     As can be seen, in the first (0th) iteration, the partial quotient becomes the product of h bits of X and the inverse of h bits of Y, which will be close as a zeroth-order approximation of the result. At the same time, the remainder becomes the difference between (a) X and (b) the product of (i) h bits of X and (ii) the product of (1) Y and (2) the inverse of h bits of Y, which is the difference between (a) X and (b) the product of (i) h bits of X and (ii) a number close to 1, which is the difference between (a) X and (b) a number close to h bits of X, which is close to zero. In other words, as expected, in the 0th iteration, the result is that Q 0  is the product of h bits of X and the inverse of h bits of Y which is close to the result, and R 0  is close to zero. The result will converge in subsequent iterations, getting closer to the actual result where Q i  is essentially equal to the result and R i  is essentially equal to zero. 
     The number of iterations required for convergence depends on how close to the actual result one wants to be, and on the value chosen for h. The value chosen for h cannot be so large that the inverse of Yh cannot be computed easily. In the 72-bit-by-18-bit embodiment described herein, an 18-bit inverse can be calculated relatively easily using, e.g., a Taylor series expansion. The Taylor series expansion can be performed using one 18-bit-by-18-bit multiplier, along with two lookup tables (which may be provided as read-only memories, or programmed into programmable logic in the case of a programmable device), as well as some additional logic such as adders. 
     In such an embodiment, the R i  partial remainder multiplications can then be 18-bits by the internal precision of the calculation, which may be 64 bits for double-precision arithmetic or 72 bits for extended double-precision arithmetic, which exceed the required mantissa sizes—52 bits and 64 bits respectively—in both cases, so that any errors accumulate to be less than the least-significant-bit position required in the final answer. The Q i  partial quotient multiplications—Rh(1/Yh)—would be 18-bits-by-18-bits in either case. The result can be deemed to have converged when R i  falls below a predetermined value. In a programmable device, that predetermined value may be user-programmable. 
       FIG. 1  schematically shows a previously-known DSP block  10  of the type described above, available in devices from Altera Corporation. DSP block  10  may have four 18-bit-by-18-bit multipliers  11 , whose outputs may be combined by N:2 compressor  12  to provide two partial sums and a carry vector, which are further combined in carry-lookahead adder  13 . The total number of signals typically include 144 input data signals  14 , and 72-80 output data signals  15 . 
       FIG. 2  shows how such a structure may be used to perform a 36-bit-by-36-bit multiplication. The two 36-bit numbers  20 ,  21  are decomposed into two 18-bit numbers each—A|B and C|D. The four multipliers form four 18-bit-by-18-bit products DB, DA, CB and AC. The products DA and CB are left-shifted by 18 bits, and the product AC is left-shifted by 36 bits. 
       FIG. 3  shows the connections in block  10  for performing those multiplications. There are four 18-bit-by-18-bit multipliers  30 . As each has 36 (i.e., 18+18) inputs, 36×4=144 inputs  31  are available. However, only 72 unique inputs are required. The 72 inputs can be provided only once, with each input to be used more than once being de-multiplexed to the respective multipliers  30  inside DSP block  10 , or inputs can be provided multiple times, once each for every component to use the input, so that up to all 144 inputs are used. The partial products may be left-shifted at  320 ,  321 ,  322  using, e.g., a combination of multiplexers and wires (conductive traces). After all partial products have thus been properly aligned, they are compressed using the N:2 compressor  33  into a partial product vector and a carry vector, after which they are added in carry-lookahead adder  34  to make the 72-bit output  35 . 
     A 72-bit-by-18-bit multiplication can use the same number of partial products as a 36-bit-by-36-bit multiplication, except that there are five unique 18-bit numbers.  FIG. 4  shows the offsets and combining patterns for the partial products of an 72-bit-by-18-bit multiplication, while  FIG. 5  shows how block  10  of  FIG. 3  may be modified to provide block  50  capable of performing a 72-bit-by-18-bit multiplication. 
     As can be seen in block  50 , 18-bit left-shifter  322  is replaced with 36-bit left-shifter  522 . Preferably, left-shifter  522  is selectable (e.g., using a multiplexer) to shift by either 18 or 36 bits, so that the user can use block  50  in the manner of block  10  if desired. 
     Of the 144 input conductors  31 , between 82 (in the case of a 64-bit-by-18-bit calculation for double-precision arithmetic) and 90 (in the case of a 72-bit-by-18-bit calculation for extended double-precision arithmetic) are used for inputs, while correspondingly 72 or 80 bits are used as outputs. The 72-bit-by-18-bit multiplication operation actually produces a 90-bit output, which cannot be handled by the routing structure in this embodiment, but as the input of each iteration can handle 72 bits, and as the overall division operation is only an iterative approximation, only the 72 most significant bits need be routed out. The precision lost by discarding the 18 least significant bits will not have much impact. Optionally, adder  34  can include a rounding mode to compensate for the discarding of the least significant bits. For example, rounding can occur at the 52nd bit for double precision calculations or at the 64th bit for extended double precision calculations. 
     In the calculation above for the partial remainder R i+1 , multiplicative term Rh i  is a subset or truncation of the additive term R i . Therefore, those h bits (e.g., 18 bits) need not be input twice, but rather simply routed twice within block  50 . With 144 inputs, the partial remainder recurrence equation can be supported by the block  50 . It is already known to provide additional input terms for compressor  33 , which may be used, e.g., for accumulation, chaining or redundancy. In order to include the h bits of Rh i  in the multiplication operation, all that would be needed is some additional multiplexing. 
     As a reminder, each term of the partial remainder recurrence subtracts (which is a form of addition) a product of Rh i  (which is 18 bits wide) and Y(1/Yh) which itself is a 72-bit product. The structure of a DSP block  60  for performing this calculation is shown in  FIG. 6 . The logical equivalent is shown in  FIG. 7 . There are 144 inputs  61  representing 72 bits  62  of R i  and 72 bits  63  of Y(1/Yh). The latter are combined with the 18 bits  64  of Rh i  which are a subset of bits  62  to provide 90 bits  65 . As discussed above, output  66  may be 90 bits wide, but is truncated to its 72 most significant bits, or optionally rounded to 52 or 64 bits, for use by the next iteration. 
     Chaining a number of these blocks allows calculation of a division operation. With an 18-bit “guess” for 1/Yh, each iteration should give about 15 “good” bits—i.e., bits that can be counted on to be correct. As discussed above, any errors can be expected to accumulate at bit positions less significant than the fifteenth bit of each iteration. Therefore, for double precision, which requires 52 bits, four iterations (60 “good” bits) should be sufficient, while for extended double precision, which requires 64 bits, five iterations (75 “good” bits) should be sufficient. 
     As shown below in  FIG. 8 , each iteration requires five 18-bit-by-18-bit multipliers—the four multipliers of a DSP block for the remainder calculation, and one additional multiplier for the quotient calculation (which, as a reminder, is simply Rh i (1/Yh) added to the previous quotient), or five multipliers. Therefore, the four iterations of a double-precision division operation will require twenty multipliers, plus five more to prepare the “constants” 1/Yh (which requires one 18-bit-by-18-bit multiplier as discussed above) and Y(1/Yh) (which requires four 18-bit-by-18-bit multipliers to perform the necessary 72-bit-by-18-bit multiplication), for a total of twenty-five multipliers. By comparison, for example, a double-precision multiplication operation requires eight or nine 18-bit-by-18-bit multipliers. While division according to the present invention thus requires more multipliers than multiplication, it nevertheless requires fewer resources than the 64 adders previously used, as discussed above. 
     An embodiment of a divider structure  80  in accordance with the invention is shown in  FIG. 8 . Although, as discussed above, a minimum of four iterations ordinarily would be provided, to simplify the drawing only three iterations are included in divider structure  80 . Y, the divisor, is input at  81 , while X, the dividend, is input at  82 . 
     A first DSP block  801  is used to provide an 18-bit approximation 1/Yh of the inverse of Y, using one 18-bit-by-18-bit multiplier plus additional logic as described above. This value  802  is multiplied by Y in DSP block  803  (configured as a 72-bit-by-18-bit multiplier to perform 64-bit-by-18-bit multiplication in a double-precision embodiment or 72-bit-by-18-bit multiplication in an extended double-precision embodiment) and the result  804 , which approximates, but does not quite equal, one, is provided to each of DSP blocks  805 ,  806 ,  807  which perform respective stages of the remainder calculation. At each stage, 72 bits of the previous remainder  814  are multiplied by value  804 , and that product is subtracted from the same previous remainder  814  by carry-lookahead adder  808 . The subtraction can be facilitated either by negating inputs to some of the 18-bit multipliers or it can be done in compressor  11  (not shown in  FIG. 8 ). 
     For each stage of the quotient, value  802  (1/Yh) is multiplied at respective multiplier  809  by previous remainder  814  as input to that stage. All of these stages are then added together. The addition is represented symbolically at  819 . However, while one big adder  819  could be provided, the addition alternatively could be carried out in steps, using, e.g., a chaining mode available in DSP blocks of the Altera Corporation products described above. In addition, because each stage provides about fifteen “good” bits of the final quotient, the result of each subsequent stage (except the first) preferably is right-shifted by about fifteen additional bits. Insofar as shifters are essentially simply wires, the shifters are not explicitly shown in  FIG. 8 . However, the shifting occurs after each multiplier  809  and before adder  819 . 
     Thus, the method of the invention configures a programmable integrated circuit device, such as a PLD, to create the structures shown in  FIGS. 6 and 8  to perform division operations using multipliers on the device, at a savings as compared to using adders as has been done previously. 
     Instructions for carrying out the method according to this invention may be encoded on a machine-readable medium, to be executed by a suitable computer or similar device to implement the method of the invention for programming or configuring programmable integrated circuit devices to perform operations as described above. For example, a personal computer may be equipped with an interface to which a programmable integrated circuit device can be connected, and the personal computer can be used by a user to program the programmable integrated circuit device using a suitable software tool, such as the QUARTUS® II software available from Altera Corporation, of San Jose, Calif. 
       FIG. 9  presents a cross section of a magnetic data storage medium  600  which can be encoded with a machine executable program that can be carried out by systems such as the aforementioned personal computer, or other computer or similar device. Medium  600  can be a floppy diskette or hard disk, or magnetic tape, having a suitable substrate  601 , which may be conventional, and a suitable coating  602 , which may be conventional, on one or both sides, containing magnetic domains (not visible) whose polarity or orientation can be altered magnetically. Except in the case where it is magnetic tape, medium  600  may also have an opening (not shown) for receiving the spindle of a disk drive or other data storage device. 
     The magnetic domains of coating  602  of medium  600  are polarized or oriented so as to encode, in manner which may be conventional, a machine-executable program, for execution by a programming system such as a personal computer or other computer or similar system, having a socket or peripheral attachment into which the PLD to be programmed may be inserted, to configure appropriate portions of the PLD, including its specialized processing blocks, if any, in accordance with the invention. 
       FIG. 10  shows a cross section of an optically-readable data storage medium  700  which also can be encoded with such a machine-executable program, which can be carried out by systems such as the aforementioned personal computer, or other computer or similar device. Medium  700  can be a conventional compact disk read only memory (CD-ROM) or digital video disk read only memory (DVD-ROM) or a rewriteable medium such as a CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, DVD+RW, or DVD-RAM or a magneto-optical disk which is optically readable and magneto-optically rewriteable. Medium  700  preferably has a suitable substrate  701 , which may be conventional, and a suitable coating  702 , which may be conventional, usually on one or both sides of substrate  701 . 
     In the case of a CD-based or DVD-based medium, as is well known, coating  702  is reflective and is impressed with a plurality of pits  703 , arranged on one or more layers, to encode the machine-executable program. The arrangement of pits is read by reflecting laser light off the surface of coating  702 . A protective coating  704 , which preferably is substantially transparent, is provided on top of coating  702 . 
     In the case of magneto-optical disk, as is well known, coating  702  has no pits  703 , but has a plurality of magnetic domains whose polarity or orientation can be changed magnetically when heated above a certain temperature, as by a laser (not shown). The orientation of the domains can be read by measuring the polarization of laser light reflected from coating  702 . The arrangement of the domains encodes the program as described above. 
     Thus it is seen that a method for efficiently carrying out division in a programmable integrated circuit device, a programmable integrated circuit device programmed to perform the method, and software for carrying out the programming, have been provided. 
     A PLD  90  programmed according to the present invention may be used in many kinds of electronic devices. One possible use is in a data processing system  900  shown in  FIG. 11 . Data processing system  900  may include one or more of the following components: a processor  901 ; memory  902 ; I/O circuitry  903 ; and peripheral devices  904 . These components are coupled together by a system bus  905  and are populated on a circuit board  906  which is contained in an end-user system  907 . 
     System  900  can be used in a wide variety of applications, such as computer networking, data networking, instrumentation, video processing, digital signal processing, or any other application where the advantage of using programmable or reprogrammable logic is desirable. PLD  90  can be used to perform a variety of different logic functions. For example, PLD  90  can be configured as a processor or controller that works in cooperation with processor  901 . PLD  90  may also be used as an arbiter for arbitrating access to a shared resources in system  900 . In yet another example, PLD  90  can be configured as an interface between processor  901  and one of the other components in system  900 . It should be noted that system  900  is only exemplary, and that the true scope and spirit of the invention should be indicated by the following claims. 
     Various technologies can be used to implement PLDs  90  as described above and incorporating this invention. 
     It will be understood that the foregoing is only illustrative of the principles of the invention, and that various modifications can be made by those skilled in the art without departing from the scope and spirit of the invention. For example, the various elements of this invention can be provided on a programmable integrated circuit device in any desired number and/or arrangement. One skilled in the art will appreciate that the present invention can be practiced by other than the described embodiments, which are presented for purposes of illustration and not of limitation, and the present invention is limited only by the claims that follow.