SCAMP-5c Vision System  1.0.0
An image sensor with a parallel processor on focal plane
Data Structures | Functions
ipu_instructions.h File Reference

Go to the source code of this file.

Data Structures

class  reg
 operand of this type can only be an ipu register More...
 
class  r_int
 operand of this type can be either an ipu register or a constant integer of range [0,255] or [-128,127] More...
 
class  r_int16
 similar to r_int, but it can be assigned with a constant integer of range [0,65535] More...
 
class  port
 operand of this type can only be a port address More...
 

Functions

 _mov (reg d, r_int s)
 move data in to a register More...
 
 _or (reg d, r_int s)
 bitwise OR operation More...
 
 _and (reg d, r_int s)
 bitwise AND operation More...
 
 _add (reg d, r_int s)
 add two data ( d = d + s ) More...
 
 _sub (reg d, r_int s)
 subtract two data ( d = d - s ) More...
 
 _jump (label l)
 jump the program to a labeled position More...
 
 _jump (condition f, label l)
 jump the program conditionally to a labeled position More...
 
 ipu_delay_50us_x (r_int t)
 time delay with a resolution of 50 us More...
 
 ipu_wait_frame_trigger ()
 wait until a frame trigger is detected More...
 
 ipu_pixel_set (dreg b1, r_int x, r_int y)
 set one pixel in a DREG plane More...
 
dreg ipu_pixel_select (r_int x, r_int y, r_int mx, r_int my)
 set all pixel a DREG plane of which their coordinates match the rules More...
 
 ipu_pixel_filter (dreg b1, r_int x, r_int y, r_int mx, r_int my)
 similar to ipu_pixel_select, but the result will be ANDed with the DREG More...
 
reg ipu_global_sum (areg a, r_int k)
 sum all pixels in a AREG plane, then sample More...
 

Detailed Description

Author
Jianing Chen

Function Documentation

_mov ( reg  d,
r_int  s 
)

move data in to a register

Parameters
dthe destinated register
sthe data to be moved

Example Usage: _mov(s0,0) _mov(s0,15) _mov(s3,s4)

Flagging:

set Z if s is equal to the data originally stored in d

_or ( reg  d,
r_int  s 
)

bitwise OR operation

Parameters
dthe destinated register, LHS of the OR operation
sRHS of the OR operation

Example Usage: _or(s0,128) _or(s0,s1)

Flagging: Z.

_and ( reg  d,
r_int  s 
)

bitwise AND operation

Parameters
dthe destinated register, LHS of the AND operation
sRHS of the AND operation

Example Usage: _and(s0,15) _and(s0,s1)

Flagging: Z.

_add ( reg  d,
r_int  s 
)

add two data ( d = d + s )

Parameters
dthe destinated register, LHS of the addition
sRHS of the addition

Example Usage: _add(s0,10) _add(s1,s2)

Flagging: Z, C.

_sub ( reg  d,
r_int  s 
)

subtract two data ( d = d - s )

Parameters
dthe destinated register, LHS of the subtraction
sRHS of the subtraction

Example Usage: _sub(s0,1) _sub(s1,s2)

Flagging: Z, C.

_jump ( label  l)

jump the program to a labeled position

Parameters
la labeled position in the program

Example Usage:

