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

Subversion Repositories wdsp

[/] [wdsp/] [trunk/] [sw/] [IIR6/] [IIR6.c] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 parrado
#include "../support/support.h"
2
#include "../support/board.h"
3
#include "../support/uart.h"
4
#include "coefs_sos.h"
5
 
6
#include "../support/spr_defs.h"
7
 
8
#define IIR_BASE 0x9d000000
9
#define IIR_CONTROL 0
10
#define IIR_DATA 4
11
#define IIR_STATUS 8
12
#define IIR_NSECTT 12
13
#define IIR_GAIN 16
14
#define IIR_COEFF 20
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
//        uart_putc('A');
50
 
51
 
52
//uart_print_short(lala);
53
 //       uart_putc('\n');
54
    }
55
}
56
 
57
 
58
void uart_print_str(char *p)
59
{
60
        while(*p != 0) {
61
                uart_putc(*p);
62
                p++;
63
        }
64
}
65
 
66
void uart_print_long(unsigned long ul)
67
{
68
  int i;
69
  char c;
70
 
71
 
72
  uart_print_str("0x");
73
  for(i=0; i<8; i++) {
74
 
75
  c = (char) (ul>>((7-i)*4)) & 0xf;
76
  if(c >= 0x0 && c<=0x9)
77
    c += '0';
78
  else
79
    c += 'a' - 10;
80
  uart_putc(c);
81
  }
82
 
83
}
84
 
85
void uart_print_short(unsigned long ul)
86
{
87
  int i;
88
  char c;
89
  char flag=0;
90
 
91
 
92
  uart_print_str("0x");
93
  for(i=0; i<8; i++) {
94
 
95
  c = (char) (ul>>((7-i)*4)) & 0xf;
96
  if(c >= 0x0 && c<=0x9)
97
    c += '0';
98
  else
99
    c += 'a' - 10;
100
  if ((c != '0') || (i==7))
101
    flag=1;
102
  if(flag)
103
    uart_putc(c);
104
  }
105
 
106
}
107
 
108
 
109
char str[100];
110
 
111
int main()
112
{
113
int c,k,j,r_in,r_out;
114
        uart_init();
115
 
116
        int_init();
117
        int_add(UART_IRQ,&uart_interrupt);
118
 
119
 
120
//Nsections-1
121
                REG32(IIR_BASE+IIR_NSECTT)=NSECT-1;
122
 
123
//Gain
124
                REG32(IIR_BASE+IIR_GAIN)=(int)gk;
125
 
126
//Coef Write
127
    for (k=0;k<(6*NSECT);k++){
128
                REG32(IIR_BASE+IIR_COEFF+(k*4))=(int)SOS[k];
129
                r_out=REG32(IIR_BASE+IIR_COEFF+(k*4));
130 11 parrado
int10_to_str(r_out,str,-10);
131
                uart_print_str(str);
132
                        uart_putc(' ');
133 5 parrado
 
134 11 parrado
 
135 5 parrado
    }
136
 
137
uart_print_str("IIR filter impulse response :\n ");
138
 
139
                //Writes kronecker delta
140
 
141
                REG32(IIR_BASE+IIR_DATA)=(int)(32767);
142
                REG32(IIR_BASE+IIR_CONTROL)=1;//Start
143
                while(REG32(IIR_BASE+IIR_STATUS)==0) ;
144
                REG32(IIR_BASE+IIR_STATUS)=1;
145
 
146
 
147 11 parrado
 
148 5 parrado
//Reads filter output
149
r_out=REG32(IIR_BASE+IIR_DATA);
150
                int10_to_str(r_out,str,-10);
151
                uart_print_str(str);
152
                        uart_putc(' ');
153
 
154
 
155
     //Writes 999 zeros
156
    for (k=0;k<((1000)-1);k++){
157
                REG32(IIR_BASE+IIR_DATA)=0;
158
                REG32(IIR_BASE+IIR_CONTROL)=1;//Start
159
 
160
                //Waits for filtering 
161
                while(REG32(IIR_BASE+IIR_STATUS)==0) ;
162
                REG32(IIR_BASE+IIR_STATUS)=1;
163
 
164
//Reads filter output
165
r_out=REG32(IIR_BASE+IIR_DATA);
166
                int10_to_str(r_out,str,-10);
167
                uart_print_str(str);
168
                        uart_putc(' ');
169
 
170
        }
171
 
172
        report(0xdeaddead);
173
        or32_exit(0);
174
}

powered by: WebSVN 2.1.0

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