Getting Started with ADSP-BF537 EZ-KIT Lite
1-19
Programming ADSP-BF537 EZ-KIT Lite with Vi+
Listing 1-1. Exercise 1, Part 1
/*
* Getting Started With the ADSP-BF537 EZ-KIT Lite
* Part 1, Exercise 1
*/
#include <stdlib.h>
#define NUM_ITERATIONS
1
#define ARRAY_LENGTH
128
/* Initialize two arrays to the same set of random values */
void randomize_arrays ( int *v1, int *v2, unsigned int length )
{
unsigned int i;
for ( i = 0; i < length; ++i )
{
v1[ i ] = v2[ i ] = rand () % 1024;
}
}
/* A standard bubble sort algorithm, O(n^2) */
void bubble_sort ( int *v, unsigned int length )
{
unsigned int i, j;
for ( i = 0; i < length - 1; ++i )
{
for ( j = i + 1; j < length; ++j )
{
if ( v[ i ] > v[ j ] )
{
int temp = v[ i ];
v[ i ] = v[ j ];
v[ j ] = temp;
}
}
}
}
/* A standard quick sort algorithm, O(n*log(n)) */
void quick_sort ( int *v, unsigned int p, unsigned int r )
{
if ( p < r )
www.BDTIC.com/ADI