31.4.2.6 Carry
The carry output from most instructions can be observed through the CARRY bit in CRYPTO_DSTATUS. Shift-instructions set CARRY
to the value that is shifted out of the register, addition and multiplication set it on register overflow, and subtraction sets it on borrow, e.g.
underflow.
In addition to generating carry information, some instructions also use the current value of CARRY. ADDC, SUBC, SHLC and SHRC all
use carry to generate the result. For all of these instructions, carry allows a program to chain instructions together to operate on bigger
numbers than allowed by CRYPTO. For example, by chaining first an ADD, and then an ADDC which uses the carry from the ADD
operation, two 512-bit numbers can be added. By chaining more instructions, even larger numbers can be manipulated.
Other uses of CARRY include observation. To check if a register is 0, one can subtract 1 using the DEC instruction, and check if goes
negative by checking the CARRY bit. CARRY can be set manually and in CRYPTO programs using the CSET and CCLR instructions,
which set and clear the CARRY bit.
The MULC instruction does not use CARRY like the other carry instructions (i.e., instructions ending in 'C' such as 'ADDC'), but rather
preserves the old contents of the multiplication register.
31.4.3 Repeated Sequence
To maximize efficiency, it is desirable to be able to run a set of instructions over multiple blocks of data autonomously. To repeat a se-
quence over a larger set of data, set LENGTHA in CRYPTO_SEQCTRL to the number of bytes in the set, and BLOCKSIZE to the size
of the blocks in the set. The sequence will then be repeated N times, where N is LENGTHA / BLOCKSIZE if LENGTHA is a multiple of
BLOCKSIZE, or ceiling( LENGTHA / BLOCKSIZE ) if not. In the latter case, data written by DMA or received from BUFC will be zero-
padded up to BLOCKSIZE if it is written to a register which has a size equal to BLOCKSIZE. One notable exception is when LENGTHA
is 0. In this case the sequence will still execute once, but the block transfer instructions will not execute.
Note:
If DMAxRSEL in CRYPTO_CTRL selects a register that is smaller than the specified blocksize, DATATODMAx/DMAxTODATA
instructions will not use the full blocksize, but will only transfer enough data to empty/fill the register once. For example, if BLOCKSIZE
is set to 64B and DMA0RSEL=DDATA0, the instruction DATATODMA0 will only read 32B instead of 64B. The processing of
LENGTHA/B will continue as if all 64B had been transferred.
A repeated sequence can also be made do slightly different operations on different parts of the data set. A sequence can be divided
into two parts; part A, and part B. By configuring LENGTHA in CRYPTO_SEQCTRL to the length of part A, and LENGTHB in CRYP-
TO_SEQCTRLB to the length of part B, CRYPTO will first run iterations over part A, knowing it is A, and then part B, knowing it is part
B. By using the conditional instructions listed in
Table 31.3 Conditional Instructions on page 1033
, a program can execute different in-
structions depending on whether it is in part A or part B.
Reference Manual
CRYPTO - Crypto Accelerator
silabs.com
| Building a more connected world.
Rev. 1.1 | 1034