Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements }...

28
slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definition Parameter description that is printed on the slider object. minVal An integer constant specifying the value to be passed to the function when the position of the slider is at its lowest level. maxVal An integer constant specifying the value to be passed to the function when the position of the slider is at its highest level. increment An integer constant specifying the increment added to the value each time the slider is moved one position. pageIncrement An integer constant specifying the increment added to the value each time the slider is moved by one page. paramName Parameter definition that is used inside the function. The following example uses the slider keyword to add a volume control slider. menuitem "My Functions"; slider VolumeControl(0, 10, 1, 1, volume) { /* initialize the target variable with the parameter passed by the slider object. */ targVarVolume = volume; GEL

Transcript of Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements }...

Page 1: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

slider param_definition( minVal, maxVal, increment, pageIncrement, paramName )

{

statements

}

param_definition Parameter description that is printed on the slider object.

minVal An integer constant specifying the value to be passed to the function when the position of the slider is at its lowest level.

maxVal An integer constant specifying the value to be passed to the function when the position of the slider is at its highest level.

increment An integer constant specifying the increment added to the value each time the slider is moved one position.

pageIncrement An integer constant specifying the increment added to the value each time the slider is moved by one page.

paramName Parameter definition that is used inside the function.

The following example uses the slider keyword to add a volume control slider.

menuitem "My Functions";

slider VolumeControl(0, 10, 1, 1, volume)

{

/* initialize the target variable with the parameter passed

by the slider object. */

targVarVolume = volume;

}

GEL

Page 2: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Homework (solution)

1. Functional Units1. Functional Units

a. How many can perform an ADD? Name them.a. How many can perform an ADD? Name them.

b. Which support memory loads/stores?b. Which support memory loads/stores?

.M.M .S.S .D.D .L.L

six; .L1, .L2, .D1, .D2, .S1, .S2six; .L1, .L2, .D1, .D2, .S1, .S2

2. Memory Map2. Memory Map

a. How many a. How many externalexternal ranges exist on ‘C6201? ranges exist on ‘C6201?

FourFour

Page 3: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

3. Conditional Code

a.a. Which registers can be used as cond’l registers?Which registers can be used as cond’l registers?

b.b. Which instructions can be conditional?Which instructions can be conditional?

4. Performance4. Performancea.a. What is the 'C6711 instruction cycle time?What is the 'C6711 instruction cycle time?

b.b. How can the 'C6711 execute 1200 MIPs?How can the 'C6711 execute 1200 MIPs?

A0, A1, A2, B0, B1, B2A0, A1, A2, B0, B1, B2

All of themAll of them

CLKOUT1CLKOUT1

1200 MIPs = 8 instructions (units) x 150 MHz1200 MIPs = 8 instructions (units) x 150 MHz

Page 4: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

5. Coding Problems a. Move contents of A0-->A1a. Move contents of A0-->A1

MVMV .L1.L1 A0, A1A0, A1oror ADDADD .S1.S1 A0, 0, A1A0, 0, A1oror MPYMPY .M1.M1 A0, 1, A1A0, 1, A1(what’s the problem(what’s the problem

with this?)with this?)

Page 5: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

5. Coding Problems a. Move contents of A0-->A1a. Move contents of A0-->A1

b. Move contents of CSR-->A1b. Move contents of CSR-->A1

c. Clear register A5c. Clear register A5

MVMV .L1.L1 A0, A1A0, A1oror ADDADD .S1.S1 A0, 0, A1A0, 0, A1oror MPYMPY .M1.M1 A0, 1, A1A0, 1, A1

ZEROZERO .S1.S1 A5A5oror SUBSUB .L1.L1 A5, A5, A5A5, A5, A5oror MPYMPY .M1.M1 A5, 0, A5A5, 0, A5oror CLRCLR .S1.S1 A5, 0, 31, A5A5, 0, 31, A5oror MVKMVK .S1.S1 0, A50, A5oror XORXOR .L1.L1 A5,A5,A5A5,A5,A5

(A0 can only be a (A0 can only be a 16-bit value)16-bit value)

MVCMVC CSR, A1CSR, A1

Page 6: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

5. Coding Problems (cont’d) d. A2 = A0d. A2 = A022 + A1 + A1

e. If (B1 e. If (B1 0) then B2 = B5 * B6 0) then B2 = B5 * B6

f. A2 = A0 * A1 + 10f. A2 = A0 * A1 + 10

g. Load an g. Load an unsignedunsigned constant (19ABCh) into constant (19ABCh) into register A6. register A6.

MPY.M1MPY.M1 A0, A0, A2A0, A0, A2ADD.L1ADD.L1 A2, A1, A2A2, A1, A2

[B1] MPY.M2[B1] MPY.M2 B5, B6, B2B5, B6, B2

mvklmvkl .s1.s1 0x00019abc,a60x00019abc,a6mvkhmvkh .s1.s1 0x00019abc,a60x00019abc,a6

valuevalue .equ.equ 0x00019abc0x00019abc

mvkl.s1mvkl.s1 value,a6value,a6mvkh.s1mvkh.s1 value,a6value,a6

MPYMPY A0, A1, A2A0, A1, A2ADDADD 10, A2, A210, A2, A2

