update image
[crowdsupply.git] / updates / 006_2018dec23_floorplan.mdwn
1 # A Reasonably Sane Plan
2
3 Honestly there is nothing sane about merging a variable-size polymorphic
4 vectorisation front-end onto a standard RISC register file in an MMX/SSE
5 fashion, right down to the byte level, however that's what we've chosen
6 to do. Why? well, because it's not been done before, and we'd like to
7 see how it works out. Plus, there's no new instructions needed, and
8 unlike a traditional vector system, which has its own pipeline and its
9 own register file, we don't need special instructions to transfer between
10 the vector register file (which will contain both integer and floating
11 point numbers), and we can leverage an absolutely standard superscalar
12 out-of-order microarchitecture, to save on design development effort.
13 That's the theory.
14
15 One of the things that's proved to be rather scary is both the size of
16 the register files (128 FP and 128 INT 64-bit registers), and the number
17 of ports needed for high-end processors: reports of 8R3W are not uncommon.
18 We're going for an odd-even hi-lo approach: 4 banks with a 32-32 bit
19 split and dividing further into odd register numbers and even register
20 numbers.
21
22 In the previous update it was explained that we will fully route source
23 registers (and sub-register "elements") down to the byte level, so that
24 after they have been processed through the ALU, there is absolutely no
25 need to do any further routing. This is akin to a standard vectorisation
26 system's "lanes". Additionally, every byte on the register file will
27 have its own separate "write" line, such that for 16-bit and 8-bit
28 element widths we do not need to do extraneous read-merge-write cycles.
29
30 It was also explained that to do byte-level source register routing,
31 across all four banks, that's a 16-to-16 crossbar routing 8 bit values
32 from any 16 to any 16 destination locations. This is simply too much,
33 particularly given that if we use 2R1W we will need *two* 16-to-16
34 crossbars. The number of gates is massive.
35
36 We have an accompanying [[video]](https://www.youtube.com/watch?v=78het1cfz_8)
37 walkthough, however here is a photo of the scheme currently under discussion:
38
39 {{libreriscv_floorplan.jpg}}
40
41 What we will likely go with is a hybrid arrangement. In the top right of
42 the above photo is a 4-bank arrangement, 32-bit wide as before. However
43 there is only 4-to-4 crossbar routing, 32-bit wide. Again, this is only
44 on the source registers. Two of these crossbars will be needed: one for
45 src1, one for src2.
46
47 In the bottom middle you can see that we decided to put in xBitManip
48 Function Units onto the 8-bit Function Unit Area. These are actually
49 32-bit bit manipulation ALUs, however we are putting them in the *8-bit* area.
50 The reason is very simple: these xBitManip ALUs will *also* be used, in
51 a pseudo-micro-code fashion, to serve the dual purpose of reordering
52 and routing source element register bytes to the correct "lane".
53
54 What will happen is:
55
56 * Each 8-bit Function Unit (synonymous in this scheme with a
57 "Reservation Station" row), will have src1 and src2 latches
58 for incoming registers.
59 * 32-bit data will be latched into the **wrong** 8-bit Function Unit,
60 along with the remainder of the element "address" to which the
61 source value **should** be directed.
62 * The "wrong" data will be sent through the xBitManip ALUs, to shuffle
63 and permute it to the **right** order.
64 * **Pre-existing** operand "forwarding" routing will take the output
65 from the xBitManip ALUs and put it **back** into the Function Unit
66 Reservation Station src1 (or src2) latches.
67 * With the source sub-register 8-bit values now in their correct "lanes",
68 the actual required 8-bit ALU operation may now proceed.
69
70 So it's a multi-stage process that's very similar to micro-code operations:
71 it is however easier to hard-wire the use of the xBitManip ALUs than it
72 is to create multiple micro-code instructions, which was one possibility
73 that was considered.
74
75 In essence, the xBitManip ALU can handle 4x4 crossbar routing at the byte
76 level with no difficulties whatsoever, so we might as well use it for
77 precisely that job. What's nice is that we can decide how many xBitManip
78 ALUs to put in, depending on how the VPU workload works out. Plus, the
79 infrastructure to handle queueing, routing and temporary storage of the
80 in-flight source register values *already exists*. The alternative previously
81 discussed was to have massive duplicated dedicated 16x16 crossbars: now
82 we have only 4x4 32-bit crossbars plus a *small* number of 4x4 8-bit
83 crossbars (aka xBitManip ALUs), saving significantly on the number of gates.
84
85 # Reducing Register-FU Matrix sizes
86
87 Also, one significant detail. Recall in the previous update that a scheme
88 was finally envisaged where 64-bit Function Units would cascade-block
89 32-bit Function Units right down to 8-bit, on any given register. We decided
90 that this, too, was insane, given that it would result in a whopping 16
91 fold increase in the Function Unit Matrices.
92
93 Instead we decided to go with 32-bit to 8-bit cascade-blocking, where
94 two adjacent 32-bit Function Units would be required to perform 64-bit
95 operations, and two adjacent 8-bit Function Units required to do 16-bit
96 operations. In this way the FU-to-FU Dependency Matrices are reduced
97 down to only a four-fold size increase when compared to a more traditional
98 SIMD arrangement.
99
100 In the middle towards the top of the above picture, we can therefore
101 see a four-wide group of 32-bit Function Units: FU1 through FU4. These,
102 unsurprisingly, are dedicated to *destination* register banks, i.e. the
103 write port is connected very specifically and exclusively to their
104 respective RegFile bank.
105
106 Function Units 8 through 12 are the 8-bit FUs. Really there should
107 be sixteen of these, because it is likely that we will need one for
108 every byte of the full width of 4 32-bit register banks. If we do not
109 have 16 of them, having say only 8, it will be necessary to do *destination*
110 routing to the correct 32-bit-wide RegFile bank. This is something that
111 we are keen to avoid.
112
113 Also bear in mind that we have not shown, in the above diagram,
114 the enhancements designed by Mitch Alsup, to the 6600 Scoreboard system.
115 These enhancements basically add LOAD/STORE "Function Units", which cover
116 the exact same role as the Tomasulo scheme's LOAD/STORE queues (provide
117 out-of-order correctly sequenced LOAD/STORE operations). One Function
118 Unit (aka Reservation Station) is required per outstanding LOAD/STORE
119 needed, and we need LOAD/STOREs on **both** the 32-bit FUs **and** the
120 8-bit FUs. It **may** be possible to merge these into one: we will have
121 to see.
122
123 Also, Branch Prediction (including speculative execution) requires individual
124 Function Units: one for each branch that is intended to run ahead. Remember
125 that it was previously mentioned that there would be a "Schroedinger" wire
126 indicating that the instructions operating in the "shadow" of the branch
127 would be neither alive nor dead, and that until this was determined they
128 would be treated as "Write Hazards", allowing them to *execute* but **not**
129 commit (write) their results. We will need such Function Units on both
130 the 32-bit **and** the 8-bit areas. Exceptions likewise.
131
132 So if we are not careful we could easily end up with 64 Function Units:
133 32 for the 32-bit area and 32 for the 8-bit area. This is going to need
134 some experimentation and some detailed thought, when it comes to actual
135 implementation. A 64x64 Function Unit Dependency Matrix is pretty massive,
136 even if the cell size (and power consumption) is very small compared to
137 Tomasulo plus Reorder Buffers, with associated CAMs.
138
139 There is a lot of detail that still needs to be done: we are however reaching
140 the end of the critical "overview" planning phase. Really it is time to
141 start implementing a first iteration, to see how it works out. For that,
142 we will be looking closely at Mitch Alsup's unpublished book chapters,
143 as there really is no reason why we should not just implement the gate-level
144 diagrams that he has kindly given permission to use (with credit).
145