From b6803d366abaab2533647de4b0f569bea2c6750f Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 09:47:55 +0000 Subject: [PATCH] separate common functions into FPBase class --- src/add/nmigen_add_experiment.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 68b3a093..675ef4b3 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -111,13 +111,13 @@ class Overflow: self.sticky = Signal() # tot[0] -class FPADD: - def __init__(self, width): - self.width = width +class FPBase: + """ IEEE754 Floating Point Base Class - self.in_a = FPOp(width) - self.in_b = FPOp(width) - self.out_z = FPOp(width) + contains common functions for FP manipulation, such as + extracting and packing operands, normalisation, denormalisation, + rounding etc. + """ def get_op(self, m, op, v, next_state): """ this function moves to the next state and copies the operand @@ -222,6 +222,17 @@ class FPADD: m.d.sync += out_z.stb.eq(0) m.next = next_state + +class FPADD(FPBase): + + def __init__(self, width): + FPBase.__init__(self) + self.width = width + + self.in_a = FPOp(width) + self.in_b = FPOp(width) + self.out_z = FPOp(width) + def get_fragment(self, platform=None): """ creates the HDL code-fragment for FPAdd """ -- 2.30.2