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

Subversion Repositories wdsp

[/] [wdsp/] [trunk/] [sw/] [FFT1024/] [FFT.c] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 parrado
/*FFT-Core test*/
2
 
3
#include "../support/support.h"
4
#include "../support/board.h"
5
#include "../support/uart.h"
6
 
7
#include "../support/spr_defs.h"
8
 
9
#define FFT_BASE 0x94000000
10
#define FFT_CONTROL 0
11
#define FFT_DATA 4
12
#define FFT_STATUS 8
13
#define FFT_MEMORY 12
14
 
15
 
16
void uart_print_str(char *);
17
void uart_print_long(unsigned long);
18
 
19
// Dummy or32 except vectors
20
void buserr_except(){}
21
void dpf_except(){}
22
void ipf_except(){}
23
void lpint_except(){}
24
void align_except(){}
25
void illegal_except(){}
26
/*void hpint_except(){
27
 
28
}*/
29
void dtlbmiss_except(){}
30
void itlbmiss_except(){}
31
void range_except(){}
32
void syscall_except(){}
33
void res1_except(){}
34
void trap_except(){}
35
void res2_except(){}
36
 
37
 
38
void uart_interrupt()
39
{
40
    char lala;
41
    unsigned char interrupt_id;
42
    interrupt_id = REG8(UART_BASE + UART_IIR);
43
    if ( interrupt_id & UART_IIR_RDI )
44
    {
45
        lala = uart_getc();
46
        uart_putc((lala>>1)&0xff);
47
 
48
 
49
 }
50
}
51
 
52
 
53
void uart_print_str(char *p)
54
{
55
        while(*p != 0) {
56
                uart_putc(*p);
57
                p++;
58
        }
59
}
60
 
61
void uart_print_long(unsigned long ul)
62
{
63
  int i;
64
  char c;
65
 
66
 
67
  uart_print_str("0x");
68
  for(i=0; i<8; i++) {
69
 
70
  c = (char) (ul>>((7-i)*4)) & 0xf;
71
  if(c >= 0x0 && c<=0x9)
72
    c += '0';
73
  else
74
    c += 'a' - 10;
75
  uart_putc(c);
76
  }
77
 
78
}
79
 
80
void uart_print_short(unsigned long ul)
81
{
82
  int i;
83
  char c;
84
  char flag=0;
85
 
86
 
87
  uart_print_str("0x");
88
  for(i=0; i<8; i++) {
89
 
90
  c = (char) (ul>>((7-i)*4)) & 0xf;
91
  if(c >= 0x0 && c<=0x9)
92
    c += '0';
93
  else
94
    c += 'a' - 10;
95
  if ((c != '0') || (i==7))
96
    flag=1;
97
  if(flag)
98
    uart_putc(c);
99
  }
100
 
101
}
102
 
103
 
104
 
105
char str[100];
106
 
107
 
108
int main()
109
{
110
int c,k,j,r_in,r_out,DAT0,DAT1,DAT2;
111
        uart_init();
112
 
113
        int_init();
114
        int_add(UART_IRQ,&uart_interrupt);
115
 
116
        uart_print_str("FFT-Test\n");
117
 
118
 
119
         /*clears status register and FFT-core*/
120
        REG32(FFT_BASE+FFT_CONTROL)=1;
121
 
122
        /*Test data for FFT*/
123
        /*MATLAB command: int16((fft([-1100 1024 zeros(1,1022)])/16)).' */
124
        DAT0=-1100;  DAT1=1024; DAT2=0;
125
 
126
        /*real part in MSW, imaginary part (zero) in LSW*/
127
        REG32(FFT_BASE+FFT_DATA)=(DAT0)<<16;
128
        REG32(FFT_BASE+FFT_DATA)=(DAT1)<<16;
129
 
130
        /*Pipeline fill*/
131
        for(k=1;k<=2046;k=k+1) {
132
 
133
        REG32(FFT_BASE+FFT_DATA)=(DAT2);
134
        };
135
 
136
 
137
        /*Waits for FFT core*/
138
        while(REG32(FFT_BASE+FFT_STATUS)==0) ;
139
 
140
 
141
        /*reads FFT results */
142
        for(k=0;k<=(1023);k++) {
143
            r_out=REG32(FFT_BASE+FFT_MEMORY+4*k);
144
 
145
           /*prints real part*/
146
           int10_to_str(r_out>>16,str,-10);
147
           uart_print_str(str);
148
 
149
 
150
           /*prints imaginary part*/
151
           uart_putc('+');
152
           int10_to_str((r_out<<16)>>16,str,-10);
153
           uart_print_str(str);
154
           uart_print_str("*j");
155
 
156
           uart_putc(' ');
157
 
158
        };
159
 
160
 
161
 
162
        report(0xdeaddead);
163
        or32_exit(0);
164
}

powered by: WebSVN 2.1.0

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