1 #start:
2 
3 ...
4 
5 _jump(#start)
_jump ( condition  f,
label  l 
)

jump the program conditionally to a labeled position

Parameters
fthe condition, can be either of c,nc,z,nz
la labeled position in the program

For the condition part, the Z or C flag produced by previous instructions will be checked.

Example Usage:

The following structure is a loop iterating 10 times:

1 ...
2 
3 _mov(s0,10)
4 #loop_begin:
5 
6 ...//loop body
7 
8 _sub(s0,1)
9 _jump(nz,#loop_begin)
10 
11 ...
ipu_delay_50us_x ( r_int  t)

time delay with a resolution of 50 us

Parameters
[in]t(t*50) is the number of micro seconds delayed

Example Usage:

Take a image with an exposure time of 500 us:

1 rpix
2 ipu_delay_50us_x(10)// wait for 500 us
3 rpix(B,C)
ipu_wait_frame_trigger ( )

wait until a frame trigger is detected

The frame trigger signal is a series of pulse with a frequency specified by host_set_frame_rate.

The following structure provide a frame of which the exposure time is the interval between two frame triggers:

1 ipu.wait_frame_trigger
2 rpix
3 ipu.wait_frame_trigger
4 rpix(B,C)
ipu_pixel_set ( dreg  b1,
r_int  x,
r_int  y 
)

set one pixel in a DREG plane

Parameters
[in,out]b1the DREG plane
[in]xx coordinate of the pixel
[in]yy coordinate of the pixel

Example Usage:

Make (30,50) and (50,50) in R5 DREG plane to be 1:

1 R5 = 0 // do not forget to clear the plane before putting new points
2 ipu.pixel_set(R5,30,50)
3 ipu.pixel_set(R5,50,50)
dreg ipu_pixel_select ( r_int  x,
r_int  y,
r_int  mx,
r_int  my 
)

set all pixel a DREG plane of which their coordinates match the rules

Parameters
[in]xx coordinate match of the pixels
[in]yy coordinate match of the pixels
[in]mxx coordinate mask of the pixels
[in]myy coordinate mask of the pixels
Returns
the result in DREG plane

Example Usage:

For R5 DREG plane, make all pixel with x and y coordinates in in the format "xxxxx101" (binary form) to be 1:

1 R5 = ipu.pixel_select(5,5,248,248)

Note:

Binary form of 248 is 11111000, which is used as the coordinate mask.

Binary form of 5 is 00000101. which is used as the matching part.

ipu_pixel_filter ( dreg  b1,
r_int  x,
r_int  y,
r_int  mx,
r_int  my 
)

similar to ipu_pixel_select, but the result will be ANDed with the DREG

Parameters
[in]b1the selection result will be ANDed with this DREG
[in]xx coordinate match of the pixels
[in]yy coordinate match of the pixels
[in]mxx coordinate mask of the pixels
[in]myy coordinate mask of the pixels
Returns
the result in DREG plane

Example Usage:

Make a rectangular with bottom left corner on (64,64) and top right corner (127,127) in R5:

1 R5 = 1 // becuase the result will be ANDed so the initial value should be 1
2 ipu.pixel_filter(R5,0,0,191,191)
3 ipu.pixel_filter(R5,128,128,127,127)

Notice that it is very difficult to make up these parameters in mind. Instead, it is more feasible to try some combinations using a program like Example 10: DREG Selecting.

Another example:

Compose a rectangular of size 128x128 in the center of R5 DREG plane:

1 R5 = 0
2 
3 R6 = 1
4 ipu.pixel_filter(R6,0,0,191,191)
5 ipu.pixel_filter(R6,128,128,127,127)
6 R7 = R5
7 R5 = or(R6,R7)
8 
9 R6 = 1
10 ipu.pixel_filter(R6,64,0,191,191)
11 ipu.pixel_filter(R6,0,128,127,127)
12 R7 = R5
13 R5 = or(R6,R7)
14 
15 R6 = 1
16 ipu.pixel_filter(R6,64,64,191,191)
17 ipu.pixel_filter(R6,0,0,127,127)
18 R7 = R5
19 R5 = or(R6,R7)
20 
21 R6 = 1
22 ipu.pixel_filter(R6,0,64,191,191)
23 ipu.pixel_filter(R6,128,0,127,127)
24 R7 = R5
25 R5 = or(R6,R7)
reg ipu_global_sum ( areg  a,
r_int  k 
)

sum all pixels in a AREG plane, then sample

Parameters
[in]athe AREG plane
[in]kthe ADC gain setting
Returns
the sampling result

The ADC gain value need to be determined through testing.

Example 11: Analogue Regional Summation demonstrates how to sum only a specific region in a AREG plane.

Example Usage:

Sum all pixels in A with a ADC gain of 15, store the sampling result in s0:

1 s0 = ipu.global_sum(A,15)