# Ternary Logic Immediate
-TLI-form
-
Add this section to Book I 3.3.13
+TLI-form
+
* `ternlogi RT, RA, RB, TLI` (`Rc=0`)
* `ternlogi. RT, RA, RB, TLI` (`Rc=1`)
Pseudocode:
```
-result <- (~RT&~RA&~RB & TLI[0]*XLEN |
- (~RT&~RA& RB & TLI[1]*XLEN |
- (~RT& RA&~RB & TLI[2]*XLEN |
- (~RT& RA& RB & TLI[3]*XLEN |
- ( RT&~RA&~RB & TLI[4]*XLEN |
- ( RT&~RA& RB & TLI[5]*XLEN |
- ( RT& RA&~RB & TLI[6]*XLEN |
- ( RT& RA& RB & TLI[7]*XLEN)
+result <- (~RT & ~RA & ~RB & TLI[0]*64) | # 64 copies of TLI[0]
+ (~RT & ~RA & RB & TLI[1]*64) | # ...
+ (~RT & RA & ~RB & TLI[2]*64) |
+ (~RT & RA & RB & TLI[3]*64) |
+ ( RT & ~RA & ~RB & TLI[4]*64) |
+ ( RT & ~RA & RB & TLI[5]*64) |
+ ( RT & RA & ~RB & TLI[6]*64) | # ...
+ ( RT & RA & RB & TLI[7]*64) # 64 copies of TLI[7]
RT <- result
```
-For each integer value i, 0 to XLEN-1, do the following.
+For each integer value i, 0 to 63, do the following.
Let j be the value of the concatenation of the
contents of bit i of RT, bit i of RB, bit i of RT.
Functions," on page 968 for the equivalent function
evaluated by this instruction for any given value of TLI.
+Programmer's Note: this is a Read-Modify-Write instruction on RT.
+
Special registers altered:
```
# Condition Register Ternary Logic Immediate
-CRB-form
-
Add this section to Book I 2.5.1
+CRB-form
+
* `crternlogi BF, BFA, BFB, BFC, TLI, msk`
-| 0.5| 6-8 | 9-11 | 12-14 | 15-17 | 18-20 | 21-28 | 29-30 | 31 | Form |
-|----|-----|------|-------|-------|-------|-------|-------|-----|----------|
-| PO | BF | BFA | BFB | BFC | msk | TLI | XO | msk | CRB-Form |
+| 0.5|6.8 |9.10|11.13|14.15|16.18|19.25|26.30| 31| Form |
+|----|----|----|-----|-----|-----|-----|-----|---|----------|
+| NN | BF | msk|BFA | msk | BFB | TLI | XO |TLI| CRB-Form |
+
+| 0.5| 6-8 | 9-11 | 12-14 | 15-17 | 18-20 | 21-28 | 29-30 | 31 |
+|----|-----|------|-------|-------|-------|-------|-------|-----|
+| PO | BF | BFA | BFB | BFC | msk | TLI | XO | msk |
Pseudocode:
```
-a <- CR[4*BFA+32:4*BFA+35]
-b <- CR[4*BFB+32:4*BFB+35]
-c <- CR[4*BFC+32:4*BFC+35]
+a <- CR[4*BF+32:4*BFA+35]
+b <- CR[4*BFA+32:4*BFB+35]
+c <- CR[4*BFB+32:4*BFC+35]
+ternary <- (~a & ~b & ~c & TLI[0]*4) | # 4 copies of TLI[0]
+ (~a & ~b & c & TLI[1]*4) | # 4 copies of TLI[1]
+ (~a & b & ~c & TLI[2]*4) | # ...
+ (~a & b & c & TLI[3]*4) |
+ ( a & ~b & ~c & TLI[4]*4) |
+ ( a & ~b & c & TLI[5]*4) |
+ ( a & b & ~c & TLI[6]*4) | # ...
+ ( a & b & c & TLI[7]*4)) # 4 copies of TLI[7]
do i = 0 to 3
- idx <- a[i] || b[i] || c[i] # compute index from current bits
- result <- TLI[7 - idx] # subtract from 7 to index in LSB0 order
if msk[i] = 1 then
- CR[4*BF+32+i] <- result
+ CR[4*BF+32+i] <- ternary[i]
```
+For each integer value i, 0 to 3, do the following.
+
+ Let j be the value of the concatenation of the
+ contents of bit i of CR Field BF, bit i of CR Field BFA,
+ bit i of CR Field BFB.
+
+ If bit i of msk is set to 1 then the value of bit j of TLI
+ is placed into bit i of CR Field BF.
+
+ Otherwise, if bit i of msk is a zero then bit i of
+ CR Field BF is unchanged.
+
+ See Table 145, "xxeval(A, B, C, TLI) Equivalent
+ Functions," on page 968 for the equivalent function
+ evaluated by this instruction for any given value of TLI.
+
Special registers altered:
```