c1b3f78435d147c8faacd6bf7331f12f0335c0be
[libreriscv.git] / 3d_gpu / architecture / dynamic_simd / assign.mdwn
1 # PartitionedSignal nmigen-aware eq (assign)
2
3 * <https://bugs.libre-soc.org/show_bug.cgi?id=709>
4
5 For copying (assigning) PartitionedSignal to PartitionedSignal
6 of equal size there is no issue. However if the source has a
7 greater width than the target, *partition-aware* truncation
8 must occur. For the opposite, sign/zero extension must occur.
9 Finally for a Signal or Const, duplication across all Partitions
10 must occur, again, following the rules of zero, sign or unsigned.
11
12 Take two PartitionedSignals (source a, dest b) of 32 bit:
13
14 partition: p p p (3 bits)
15 a : AAA3 AAA2 AAA1 AAA0 (32 bits)
16 b : BBB3 BBB2 BBB1 BBB0 (32 bits)
17
18 For all partition settings this copies verbatim. However if A
19 is shorter than B:
20
21 partition: p p p (3 bits)
22 a : A7A6 A5A4 A3A2 A1A0 (8 bits)
23 b : BBB3 BBB2 BBB1 BBB0 (16 bits)
24
25 then it matters what the partition settings are:
26
27 | partition | o3 | o2 | o1 | o0 |
28 | --------- | -- | -- | -- | -- |
29 | 000 | [A7A7A7A7] | [A7A7A7A7] | A7A6A5A4 | A3A2A1A0 |
30 | 001 | [A7A7A7A7] | [A7A7]A7A6 | A5A4A3A2 | [A1A1]A1A0 |
31 | 010 | [A7A7A7A7] | A7A6A5A4 | [A3A3A3A3] | A3A2A1A0 |
32 | 111 | [A7A7]A7A6 | [A5A5]A5A4 | [A3A3]A3A2 | [A1A1]A1A0 |
33
34 where square brackets are zero if A is unsigned, and contains
35 the specified bits if signed.
36
37 When the source A is scalar and is equal or larger than
38 the destination it requires copying across multiple
39 partitions:
40
41 partition: p p p (3 bits)
42 a : AAAA AAAA AAAA AAAA (16 bits)
43 b : B7B6 B5B4 B3B2 B1B0 (8 bits)
44
45 The partition options are:
46
47 | partition | o3 | o2 | o1 | o0 |
48 | --------- | -- | -- | -- | -- |
49 | 000 | A7A6 | A5A4 | A3A2 | A1A0 |
50 | 001 | A5A4 | A3A2 | A1A0 | A1A0 |
51 | 010 | A3A2 | A1A0 | A3A2 | A1A0 |
52 | 100 | A1A0 | A5A4 | A3A2 | A1A0 |
53 | 111 | A1A0 | A1A0 | A1A0 | A1A0 |