|
|
|
SoftPosit is based on Berkeley SoftFloat Release 3d to enable software comparison between posits and floats.
|
|
|
|
|
|
|
|
**Installation**
|
|
|
|
|
|
|
|
cd SoftPosit/build/Linux-x86_64-GCC
|
|
|
|
|
|
|
|
make all
|
|
|
|
|
|
|
|
|
|
|
|
Please link to the archive (softposit.a) to use.
|
|
|
|
|
|
|
|
**Tested on**
|
|
|
|
|
|
|
|
Release v0.1 supports 16-bit posit with one exponent bit (posit16_t). This code is tested on
|
|
|
|
* GNU gcc (SUSE Linux) 4.8.5
|
|
|
|
* Apple LLVM version 9.1.0 (clang-902.0.39.2)
|
|
|
|
|
|
|
|
An example on how to use the code to add:
|
|
|
|
|
|
|
|
`union ui16_p16 uA, uB, uZ;`
|
|
|
|
|
|
|
|
`uA.ui = 0x42;`
|
|
|
|
|
|
|
|
`uB.ui = 0x23;`
|
|
|
|
|
|
|
|
`uZ.p = p16_add(uA.p, uB.p);`
|
|
|
|
|
|
|
|
`//To check answer`
|
|
|
|
|
|
|
|
`double dZ = convertP16ToDec_f(uZ.p);`
|
|
|
|
|
|
|
|
`//To print result in binary`
|
|
|
|
|
|
|
|
`printBinary(&uZ.ui, 16);`
|
|
|
|
|
|
|
|
|
|
|
|
**Features**
|
|
|
|
|
|
|
|
Main Posit Functionalities:
|
|
|
|
1. Add
|
|
|
|
`posit16_t p16_add(posit16_t, posit_16)`
|
|
|
|
|
|
|
|
2. Subtract
|
|
|
|
`posit16_t p16_sub(posit16_t, posit_16)`
|
|
|
|
|
|
|
|
3. Divide
|
|
|
|
`posit16_t p16_div(posit16_t, posit_16)`
|
|
|
|
|
|
|
|
4. Multiply
|
|
|
|
`posit16_t p16_mul(posit16_t, posit_16)`
|
|
|
|
|
|
|
|
5. Fused Multiply Add
|
|
|
|
`posit16_t p16_mulAdd(posit16_t, posit_16, posit_16)`
|
|
|
|
|
|
|
|
`p16_mulAdd(a, b, c) <=> a*b + c`
|
|
|
|
|
|
|
|
Main Quire Functionalities
|
|
|
|
|
|
|
|
1. Fused dot product-add
|
|
|
|
`quire16_t q16_fdp_add(quire16_t, posit_16, posit_16)`
|
|
|
|
|
|
|
|
1. Fused dot product-subtract
|
|
|
|
`quire16_t q16_fdp_sub(quire16_t, posit_16, posit_16)`
|
|
|
|
|
|
|
|
1. Set quire variable to zero
|
|
|
|
`quire16_t q16_clr(quire16_t)`
|
|
|
|
|
|
|
|
1. Convert quire to posit
|
|
|
|
`posit_16 convertQ16ToP16(quire16_t)`
|
|
|
|
|
|
|
|
Additional Posit Functionalites
|
|
|
|
|
|
|
|
1. Square root
|
|
|
|
`posit16_t p16_sqrt(posit16_t)`
|
|
|
|
|
|
|
|
1. Round to nearest integer
|
|
|
|
`posit16_t p16_roundToInt(posit16_t)`
|
|
|
|
|
|
|
|
1. Check equal
|
|
|
|
`bool p16_eq( posit16_t, posit16_t )`
|
|
|
|
|
|
|
|
1. Check less than equal
|
|
|
|
`bool p16_le( posit16_t, posit16_t )`
|
|
|
|
|
|
|
|
1. Check less than
|
|
|
|
`bool p16_lt( posit16_t, posit16_t )`
|
|
|
|
|
|
|
|
1. Convert p16 to integer (32 bits)
|
|
|
|
`int_fast32_t p16_to_i32( posit16_t )`
|
|
|
|
|
|
|
|
1. Convert p16 to long integer (64 bits)
|
|
|
|
`int_fast64_t p16_to_i64( posit16_t)`
|
|
|
|
|
|
|
|
1. Convert p16 to unsigned integer (32 bits)
|
|
|
|
`uint_fast32_t p16_to_ui32( posit16_t )`
|
|
|
|
|
|
|
|
1. Convert p16 to unsigned long integer (64 bits)
|
|
|
|
`uint_fast64_t p16_to_ui64( posit16_t)`
|
|
|
|
|
|
|
|
1. Convert p16 to p32 (posit<32, 2>)
|
|
|
|
`posit32_t p16_to_p32( posit16_t )`
|
|
|
|
|
|
|
|
1. Convert p16 to double (64 bits)
|
|
|
|
`double convertP16ToDec_f(posit16_t)`
|
|
|
|
|
|
|
|
1. Convert double (64 bits) to posit
|
|
|
|
`posit16_t convertdoubleToP16(double)` |
|
|
|
\ No newline at end of file |