bug #1183: attempt first ddffirst mapreduce mode
[openpower-isa.git] / openpower / isa / prefix_codes.mdwn
1 <!-- https://libre-soc.org/openpower/prefix_codes/ -->
2
3 # [DRAFT] Prefix-code decode
4
5 VA-Form
6
7 * pcdec. RT,RA,RB,RC
8
9 Pseudo-code:
10
11 tree[0:63] <- (RB)
12 mode <- tree[62:63]
13 tree[62:63] <- 0
14 ra_used <- 0b0
15 in_bits[0:63] <- (RC|0)
16 if in_bits = 0 then
17 in_bits[0:63] <- 1
18 orig_in_bits <- in_bits
19 tree_index <- 1
20 found <- 0b0
21 hit_end <- 0b0
22 do bit_length = 1 to 6
23 in_bit <- in_bits[63]
24 if in_bits = 1 then
25 if ra_used | (_RA = 0) then
26 hit_end <- 0b1
27 leave
28 ra_used <- 0b1
29 in_bit <- (RA)[63]
30 in_bits <- 0b1 || (RA)[0:62]
31 else
32 in_bits <- 0b0 || in_bits[0:62]
33 # walk the binary tree in `tree` from parent to the selected child
34 tree_index <- tree_index * 2
35 if in_bit = 1 then
36 tree_index <- tree_index + 1
37 if tree_index < 64 then
38 if tree[63 - tree_index] then
39 found <- 0b1
40 leave
41 compressed_index <- 0
42 do i = 0 to 127
43 possible <- 1
44 j <- i
45 do while j >= 4
46 j <- j / 2
47 if tree[63 - j] then
48 possible <- 0
49 leave
50 if i = tree_index then
51 leave
52 else if i >= 64 then
53 compressed_index <- compressed_index + possible
54 else if tree[63 - i] = 1 then
55 compressed_index <- compressed_index + possible
56 switch(mode)
57 case(0):
58 RT[0:63] <- tree_index
59 if ¬found then
60 in_bits <- orig_in_bits
61 ra_used <- 0b0
62 case(1):
63 RT[0:63] <- tree_index
64 if hit_end then
65 in_bits <- orig_in_bits
66 ra_used <- 0b0
67 case(2):
68 RT[0:63] <- compressed_index
69 if ¬found then
70 in_bits <- orig_in_bits
71 ra_used <- 0b0
72 RT[0:63] <- tree_index
73 default:
74 RT[0:63] <- compressed_index
75 if hit_end then
76 in_bits <- orig_in_bits
77 ra_used <- 0b0
78 RS <- in_bits
79 CR0 <- ra_used || (tree_index >= 64) || found || hit_end
80
81 Special Registers Altered:
82
83 CR0