Skip to content

Commit c8e8f75

Browse files
committed
Fixed point utils MSB bug fix
1 parent 62046d7 commit c8e8f75

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

hls4ml/utils/fixed_point_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import sys
22
import math
3+
from unicodedata import decimal
4+
5+
from numpy import integer
36

47
'''
58
A helper class for handling fixed point methods
@@ -65,8 +68,9 @@ def set_msb_bits(self, bits):
6568
for i in range(0, len(bits)):
6669
if i < self.I:
6770
self.integer_bits[i] = bits[i]
68-
elif i >= self.I and i<self.F:
71+
elif i >= self.I and i<self.N:
6972
self.decimal_bits[i-self.I] = bits[i]
73+
# print('Len bits ' + str(len(bits)) + ' Inside FPU ' + str(self.integer_bits) + str(self.decimal_bits))
7074

7175
'''
7276
Returns e^x, where x is the current fixed point number
@@ -77,7 +81,7 @@ def set_msb_bits(self, bits):
7781
Notice:
7882
- If e^x overflow, maximum value of float is used
7983
'''
80-
def exp_float(self, sig_figs=6):
84+
def exp_float(self, sig_figs=12):
8185
try:
8286
return round(math.exp(self.to_float()), sig_figs)
8387
except OverflowError:
@@ -89,7 +93,7 @@ def exp_float(self, sig_figs=6):
8993
Returns:
9094
- Float : 1/x, rounded some number of decimal points
9195
'''
92-
def inv_float(self, sig_figs=10):
96+
def inv_float(self, sig_figs=12):
9397
if self.to_float()!=0:
9498
return round(1.0/self.to_float(), sig_figs)
9599
else:

0 commit comments

Comments
 (0)