From: Luke Kenneth Casson Leighton Date: Sun, 16 Jun 2019 06:07:32 +0000 (+0100) Subject: create FPNumBaseRecord X-Git-Tag: ls180-24jan2020~991 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1bf29821ee5143ef8ba51e3dc0a92002c8a9d3e0;p=ieee754fpu.git create FPNumBaseRecord --- diff --git a/src/ieee754/fpcommon/denorm.py b/src/ieee754/fpcommon/denorm.py index 2653e335..44d5461a 100644 --- a/src/ieee754/fpcommon/denorm.py +++ b/src/ieee754/fpcommon/denorm.py @@ -6,8 +6,8 @@ from nmigen import Module, Signal, Elaboratable from nmigen.cli import main, verilog from math import log -from ieee754.fpcommon.fpbase import FPNumIn, FPNumOut, FPNumBase -from ieee754.fpcommon.fpbase import FPState +from ieee754.fpcommon.fpbase import FPNumIn, FPNumOut, FPNumBaseRecord +from ieee754.fpcommon.fpbase import FPState, FPNumBase class FPSCData: diff --git a/src/ieee754/fpcommon/fpbase.py b/src/ieee754/fpcommon/fpbase.py index 198ce036..4889407f 100644 --- a/src/ieee754/fpcommon/fpbase.py +++ b/src/ieee754/fpcommon/fpbase.py @@ -60,7 +60,7 @@ class MultiShift: return res -class FPNumBase: #(Elaboratable): +class FPNumBaseRecord: """ Floating-point Base Number Class """ def __init__(self, width, m_extra=True): @@ -96,6 +96,22 @@ class FPNumBase: #(Elaboratable): self.N127 = Const(-(e_max-1), (e_width, True)) self.N126 = Const(-(e_max-2), (e_width, True)) + def __iter__(self): + yield self.s + yield self.e + yield self.m + + def eq(self, inp): + return [self.s.eq(inp.s), self.e.eq(inp.e), self.m.eq(inp.m)] + + +class FPNumBase(FPNumBaseRecord): # Elaboratable + """ Floating-point Base Number Class + """ + def __init__(self, width, m_extra=True): + FPNumBaseRecord.__init__(self, width, m_extra) + e_width = self.e_width + self.is_nan = Signal(reset_less=True) self.is_zero = Signal(reset_less=True) self.is_inf = Signal(reset_less=True) @@ -145,14 +161,6 @@ class FPNumBase: #(Elaboratable): def _is_denormalised(self): return (self.exp_n126) & (self.m_msbzero) - def __iter__(self): - yield self.s - yield self.e - yield self.m - - def eq(self, inp): - return [self.s.eq(inp.s), self.e.eq(inp.e), self.m.eq(inp.m)] - class FPNumOut(FPNumBase): """ Floating-point Number Class