1 # IEEE754 FCLASS Module
2 # Copyright (C) 2019 Luke Kenneth Casson Leighon <lkcl@lkcl.net>
4 from nmutil
.singlepipe
import ControlBase
5 from nmutil
.concurrentunit
import ReservationStations
, num_bits
6 from ieee754
.fpcommon
.fpbase
import FPNumBase
7 from ieee754
.fclass
.fclass
import FPClassMod
8 from ieee754
.pipeline
import PipelineSpec
, DynamicPipe
11 class FPFClassPipe(DynamicPipe
):
12 """ FPConversion: turns its argument (modkls) from a stage into a pipe
15 def __init__(self
, in_pspec
, out_pspec
, modkls
):
16 in_pspec
.stage
= modkls(in_pspec
, out_pspec
)
17 super().__init
__(in_pspec
)
20 # XXX not used because there isn't anything to "join" (no pipe chain)
21 # keeping this code around just in case FPClass has to be split into
22 # two [unlikely but hey]
23 class FPClassBasePipe(ControlBase
):
24 def __init__(self
, modkls
, in_pspec
, out_pspec
):
25 ControlBase
.__init
__(self
)
26 # redundant because there's only one "thing" here.
27 self
.pipe1
= FPFClassPipe(in_pspec
, out_pspec
, modkls
)
28 self
._eqs
= self
.connect([self
.pipe1
, ])
30 def elaborate(self
, platform
):
31 m
= ControlBase
.elaborate(self
, platform
)
32 m
.submodules
.fclass
= self
.pipe1
37 class FPClassMuxInOutBase(ReservationStations
):
38 """ Reservation-Station version of FPClass pipeline.
40 * fan-in on inputs (an array of FPBaseData: a,b,mid)
41 * 2-stage multiplier pipeline
42 * fan-out on outputs (an array of FPPackData: z,mid)
44 Fan-in and Fan-out are combinatorial.
47 def __init__(self
, modkls
, in_width
, out_width
,
48 num_rows
, op_wid
=0, pkls
=FPClassBasePipe
):
50 self
.id_wid
= num_bits(num_rows
)
52 self
.in_pspec
= PipelineSpec(in_width
, self
.id_wid
, op_wid
)
53 self
.out_pspec
= PipelineSpec(out_width
, self
.id_wid
, op_wid
)
55 self
.alu
= pkls(self
.in_pspec
, self
.out_pspec
, modkls
)
56 ReservationStations
.__init
__(self
, num_rows
)
59 class FPClassMuxInOut(FPClassMuxInOutBase
):
60 """ Reservation-Station version of FPClass pipeline.
62 * fan-in on inputs (an array of FPBaseData: a,b,mid)
63 * 2-stage multiplier pipeline
64 * fan-out on outputs (an array of FPPackData: z,mid)
66 Fan-in and Fan-out are combinatorial.
69 def __init__(self
, in_width
, out_width
, num_rows
, op_wid
=0):
70 FPClassMuxInOutBase
.__init
__(self
, FPClassMod
,
74 #pkls=FPClassBasePipe)