dbb4460aa1c8de789fe06e2636d77918e0c302c9
1 # IEEE754 FCLASS Module
2 # Copyright (C) 2019 Luke Kenneth Casson Leighon <lkcl@lkcl.net>
5 from nmigen
import Module
, Signal
, Elaboratable
6 from nmigen
.cli
import main
, verilog
8 from nmutil
.singlepipe
import ControlBase
9 from nmutil
.concurrentunit
import ReservationStations
, num_bits
11 from ieee754
.fpcommon
.basedata
import FPBaseData
12 from ieee754
.fpcommon
.pack
import FPPackData
15 from ieee754
.fpcommon
.fpbase
import FPState
, FPNumBase
16 from ieee754
.fpcommon
.getop
import FPPipeContext
18 from ieee754
.fpcommon
.fpbase
import FPState
19 from ieee754
.fclass
.fclass
import FPClassMod
20 from ieee754
.pipeline
import PipelineSpec
, DynamicPipe
23 class FPFClassPipe(DynamicPipe
):
24 """ FPConversion: turns its argument (modkls) from a stage into a pipe
27 def __init__(self
, in_pspec
, out_pspec
, modkls
):
28 in_pspec
.stage
= modkls(in_pspec
, out_pspec
)
29 super().__init
__(in_pspec
)
32 # XXX not used because there isn't anything to "join" (no pipe chain)
33 # keeping this code around just in case FPClass has to be split into
34 # two [unlikely but hey]
35 class FPClassBasePipe(ControlBase
):
36 def __init__(self
, modkls
, in_pspec
, out_pspec
):
37 ControlBase
.__init
__(self
)
38 # redundant because there's only one "thing" here.
39 self
.pipe1
= FPFClassPipe(in_pspec
, out_pspec
, modkls
)
40 self
._eqs
= self
.connect([self
.pipe1
, ])
42 def elaborate(self
, platform
):
43 m
= ControlBase
.elaborate(self
, platform
)
44 m
.submodules
.fclass
= self
.pipe1
49 class FPClassMuxInOutBase(ReservationStations
):
50 """ Reservation-Station version of FPClass pipeline.
52 * fan-in on inputs (an array of FPBaseData: a,b,mid)
53 * 2-stage multiplier pipeline
54 * fan-out on outputs (an array of FPPackData: z,mid)
56 Fan-in and Fan-out are combinatorial.
59 def __init__(self
, modkls
, in_width
, out_width
,
60 num_rows
, op_wid
=0, pkls
=FPClassBasePipe
):
62 self
.id_wid
= num_bits(num_rows
)
64 self
.in_pspec
= PipelineSpec(in_width
, self
.id_wid
, op_wid
)
65 self
.out_pspec
= PipelineSpec(out_width
, self
.id_wid
, op_wid
)
67 self
.alu
= pkls(self
.in_pspec
, self
.out_pspec
, modkls
)
68 ReservationStations
.__init
__(self
, num_rows
)
71 return FPBaseData(self
.in_pspec
)
74 return FPPackData(self
.out_pspec
)
77 class FPClassMuxInOut(FPClassMuxInOutBase
):
78 """ Reservation-Station version of FPClass pipeline.
80 * fan-in on inputs (an array of FPBaseData: a,b,mid)
81 * 2-stage multiplier pipeline
82 * fan-out on outputs (an array of FPPackData: z,mid)
84 Fan-in and Fan-out are combinatorial.
87 def __init__(self
, in_width
, out_width
, num_rows
, op_wid
=0):
88 FPClassMuxInOutBase
.__init
__(self
, FPClassMod
,
92 #pkls=FPClassBasePipe)