1 """ Group Picker: to select an instruction that is permitted to read (or write)
2 based on the Function Unit expressing a *desire* to read (or write).
4 The job of the Group Picker is extremely simple yet extremely important.
5 It sits in front of a register file port (read or write) and stops it from
6 being corrupted. It's a "port contention selector", basically.
10 * Function Units need to read from (or write to) the register file,
11 in order to get (or store) their operands, so they each have a signal,
12 readable (or writable), which "expresses" this need. This is an
15 * The Function Units also have a signal which indicates that they
16 are requesting "release" of the register file port (this because
17 in the scoreboard, readable/writable can be permanently HI even
18 if the FU is idle, whereas the "release" signal is very specifically
19 only HI if the read (or write) latch is still active)
21 * The Group Picker takes this unary encoding of the desire to read
22 (or write) and, on a priority basis, activates one *and only* one
23 of those signals, again as an unary output.
25 * Due to the way that the Computation Unit works, that signal (Go_Read
26 or Go_Write) will fire for one (and only one) cycle, and can be used
27 to enable the register file port read (or write) lines. The Go_Read/Wr
28 signal basically loops back to the Computation Unit and resets the
29 "desire-to-read/write-expressing" latch.
31 In theory (and in practice!) the following is possible:
33 * Separate src1 and src2 Group Pickers. This would allow instructions
34 with only one operand to read to not block up other instructions,
35 and it would also allow 3-operand instructions to be interleaved
36 with 1 and 2 operand instructions.
38 * *Multiple* Group Pickers (multi-issue). This would require
39 a corresponding increase in the number of register file ports,
40 either 4R2W (or more) or by "striping" the register file into
41 split banks (a strategy best deployed on Vector Processors)
45 from nmigen
.compat
.sim
import run_simulation
46 from nmigen
.cli
import verilog
, rtlil
47 from nmigen
import Module
, Signal
, Elaboratable
49 from nmutil
.picker
import PriorityPicker
52 class GroupPicker(Elaboratable
):
53 """ implements 10.5 mitch alsup group picker, p27
55 def __init__(self
, wid
):
58 self
.readable_i
= Signal(wid
, reset_less
=True) # readable in (top)
59 self
.writable_i
= Signal(wid
, reset_less
=True) # writable in (top)
60 self
.rd_rel_i
= Signal(wid
, reset_less
=True) # go read in (top)
61 self
.req_rel_i
= Signal(wid
, reset_less
=True) # release request in (top)
64 self
.go_rd_o
= Signal(wid
, reset_less
=True) # go read (bottom)
65 self
.go_wr_o
= Signal(wid
, reset_less
=True) # go write (bottom)
67 def elaborate(self
, platform
):
70 m
.submodules
.rpick
= rpick
= PriorityPicker(self
.gp_wid
)
71 m
.submodules
.wpick
= wpick
= PriorityPicker(self
.gp_wid
)
73 # combine release (output ready signal) with writeable
74 m
.d
.comb
+= wpick
.i
.eq(self
.writable_i
& self
.req_rel_i
)
75 m
.d
.comb
+= self
.go_wr_o
.eq(wpick
.o
)
77 m
.d
.comb
+= rpick
.i
.eq(self
.readable_i
& self
.rd_rel_i
)
78 m
.d
.comb
+= self
.go_rd_o
.eq(rpick
.o
)
93 def grp_pick_sim(dut
):
94 yield dut
.dest_i
.eq(1)
95 yield dut
.issue_i
.eq(1)
97 yield dut
.issue_i
.eq(0)
99 yield dut
.src1_i
.eq(1)
100 yield dut
.issue_i
.eq(1)
104 yield dut
.issue_i
.eq(0)
106 yield dut
.rd_rel_i
.eq(1)
108 yield dut
.rd_rel_i
.eq(0)
110 yield dut
.go_wr_i
.eq(1)
112 yield dut
.go_wr_i
.eq(0)
117 vl
= rtlil
.convert(dut
, ports
=dut
.ports())
118 with
open("test_grp_pick.il", "w") as f
:
121 run_simulation(dut
, grp_pick_sim(dut
), vcd_name
='test_grp_pick.vcd')
123 if __name__
== '__main__':