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

Subversion Repositories biquad

[/] [biquad/] [web_uploads/] [bqmain.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 root
/* ********************************************************************************* */
2
/*                                                                                   */
3
/*                      Main module for biquad filter                                */
4
/*                                                                                   */
5
/*  Author:  Chuck Cox (chuck100@home.com)                                           */
6
/*                                                                                   */
7
/* This filter core uses a wishbone interface for compatibility with other cores:    */
8
/*                                                                                   */
9
/* Wishbone general description:  16x5 register file                                 */
10
/* Supported cycles:  Slave Read/write, block read/write, RMW                        */
11
/* Data port size:  16 bit                                                           */
12
/* Data port granularity: 16 bit                                                     */
13
/* Data port maximum operand size:  16 bit                                           */
14
/*                                                                                   */
15
/*      Addr    register                                                             */
16
/*      ----    --------                                                             */
17
/*      0x0     Filter coefficient a11                                               */
18
/*      0x1     Filter coefficient a12                                               */
19
/*      0x2     Filter coefficient b10                                               */
20
/*      0x3     Filter coefficient b11                                               */
21
/*      0x4     Filter coefficient b12                                               */
22
/*                                                                                   */
23
/*  Filter coefficients need to be written as 16 bit twos complement fractional      */
24
/*  numbers.  For example:  0100_0000_0000_0001 = 2^-1 + 2^-15 = .500030517578125    */
25
/*                                                                                   */
26
/*  The equation for the filter implemented with this core is                        */
27
/*  y[n] = b10 * x[n] + b11 * x[n-1] + b12 * x[n-2] + a11 * y[n-1] + a12 * y[n-2]    */
28
/*                                                                                   */
29
/*  This biquad filter is parameterized.  If a filter with coefficients less than    */
30
/*  16 bits in length is selected via parameters then the most significant bits of   */
31
/*  the value written to the filter coefficient register shall be used (ie           */
32
/*  coefficients shall be truncated as required by parameter value COEFWIDTH).       */
33
/*                                                                                   */
34
/*  See comments in biquad module for more details on filtering algorthm.            */
35
/* ********************************************************************************* */
36
 
37
 
38
module bqmain
39
        (
40
        clk_i,          /* Wishbone clk */
41
        rst_i,          /* Wishbone asynchronous active high reset */
42
        we_i,           /* Wishbone write enable */
43
        stb_i,          /* Wishbone strobe */
44
        ack_o,          /* Wishbone ack */
45
        dat_i,          /* Wishbone input data */
46
        dat_o,          /* Wishbone output data */
47
        adr_i,          /* Wishbone address bus */
48
        dspclk,         /* DSP processing clock */
49
        nreset,         /* active low asynchronous reset for filter block */
50
        x,              /* input data for filter */
51
        valid,          /* data valid input */
52
        y               /* filter output data */
53
        );
54
 
55
parameter       DATAWIDTH = 8;
56
parameter       COEFWIDTH = 8;
57
 
58
input                   clk_i;
59
input                   rst_i;
60
input                   we_i;
61
input                   stb_i;
62
output                  ack_o;
63
input   [15:0]           dat_i;
64
output  [15:0]           dat_o;
65
input   [2:0]            adr_i;
66
input                   dspclk;
67
input                   nreset;
68
input   [DATAWIDTH-1:0]  x;
69
input                   valid;
70
output  [DATAWIDTH-1:0]  y;
71
 
72
 
73
wire    [15:0]   a11;
74
wire    [15:0]   a12;
75
wire    [15:0]   b10;
76
wire    [15:0]   b11;
77
wire    [15:0]   b12;
78
 
79
/* Filter module */
80
biquad biquadi
81
        (
82
        .clk(dspclk),                           /* clock */
83
        .nreset(nreset),                        /* active low reset */
84
        .x(x),                                  /* data input */
85
        .valid(valid),                          /* input data valid */
86
        .a11(a11[15:16-COEFWIDTH]),             /* filter pole coefficient */
87
        .a12(a12[15:16-COEFWIDTH]),             /* filter pole coefficient */
88
        .b10(b10[15:16-COEFWIDTH]),             /* filter zero coefficient */
89
        .b11(b11[15:16-COEFWIDTH]),             /* filter zero coefficient */
90
        .b12(b12[15:16-COEFWIDTH]),             /* filter zero coefficient */
91
        .yout(y)                                /* filter output */
92
        );
93
 
94
/* Wishbone interface module */
95
coefio coefioi
96
        (
97
        .clk_i(clk_i),
98
        .rst_i(rst_i),
99
        .we_i(we_i),
100
        .stb_i(stb_i),
101
        .ack_o(ack_o),
102
        .dat_i(dat_i),
103
        .dat_o(dat_o),
104
        .adr_i(adr_i),
105
        .a11(a11),
106
        .a12(a12),
107
        .b10(b10),
108
        .b11(b11),
109
        .b12(b12)
110
        );
111
 
112
 
113
 
114
endmodule

powered by: WebSVN 2.1.0

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