From: Luke Kenneth Casson Leighton Date: Thu, 4 Apr 2019 21:35:03 +0000 (+0100) Subject: add create2 functions, for use later X-Git-Tag: ls180-24jan2020~1345 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=08cc069dd3bdece2058d27171b73469a9fd3a09f;p=ieee754fpu.git add create2 functions, for use later --- diff --git a/src/add/fpbase.py b/src/add/fpbase.py index b15c21ca..b31ab21c 100644 --- a/src/add/fpbase.py +++ b/src/add/fpbase.py @@ -87,6 +87,8 @@ class FPNumBase: self.s = Signal(reset_less=True) # Sign bit self.mzero = Const(0, (m_width, False)) + m_msb = 1<<(self.m_width-2) + self.msb1 = Const(m_msb, (m_width, False)) self.m1s = Const(-1, (m_width, False)) self.P128 = Const(e_max, (e_width, True)) self.P127 = Const(e_max-1, (e_width, True)) @@ -186,6 +188,25 @@ class FPNumOut(FPNumBase): def zero(self, s): return self.create(s, self.N127, 0) + def create2(self, s, e, m): + """ creates a value from sign / exponent / mantissa + + bias is added here, to the exponent + """ + e = e + self.P127 # exp (add on bias) + return Cat(m[0:self.e_start], + e[0:self.e_end-self.e_start], + s) + + def nan2(self, s): + return self.create2(s, self.P128, self.msb1) + + def inf2(self, s): + return self.create2(s, self.P128, self.mzero) + + def zero2(self, s): + return self.create2(s, self.N127, self.mzero) + class MultiShiftRMerge: """ shifts down (right) and merges lower bits into m[0].