-# IEEE Floating Point Adder (Single Precision)
-# Copyright (C) Jonathan P Dawson 2013
-# 2013-12-12
+"""IEEE Floating Point Adder Pipeline
+
+Relevant bugreport: http://bugs.libre-riscv.org/show_bug.cgi?id=75
+
+Stack looks like this:
+
+* scnorm - FPMulSpecialCasesDeNorm
+* addalign - FPAddAlignSingleAdd
+* normpack - FPNormToPack
+
+scnorm - FPDIVSpecialCasesDeNorm ispec FPADDBaseData
+------ ospec FPSCData
+
+ StageChain: FPMULSpecialCasesMod,
+ FPAddDeNormMod
+ FPAlignModSingle
+
+addalign - FPAddAlignSingleAdd ispec FPSCData
+-------- ospec FPAddStage1Data
+
+ StageChain: FPAddAlignSingleMod
+ FPAddStage0Mod
+ FPAddStage1Mod
+
+normpack - FPNormToPack ispec FPAddStage1Data
+-------- ospec FPPackData
+
+ StageChain: Norm1ModSingle,
+ RoundMod,
+ CorrectionsMod,
+ PackMod
+
+This pipeline has a 3 clock latency, and, with the separation into
+separate "modules", it is quite clear how to create longer-latency
+pipelines (if needed) - just create a new, longer top-level (FPADDBasePipe
+alternative) and construct shorter pipe stages using the building blocks,
+RoundMod, FPAddStage0Mod etc.
+
+"""
from nmigen import Module
from nmigen.cli import main, verilog
from ieee754.fpcommon.normtopack import FPNormToPack
from .specialcases import FPAddSpecialCasesDeNorm
from .addstages import FPAddAlignSingleAdd
-
+from ieee754.pipeline import PipelineSpec
class FPADDBasePipe(ControlBase):
- def __init__(self, width, id_wid):
+ def __init__(self, pspec):
ControlBase.__init__(self)
- self.pipe1 = FPAddSpecialCasesDeNorm(width, id_wid)
- self.pipe2 = FPAddAlignSingleAdd(width, id_wid)
- self.pipe3 = FPNormToPack(width, id_wid)
+ self.pipe1 = FPAddSpecialCasesDeNorm(pspec)
+ self.pipe2 = FPAddAlignSingleAdd(pspec)
+ self.pipe3 = FPNormToPack(pspec)
self._eqs = self.connect([self.pipe1, self.pipe2, self.pipe3])
Fan-in and Fan-out are combinatorial.
"""
+
def __init__(self, width, num_rows, op_wid=None):
- self.width = width
self.id_wid = num_bits(width)
self.op_wid = op_wid
- self.alu = FPADDBasePipe(width, self.id_wid)
+ self.pspec = PipelineSpec(width, self.id_wid, op_wid)
+ self.alu = FPADDBasePipe(self.pspec)
ReservationStations.__init__(self, num_rows)
def i_specfn(self):
- return FPADDBaseData(self.width, self.id_wid, self.op_wid)
+ return FPADDBaseData(self.pspec)
def o_specfn(self):
- return FPPackData(self.width, self.id_wid, self.op_wid)
+ return FPPackData(self.pspec)