LSU_pvt.ih File Reference
Linear Scaling Utilities, private inline include file.
More...
#include <PBS/FFS.ih>
|
Functions |
static __inline unsigned | lsu__mulhwu (unsigned int mult, unsigned int x) |
| Computes and returns the most significant 32-bits of a 32 x 32-bit unsigned integer multiple.
|
static __inline unsigned int | lsu__scale (unsigned int mult, int shift, unsigned int dx) |
| Helper function to convert x to a scaled value.
|
Detailed Description
Linear Scaling Utilities, private inline include file.
- Author:
- JJRussell - russell@slac.stanford.edu
CVS $Id: LSU_pvt.ih,v 1.2 2011/03/24 23:05:46 apw Exp $
Function Documentation
static __inline unsigned int lsu__mulhwu |
( |
unsigned int |
mult, |
|
|
unsigned int |
x | |
|
) |
| | [static] |
Computes and returns the most significant 32-bits of a 32 x 32-bit unsigned integer multiple.
- Returns:
- The most significant 32-bits of a 32 x 32-bit unsigned integer multiple.
- This routine returns only the most significant 32-bits of a 32 x 32-bit multiple. On the PPC, this can be accomplished by using the mulhwu instruction. On other platforms, the straight-forward 32 x 32-bit multiple is done, and the correct bits are extracted
Referenced by lsu__scale().
static __inline unsigned int lsu__scale |
( |
unsigned int |
mult, |
|
|
int |
shift, |
|
|
unsigned int |
x | |
|
) |
| | [static] |
Helper function to convert x to a scaled value.
Performs a multiple and shift on X, keeping only the most significant 32-bits of the 64 bit operation.
- Parameters:
-
| mult | The multiplying scale factor |
| shift | The amount needed to left shift the result such that the upper 32 bits of the 64-bit result of the multiple contains the answer. |
| x | The number to scale. |
- This routine acts as a pseudo-floating point multiple and divide. The divide is always by a power of 2, so it reduces to a shift. The trick in the multiple is to prescale the numbers such that the significant bits land in the upper 32 bits of a 64 bit number.
- It is possible that the scaling results in a number larger than a 32 bit number can contain. In this case, the routine returns the largest 32 bit number possible, 0xffffffff. In most cases the answer is correct to the least significant bit. However, if the result is larger than 2**31, the guard digit normally used to round the LSB is sacrificed, so the LSB is in doubt. This seems a reasonable compromise.
- The normal follow of the code should result in about 6 instructions. Because one only needs the upper 32 bits of a 32 x 32 bit multiple, on the PowerPC which has an instruction to compute the hi word of such a multiple, only those bits are computed.
- Returns:
- The scaled value
- Parameters:
-
| mult | The multiplying scale factor |
| shift | The shift scale factor |
| x | The value to scale |
- This routine can be used after the multiply and shift factors have been extracted from the LSU function. In many cases, these factors are being update asynchronously, so the extraction must be done in an interlocked fashion. In other cases, no such restrictions apply, and this more bare-bones routine is all that is necessary
References lsu__mulhwu().