1 """ concurrent unit from mitch alsup augmentations to 6600 scoreboard
4 * data goes through a pipeline
5 * results fan back out.
7 the output data format has to have a member "mid", which is used
8 as the array index on fan-out
12 from nmigen
import Module
, Elaboratable
13 from nmigen
.cli
import main
, verilog
15 from nmutil
.singlepipe
import PassThroughStage
16 from nmutil
.multipipe
import CombMuxOutPipe
17 from nmutil
.multipipe
import PriorityCombMuxInPipe
21 return int(log(n
) / log(2))
24 class FPADDInMuxPipe(PriorityCombMuxInPipe
):
25 def __init__(self
, num_rows
, iospecfn
):
26 self
.num_rows
= num_rows
27 stage
= PassThroughStage(iospecfn
)
28 PriorityCombMuxInPipe
.__init
__(self
, stage
, p_len
=self
.num_rows
)
31 class FPADDMuxOutPipe(CombMuxOutPipe
):
32 def __init__(self
, num_rows
, iospecfn
):
33 self
.num_rows
= num_rows
34 stage
= PassThroughStage(iospecfn
)
35 CombMuxOutPipe
.__init
__(self
, stage
, n_len
=self
.num_rows
)
38 class ReservationStations(Elaboratable
):
39 """ Reservation-Station pipeline
41 Input: num_rows - number of input and output Reservation Stations
43 Requires: the addition of an "alu" object, an i_specfn and an o_specfn
45 * fan-in on inputs (an array of FPADDBaseData: a,b,mid)
47 * fan-out on outputs (an array of FPPackData: z,mid)
49 Fan-in and Fan-out are combinatorial.
51 def __init__(self
, num_rows
):
52 self
.num_rows
= num_rows
53 self
.inpipe
= FPADDInMuxPipe(num_rows
, self
.i_specfn
) # fan-in
54 self
.outpipe
= FPADDMuxOutPipe(num_rows
, self
.o_specfn
) # fan-out
56 self
.p
= self
.inpipe
.p
# kinda annoying,
57 self
.n
= self
.outpipe
.n
# use pipe in/out as this class in/out
58 self
._ports
= self
.inpipe
.ports() + self
.outpipe
.ports()
60 def elaborate(self
, platform
):
62 m
.submodules
.inpipe
= self
.inpipe
63 m
.submodules
.alu
= self
.alu
64 m
.submodules
.outpipe
= self
.outpipe
66 m
.d
.comb
+= self
.inpipe
.n
.connect_to_next(self
.alu
.p
)
67 m
.d
.comb
+= self
.alu
.connect_to_next(self
.outpipe
)