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

Subversion Repositories heap_sorter

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

powered by: WebSVN 2.1.0

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