280 likes | 495 Views
GEL. slider param_definition( minVal, maxVal, increment, pageIncrement, paramName ) { statements } param_definition Parameter description that is printed on the slider object.
E N D
GEL 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; }
Homework (solution) 1. Functional Units a. How many can perform an ADD? Name them. b. Which support memory loads/stores? .M .S .D .L six; .L1, .L2, .D1, .D2, .S1, .S2 2. Memory Map a. How many external ranges exist on ‘C6201? Four
3. Conditional Code a. Which registers can be used as cond’l registers? b. Which instructions can be conditional? 4. Performance a. What is the 'C6711 instruction cycle time? b. How can the 'C6711 execute 1200 MIPs? A0, A1, A2, B0, B1, B2 All of them CLKOUT1 1200 MIPs = 8 instructions (units) x 150 MHz
5. Coding Problems a. Move contents of A0-->A1 MV .L1 A0, A1 or ADD .S1 A0, 0, A1 or MPY .M1 A0, 1, A1 (what’s the problem with this?)
5. Coding Problems a. Move contents of A0-->A1 b. Move contents of CSR-->A1 c. Clear register A5 MV .L1 A0, A1 or ADD .S1 A0, 0, A1 or MPY .M1 A0, 1, A1 (A0 can only be a 16-bit value) MVC CSR, A1 ZERO .S1 A5 or SUB .L1 A5, A5, A5 or MPY .M1 A5, 0, A5 or CLR .S1 A5, 0, 31, A5 or MVK .S1 0, A5 or XOR .L1 A5,A5,A5
5. Coding Problems (cont’d) d. A2 = A02 + A1 e. If (B1 0) then B2 = B5 * B6 f. A2 = A0 * A1 + 10 g. Load an unsigned constant (19ABCh) into register A6. MPY.M1 A0, A0, A2 ADD.L1 A2, A1, A2 [B1] MPY.M2 B5, B6, B2 MPY A0, A1, A2 ADD 10, A2, A2 value .equ 0x00019abc mvkl.s1 value,a6 mvkh.s1 value,a6 mvkl .s1 0x00019abc,a6mvkh .s1 0x00019abc,a6
x16 mem A7 10h mem1 5. Coding Problems (cont’d) h. Load A7 with contents of mem1 and post-increment the selected pointer. load_mem1:MVKL .S1 mem1, A6 MVKH .S1 mem1, A6 LDH .D1 *A6++, A7
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) {}
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) {}
Pointer is passed A-reg = &x[1]
Pointer Example The value in the A-Reg = 0x102
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) {}
Address of pointer is passed • A-Reg = &ptr (not value in pointer)
Example Double Pointer The value in the A-Reg = 0x100
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 }
Sine Wave Generation • Function Call to standard library • Taylor Series • Table Look-up • Algorithm
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
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.
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
Frequency as a function of step size and table size Table size stepsize
SineWave Oscillator • H(z) = 1 / (1-a*z^-1 + z^-2) • Y[n] = x[n] + a*y[n-1] + y[n-2]
SineWave Oscillator • Y[n] = A * sin (2PI * n * f / fs) • Variables • frequency – f • Sampling frequency – fs • Amplitude - A
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
Example • Let A=1, f=1476Hz, fs=8000hz • W= 2Pi*1476/8000=1.1592 • Sin(w)= 0.9165 • Cos(w)=0.8
Homework • Add to “sine.gel” an Amplitude Controlled slider • Verify it’s operation • Page 115 • Problem 1 • Problem 2