11ce67d77c5545c96d9b5f3da9b9ab374d884d05
[libreriscv.git] / 3d_gpu / architecture / dynamic_simd / add.mdwn
1 # Partitioned Add
2
3 this principle also applies to subtract and negate (-)
4
5 the basic principle is: the partition bits, when inverted, can actually
6 be inserted into an (expanded) add, and, if the bit is set, it has
7 the side-effect of "rolling through" the carry bit of the MSB from
8 the previous partition.
9
10 this is a really neat trick, basically, that allows the use of a
11 straight "add" (DSP in an FPGA, add in a simulator) where
12 otherwise it would be extraordinarily complex, CPU-intensive
13 and take up large resources.
14
15 partition: P P P P (4 bits)
16 a : .... .... .... .... .... (32 bits)
17 b : .... .... .... .... .... (32 bits)
18 exp-a : ....P....P....P....P.... (32+4 bits, P=1 if no partition)
19 exp-b : ....0....0....0....0.... (32 bits plus 4 zeros)
20 exp-o : ....xN...xN...xN...xN... (32+4 bits - x to be discarded)
21 o : .... N... N... N... N... (32 bits - x ignored, N is carry-over)
22
23 new version:
24
25 partition: p p p p (4 bits)
26 carry-in : c c c c (4 bits)
27 C = c & P: C C C c (4 bits)
28 a : AAAA AAAA AAAA AAAA AAAA (32 bits)
29 b : BBBB BBBB BBBB BBBB BBBB (32 bits)
30 exp-a : 0AAAApAAAACAAAACAAAACAAAAc (32+4 bits, P=1 if no partition)
31 exp-b : 0BBBB0BBBBCBBBBCBBBBCBBBBc (32 bits plus 4 zeros)
32 exp-o : o....oN...oN...oN...oN...x (32+4 bits - x to be discarded)
33 o : .... N... N... N... N... (32 bits - x ignored, N is carry-over)
34 carry-out: o o o o (4 bits)
35
36 the new version
37
38 * brings in the carry-in (C) bits which, in combination with
39 the Partition bits, are ANDed to create "C & p".
40 * C is positioned twice (in both A and B) intermediates, which
41 has the effect of preserving carry-out, yet only performing a
42 carry-over if the carry-in bit (c) is set and this is part of
43 a partition
44 * o (carry-out) must be "cascaded" down to the relevant partition
45 start-point. this can be done with a Mux-cascade.
46