X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=sfpy%2Fcposit.pxd;h=ad205d3f8d078c1c20b446e8f5d140a8c2c81b59;hb=613fd66860992ec270d1515a4cd92b4468bc6280;hp=c7c4c3e5cdd59e615f0d47887d1bb747a59bc959;hpb=a36c656f8c9d760693fc98a5450878bb5365f411;p=sfpy.git diff --git a/sfpy/cposit.pxd b/sfpy/cposit.pxd index c7c4c3e..ad205d3 100644 --- a/sfpy/cposit.pxd +++ b/sfpy/cposit.pxd @@ -1,30 +1,60 @@ from libc.stdint cimport * +# As far as I can tell, this is never enabled when the library is comiled... +# The option will have to be synced manually, as by the time Cython's c is +# compiled the library will already be stored as a .a file and any compile-time +# options used to build it will be long gone. +DEF SOFTPOSIT_EXACT = 0 + cdef extern from '../SoftPosit/source/include/softposit.h': - ctypedef struct posit8_t: - pass + # Transparent types so we can have access to the raw bits. + + IF SOFTPOSIT_EXACT: + + ctypedef struct posit8_t: + uint8_t v; + bint exact; + + ctypedef struct quire8_t: + uint32_t v; + bint exact; + + ctypedef struct posit16_t: + uint16_t v; + bint exact; - ctypedef struct posit16_t: - pass + ctypedef struct quire16_t: + uint64_t v[2]; + bint exact; - ctypedef struct posit32_t: - pass + ctypedef struct posit32_t: + uint32_t v; + bint exact; - ctypedef struct posit64_t: - pass + ctypedef struct quire32_t: + uint64_t v[8]; + bint exact; - ctypedef struct posit128_t: - pass + ELSE: - ctypedef struct quire8_t: - pass + ctypedef struct posit8_t: + uint8_t v; - ctypedef struct quire16_t: - pass + ctypedef struct posit16_t: + uint16_t v; - ctypedef struct quire32_t: - pass + ctypedef struct posit32_t: + uint32_t v; + + ctypedef struct quire8_t: + uint32_t v; + + ctypedef struct quire16_t: + uint64_t v[2]; + + ctypedef struct quire32_t: + uint64_t v[8]; # /*---------------------------------------------------------------------------- # | Integer-to-posit conversion routines. @@ -32,23 +62,23 @@ cdef extern from '../SoftPosit/source/include/softposit.h': posit8_t ui32_to_p8( uint32_t ); posit16_t ui32_to_p16( uint32_t ); - posit32_t ui32_to_p32( uint32_t ); - posit64_t ui32_to_p64( uint32_t ); + # posit32_t ui32_to_p32( uint32_t ); + # posit64_t ui32_to_p64( uint32_t ); posit8_t ui64_to_p8( uint64_t ); posit16_t ui64_to_p16( uint64_t ); - posit32_t ui64_to_p32( uint64_t ); - posit64_t ui64_to_p64( uint64_t ); + # posit32_t ui64_to_p32( uint64_t ); + # posit64_t ui64_to_p64( uint64_t ); posit8_t i32_to_p8( int32_t ); posit16_t i32_to_p16( int32_t ); - posit32_t i32_to_p32( int32_t ); - posit64_t i32_to_p64( int32_t ); + # posit32_t i32_to_p32( int32_t ); + # posit64_t i32_to_p64( int32_t ); posit8_t i64_to_p8( int64_t ); posit16_t i64_to_p16( int64_t ); - posit32_t i64_to_p32( int64_t ); - posit64_t i64_to_p64( int64_t ); + # posit32_t i64_to_p32( int64_t ); + # posit64_t i64_to_p64( int64_t ); # /*---------------------------------------------------------------------------- # | 8-bit (quad-precision) posit operations. @@ -62,8 +92,8 @@ cdef extern from '../SoftPosit/source/include/softposit.h': int_fast64_t p8_to_i64( posit8_t ); posit16_t p8_to_p16( posit8_t ); - #posit32_t p8_to_p32( posit8_t ); - #posit64_t p8_to_p64( posit8_t ); + # posit32_t p8_to_p32( posit8_t ); + # posit64_t p8_to_p64( posit8_t ); posit8_t p8_roundToInt( posit8_t ); posit8_t p8_add( posit8_t, posit8_t ); @@ -98,14 +128,14 @@ cdef extern from '../SoftPosit/source/include/softposit.h': # *----------------------------------------------------------------------------*/ bint isNaRP16UI( uint16_t ); - + uint_fast32_t p16_to_ui32( posit16_t ); uint_fast64_t p16_to_ui64( posit16_t ); int_fast32_t p16_to_i32( posit16_t); int_fast64_t p16_to_i64( posit16_t ); posit8_t p16_to_p8( posit16_t ); - #posit32_t p16_to_p32( posit16_t ); - #posit64_t p16_to_p64( posit16_t ); + # posit32_t p16_to_p32( posit16_t ); + # posit64_t p16_to_p64( posit16_t ); posit16_t p16_roundToInt( posit16_t); posit16_t p16_add( posit16_t, posit16_t ); @@ -118,18 +148,18 @@ cdef extern from '../SoftPosit/source/include/softposit.h': bint p16_le( posit16_t, posit16_t ); bint p16_lt( posit16_t, posit16_t ); - #Quire 16 + # Quire 16 quire16_t q16_fdp_add( quire16_t, posit16_t, posit16_t ); quire16_t q16_fdp_sub( quire16_t, posit16_t, posit16_t ); - #posit16_t convertQ16ToP16( quire16_t ); + # posit16_t convertQ16ToP16( quire16_t ); posit16_t q16_to_p16( quire16_t ); bint isNaRQ16( quire16_t ); bint isQ16Zero( quire16_t ); - #quire16_t q16_TwosComplement( quire16_t ); + # quire16_t q16_TwosComplement( quire16_t ); - #void printBinary( uint64_t*, int ); - #void printHex( uint64_t ); + # void printBinary( uint64_t*, int ); + # void printHex( uint64_t ); quire16_t q16_clr( quire16_t ); quire16_t castQ16( uint16_t, uint16_t ); @@ -139,5 +169,5 @@ cdef extern from '../SoftPosit/source/include/softposit.h': # Helper double convertP16ToDouble( posit16_t ); - #posit16_t convertFloatToP16( float ); + # posit16_t convertFloatToP16( float ); posit16_t convertDoubleToP16( double );