Page 7: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

5. Coding Problems (cont’d) h.h. Load A7 with contents of mem1 and Load A7 with contents of mem1 and

post-increment the selected pointer.post-increment the selected pointer.

x16 memx16 mem

mem1mem1 10h10h

A7A7

load_mem1:load_mem1: MVKLMVKL .S1.S1 mem1,mem1, A6A6

MVKHMVKH .S1.S1 mem1,mem1, A6A6

LDHLDH .D1.D1 *A6++,*A6++, A7A7

Page 8: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Pointers and Double Pointers• Pointers – a variable that holds an address

Short int *Ptr, x[3];

Ptr = &x[1];

Function (ptr);

Void Function ( short *ptr)

{}

Page 9: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Pointers and Double Pointers• Pointers – a variable that holds an address

Short int *Ptr, x[3];

Ptr = &x[1];

Function (ptr);

Void Function ( short *ptr)

{}

Page 10: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Pointer is passedA-reg = &x[1]

Page 11: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Pointer ExampleMemory

0x100 Ptr = 0x102

0x101 X[0]

0x102 X[1]

0x103 X[2]

The value in the A-Reg = 0x102

Page 12: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Pointer address is passed• Pointers – a variable that holds an address

Short int *Ptr, x[3];

Ptr = &x[1];

Function (&ptr);

Void Function ( short **ptr)

{}

Page 13: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Address of pointer is passed• A-Reg = &ptr (not value in pointer)

Page 14: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Example Double Pointer

Memory

0x100 Ptr = 0x102

0x101 X[0]

0x102 X[1]

0x103 X[2]

The value in the A-Reg = 0x100

Page 15: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Example

Void function (short *ptr)

{

*ptr = 2;

}

// This means memory location 0x102 has a 2 in that location

Void function (short **ptr)

{

**ptr = 2;

// This means memory location 0x102 has a 2 in that location

*ptr = 2;

// this means memory location 0x100 has a 2 in its location

}

Page 16: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Examples

Memory

0x100 Ptr = &x[1] = 0x102

0x101 X[0]

0x102 X[1] = 2

0x103 X[2]

Memory

0x100 Ptr = &x[1] = 0x102

0x101 X[0]

0x102 X[1] = 2

Memory

0x100 2

0x101 X[0]

0x102 X[1]

Page 17: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Sine Wave Generation• Function Call to standard library

• Taylor Series

• Table Look-up

• Algorithm

Page 18: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Table LookUp

• Create a table of values for 1 cycle of a sine wave

• Create a function that takes table values and places them in an output array

• The higher the number of table entries, the higher the precision of the sine wave

Page 19: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Table LookUp

• A Table of 128 values from 0 to 2Pi is– Table[I] = sin (2*PI*I/128)

• Let Sampling Rate = 8000 hz, (Period=125 usec)

• If OutputArray[I] = Table[I]– 1cycle / (125usec*128) = 62.5 hz.

• If OutputArray[I] = Table[2*I]– 1 cycle / (125usec*64) = 125 hz.

Page 20: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Continued

• If OutputArray[I] = Table[128*I]– 1 cycle / (125usec * 1) = 8000 hz.– OutputArray[I] = 0 (DC)

• Resolution = 62 hz.

• For Higher resolution increase Table Size

Page 21: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Frequency as a function of step size and table size

64 128 512 1024

1 125 hz 62.5 hz 15.625 hz 7.8125 hz

2 250 hz 125 hz 31.25 hz 15.625 hz

32 4000 hz 2000 hz 500 hz 250 hz

128 x 8000 hz 2000 hz 1000 hz

stepsize

Table size

Page 22: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

SineWave Oscillator

• H(z) = 1 / (1-a*z^-1 + z^-2)

• Y[n] = x[n] + a*y[n-1] + y[n-2]

Page 23: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

SineWave Oscillator• Y[n] = A * sin (2PI * n * f / fs)

• Variables – frequency – f

– Sampling frequency – fs

– Amplitude - A

Page 24: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Z-Transform

21)cos(21

1)sin(][

211

1

2][

11

111

12

][

0 2][

/20

)/2sin(][

zz

zAzY

zzjeje

zjeje

jAzY

zjezjejAzY

nnz

j

jnwejneAzY

sffletn

nzsfnfAzX

Page 25: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

SineWave Oscillator

• Y[n] is produced by treating Y[z] as a product of H(z)X(z), where X(z) = 1

• X[n] is an Impulse Function, x[0]=1,

• 0 elsewhere

• Now find the difference equation

][][ nnx

Page 26: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

SineWave Oscillator

]2[]1[)cos(2]1[)sin(][

]1[)sin(]2[]1[)cos(2][

][][ 1)sin(21)cos(21

nynynxAny

nxAnynyny

zXzY zAzz

Page 27: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Example• Let A=1, f=1476Hz, fs=8000hz

• W= 2Pi*1476/8000=1.1592

• Sin(w)= 0.9165

• Cos(w)=0.8

Page 28: Slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definitionParameter description that is printed on.

Homework

• Add to “sine.gel” an Amplitude Controlled slider

• Verify it’s operation

• Page 115 – Problem 1– Problem 2