SCAMP-5 Kernel Instructions and Macros

Revision 1.0.1

Symbols

The following table explains the symbols used in this document forreferringvarious types of registers, operands and other components.

Symbol / Meaning
i, j, k / AnalogRegisters: A - F, NEWS
u, v, w, x, y, z / Analog Operand: A - F, NEWS, PIX, IN, SOUTH, EAST, NORTH, WEST
I, J, K / Digital Registers: R0 – R12
U, V, W, X, Y, Z / Digital Operand: R0 – R12, FLAG, SELECT
dir / Neighbour Directions: south, east, north, west
n / Constant 8-bit Integer Value: [0,255]
∆ / AnalogTransfer Error, ≈ (signed ADC)20
λ / AnalogReset Level, ≈ (signed ADC)0
α / PIXReset Level, ≈ (signed ADC)127
[#] / AnalogConvolution Matrix of 3-by-3 or 5-by-5
IMG / Half-range Image, value range:(signed ADC)[0,127]
IMG2 / Full-range Image, value range: (signed ADC)[-128,127]

Notes

  1. Analog Neighbour Macros: these operations are affected by the FLAG status of both the PE itself and the neighbour PE.
  2. Digital Neighbour Instructions: neighbours to be accessed are controlled by R1 – R4.
  3. Digital Propagation Instructions: the mask register is always R0, propagations occurs only in R12. The speed of this propagation varies among the chips.
  4. Analog Division Operations: these operations have some extra errors. Use the macro version is usually needed.
  5. Non-analogInstructions: if any of these instructions is the last instruction in a kernel, an extra layer of noise will keep accumulatingon all analog registers while the non-kernel program afterwards isexecuting.If such noiseaccumulation is observed and problematic, verify the last instructions inall kernelsahead of any long non-kernel programs (e.g. frametrigger, time wait, io wait).
  6. Digital Instructions: if the problem in Note 5 is observed for these instructions, put “vs_scamp5_set_dac (4095);” after finished any analog inputrelated kernels.
  7. Blur Instructions: R1 and R2 must be set to ‘1’ to enable the blur.

Kernel Instructions

Instructions are the atomic operations that can be executed inside SCAMP-5 kernels. For all Kernel Instructions, all of the operands must be different.

Instruction / Functionality / Notes
rpix() / PIX = α, FLAG = 1 / *5
res(i) / i= λ
res(i,j) / [i,j] = λ
bus(i,x) / i=-x + ∆
bus(i,x,y) / i = -(x + y) + ∆
bus(i,x,y,z) / i = -(x + y + z) + ∆
bus(i,x,y,z,w) / i = -(x + y + z + w) + ∆
bus2(i,j,x) / [i,j] = -0.5*x + ∆ / *4
bus2(i,j,x,y) / [i,j] = -0.5*(x + y) + ∆ / *4
bus3(i,j,k,x) / [i,j,k] = -0.5*x + ∆ / *4
blur(i,x) / i = -gauss[#]*x + ∆, 3-by-3 kernel / *7
blurh(i,x) / i = -gauss[#]*x + ∆, 1-by-3 kernel / *7
blurv(i,x) / i = -gauss[#]*x + ∆, 3-by-1 kernel / *7
sq(x) / NEWS = -x^2 + ∆ / Inaccurate
sq(x,y) / NEWS = -(x + y)^2 + ∆ / Inaccurate
where(x) / FLAG = IF x > λ
where(x,y) / FLAG = IF (x + y)λ
where(x,y,z) / FLAG = IF (x + y + z) λ
all() / FLAG = 1
WHERE(X) / FLAG = X
WHERE(X,Y) / FLAG = X OR Y
WHERE(X,Y,Z) / FLAG = X OR Y OR Z
ALL() / FLAG = 1
SET(X) / X = 1 / *6
SET(X,Y) / [X,Y] = 1 / *6
SET(X,Y,Z) / [X,Y,Z] = 1 / *6
SET(X,Y,Z,W) / [X,Y,Z,W] = 1 / *6
CLR(X) / X = 0 / *6
CLR(X,Y) / [X,Y] = 0 / *6
CLR(X,Y,Z) / [X,Y,Z] = 0 / *6
CLR(X,Y,Z,W) / [X,Y,Z,W] = 0 / *6
MOV(I,X) / I = X / *6
OR(I,X,Y) / I = X OR Y / *6
OR(I,X,Y,Z) / I = X OR Y OR Z / *6
OR(I,X,Y,Z,W) / I = X OR Y OR Z OR W / *6
NOT(I,X) / I = NOT X / *6
NOR(I,X,Y) / I = NOT (X OR Y) / *6
NOR(I,X,Y,Z) / I = NOT (X OR Y OR Z) / *6
NOR(I,X,Y,Z,W) / I = NOT (X OR Y OR Z OR W) / *6
DNEWS0(I,X) / OR neighbours (border as ‘0’) / *2
DNEWS1(I,X) / OR neighbours (border as ‘1’) / *2
PROP0() / Propagate ‘1’ (border as ‘0’) / *3
PROP1() / Propagate ‘1’ (border as ‘1’) / *3

Kernel Macros

Macros are combinations of instructions to make up some operations that are more user-friendly. For these macros, specific rules apply in terms of operand usage. In general, the first operand and the last operand cannot be the same register. And for macros that write to all operands, those operands must be different registers.

Macro / Functionality / Notes
respix() / PIX = α, FLAG = 1
respix(i) / [i,PIX]= α, FLAG = 1
getpix(i,x) / i = IMG, when x == α
getpix(i,j,x) / i = IMG2, j = IMG, when x == α
get_image(i) / i = IMG, respix()
get_image(i,j) / i = IMG2, j = IMG, respix()
mov(i,x) / i = x
mov(i,x,dir) / i = x_dir / *1
add(i,x,y) / i = x + y
add(i,x,y,z) / i = x + y + z
sub(i,x,y) / i = x - y
sub(i,x,dir,y) / i = x_dir - y / *1
neg(i,x) / i = -x
abs(i,x) / i = |x|, FLAG = 1
div(i,j,x) / i = 0.5*x, j = -0.5*x
diva(i,j,k) / i = 0.5*i, j = -0.5*i, k = -0.5*i + ∆
gauss(i,n) / i = gauss[#]*i, n iterations / n must be a constant
gauss(i,x,n) / i = gauss[#]*x, n iterations / n must be a constant
diffuse(i,x,n) / i = diffuse[#]*i, n iterations / a heavy diffusion
NOT(I) / I = NOT I / *6
OR(I,X) / I = I OR X / *6
NOR(I,X) / I = I NOR X / *6
AND(I,X,Y) / I = X AND Y / *6
NAND(I,X,Y) / I = X NAND Y / *6
IMP(I,X,Y) / I = X IMP Y / *6
NIMP(I,X,Y) / I = X NIMP Y / *6
XOR(I,J,X) / I = J XOR X / *6
MUX(I,W,X,Y) / I = W? X:Y / *6
CLR_IF(I,W) / I = W? 0:I / CLR only when W is 1
REFRESH(I) / I = I / DRAM refresh
DNEWS(I,X,dir,n) / I = X_dir, boundary = n / combine dir using |