Skip to content

Wrapping and Bias issues #44

@desvdp

Description

@desvdp

Hi Franco,
thanks for fixing the previous issues so quickly! Looking a bit closer, I did find some extra:

(1) Bias and scaling don't seem to play very wel with wrapping/saturation:

>>> b= Fxp(20.5,False, n_word=5 ,scaling=1, bias=8)
>>> b
fxp-u5/1(20.5)  ----> Ok
>>> b.bin() 
'11001'               ----> Ok

>>> b= Fxp(20.5,False, n_word=4 ,scaling=1, bias=8)
>>> b
fxp-u4/0(20.0)    ---> Had expected a saturation ie 15/2+8 = 15.5
>>> b.bin()
'1100'                  ---> Saturation? 1111

(2) There seems to be an issue with zero values:

>>> zero = Fxp(0.0,False, n_word=5 ,overflow='wrap', scaling=1, bias=8)     --> The range is [8, 23.5] ie 0 is out of range 
>>> zero
fxp-u5/0(32.0)        --> But so is 32 ... 
>>> zero.bin()
'11000'
>>> zero.info(verbose=3)
	dtype		=	fxp-u5/0
	Value		=	32.0
	Scaling		=	1 * val + 8
	underflow	=	True
	inaccuracy	=	True

	Signed		=	False
	Word bits	=	5
	Fract bits	=	0
	Int bits	=	5
	Val data type	=	<class 'float'>

	Upper		=	39.0
	Lower		=	8.0
	Precision	=	1.0
	Overflow	=	wrap
	Rounding	=	trunc
	Shifting	=	expand

Saturation does deal with it:

>>> zero = Fxp(0,False, n_word=5 ,overflow='saturate', scaling=1, bias=8)
>>> zero
fxp-u5/0(8.0) --> Ok 

(3) Last but not least, some long values still throw an error:
b= Fxp(0,False,64,0,overflow='wrap', bias = 8)

Let me know if you need further help testing ...

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions