(no commit message)
[libreriscv.git] / 3d_gpu / architecture / dynamic_simd / cat.mdwn
1 # PartitionedSignal nmigen-aware Cat
2
3 * <https://bugs.libre-soc.org/show_bug.cgi?id=707>
4
5 Concatenation of Signals is ordinarily straightforward: reduce to the bitlevel and create a sequence. The contributors to that sequence may be of arbitrary length.
6
7 However for a PartitionedSignal unless *all* contributors are also
8 PartitionedSignals, the results cannot be guaranteed to match, at all
9 partition sizes.
10
11 Take two PartitionedSignals:
12
13 partition: p p p (3 bits)
14 a : AAA3 AAA2 AAA1 AAA0 (32 bits)
15 b : BBB3 BBB2 BBB1 BBB0 (32 bits)
16
17 When the partitions are 32-bit, the output is:
18
19 partition: p p p (3 bits)
20 out : AAA3 AAA2 AAA1 AAA0 BBB3 BBB2 BBB1 BBB0 (64 bits)
21
22 When 2x16, the top 2 halves of A and B are Catted together,
23 and likewise the lower:
24
25 partition: p p p (3 bits)
26 out : AAA3 AAA2 BBB3 BBB2 AAA1 AAA0 BBB1 BBB0 (64 bits)
27
28 Finally when 4x8, each byte is concatenated:
29
30 partition: p p p (3 bits)
31 out : AAA3 BBB3 AAA2 BBB2 AAA1 BBB1 AAA0 BBB0 (64 bits)
32
33 This then generalises regardless of the number of PartitionedSignals
34 being Concatenated, and regardless of whether the length of
35 any individual PartitionedSignal is of differing length.
36 Bearing in mind that Partitions may **only** be on
37 equal sized points (4x 4-bit, not 3x 3-bit plus one 5-bit):
38
39 To confirm that let us assume that A is 16-bit and B is 32-bit:
40
41 partition: p p p (3 bits)
42 a : A3 A2 A1 A0 (16 bits)
43 b : BBB3 BBB2 BBB1 BBB0 (32 bits)
44
45 When the partitions are x, the output is:
46
47 partition: p p p (3 bits)
48 out : A3 A2 A1 A0 BBB3 BBB2 BBB1 BBB0 (64 bits)
49
50 When 2x:
51
52 partition: p p p (3 bits)
53 out : A3 A2 BBB3 BBB2 A1 A0 BBB1 BBB0 (64 bits)
54
55 Finally when 4x:
56
57 partition: p p p (3 bits)
58 out : A3 BBB3 A2 BBB2 A1 BBB1 A0 BBB0 (48 bits)
59
60 By a lucky coincidence the lengths match up. In the 1x case,
61 the result is a single 48-bit quantity. In the 2x case,
62 the result is two 24-bit quantities. Finally in the 4x case,
63 the result is four 12-bit quantities.
64
65 The reason this works is down to the requirement that Partitions be
66 of equal sizes. 4x 4-bit to be Concatenated with 4x 8-bit, in
67 the last example.
68
69 Table for 3-way concatenation, divided by partition:
70
71 | partition | o3 | o2 | o1 | o0 |
72 | 000 | a3 a2 a1 | a0 b3 b2 | b1 b0 c3 | c2 c1 c0 |
73 | 111 | a3 b3 c3 | a2 b2 c2 | a1 b1 c1 | a0 b0 c0 |