OpenCores
URL https://opencores.org/ocsvn/heap_sorter/heap_sorter/trunk

Subversion Repositories heap_sorter

[/] [heap_sorter/] [trunk/] [HLS_implementation/] [Fig6/] [wz_hsort_tb.cc] - Rev 8

Compare with Previous | Blame | View Log

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "wz_hsort.h"
 
/* How we assign memory address to each level?
   N - level
   NM - max level
   SORT_LEN = 2^(NM+1)
   base address 
   How we calculate the address of the node?
   2^N - base address which is also the "LEFT" address
   2^N + 2^(N-1) - "RIGHT" address
   How we create the "offset"? - we simply collect the bits from
   the previous "left<->right" decisions.
 
 */
 
 
 
int main()
{
	int i,j;
	for(i=0;i<NM;i++)
	for(j=0;j<SORT_LEN;j++) {
		sort_mem[i][j].key=0;
	}
	FILE * fout=fopen("dta.out","w");
	sort_data r;
        srand(time(NULL));
	//memset(sort_mem,0,sizeof(sort_mem));
	for(i=0;i<TEST_LEN;i++) {
		sort_data vin;
		strcpy(vin.payload,"ak");
		vin.key=i+1+rand()/(RAND_MAX/MAX_DEL);
		r=heap_sort(vin);
		//for(j=0;j<SORT_LEN;j++) printf("%d:%d,",j,sort_mem[j]);
		/* {
			int i,j;
			for(j=0;j<SORT_LEN;j++) {
				printf("%2.2d,",sort_mem[j].key);
			}
			printf("\n");
		}*/
		printf("in=%d out=%d\n\n",vin.key,r.key);
		fprintf(fout,"%d\n",r.key);
	}
	fclose(fout);
}
 
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.