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] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 wzab
#include <stdlib.h>
2
#include <stdio.h>
3
#include <string.h>
4
#include <time.h>
5
#include "wz_hsort.h"
6
 
7
/* How we assign memory address to each level?
8
   N - level
9
   NM - max level
10
   SORT_LEN = 2^(NM+1)
11
   base address
12
   How we calculate the address of the node?
13
   2^N - base address which is also the "LEFT" address
14
   2^N + 2^(N-1) - "RIGHT" address
15
   How we create the "offset"? - we simply collect the bits from
16
   the previous "left<->right" decisions.
17
 
18
 */
19
 
20
 
21
 
22
int main()
23
{
24
        int i,j;
25
        for(i=0;i<NM;i++)
26
        for(j=0;j<SORT_LEN;j++) {
27
                sort_mem[i][j].key=0;
28
        }
29
        FILE * fout=fopen("dta.out","w");
30
        sort_data r;
31
        srand(time(NULL));
32
        //memset(sort_mem,0,sizeof(sort_mem));
33
        for(i=0;i<TEST_LEN;i++) {
34
                sort_data vin;
35
                strcpy(vin.payload,"ak");
36
                vin.key=i+1+rand()/(RAND_MAX/MAX_DEL);
37
                r=heap_sort(vin);
38
                //for(j=0;j<SORT_LEN;j++) printf("%d:%d,",j,sort_mem[j]);
39
                /* {
40
                        int i,j;
41
                        for(j=0;j<SORT_LEN;j++) {
42
                                printf("%2.2d,",sort_mem[j].key);
43
                        }
44
                        printf("\n");
45
                }*/
46
                printf("in=%d out=%d\n\n",vin.key,r.key);
47
                fprintf(fout,"%d\n",r.key);
48
        }
49
        fclose(fout);
50
}
51
 

powered by: WebSVN 2.1.0

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