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

Subversion Repositories robust_fir

[/] [robust_fir/] [trunk/] [src/] [base/] [fir_serial.v] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 eyalhoc
<##//////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Author: Eyal Hochberg                                      ////
4
////          eyal@provartec.com                                 ////
5
////                                                             ////
6
////  Downloaded from: http://www.opencores.org                  ////
7
/////////////////////////////////////////////////////////////////////
8
////                                                             ////
9
//// Copyright (C) 2010 Provartec LTD                            ////
10
//// www.provartec.com                                           ////
11
//// info@provartec.com                                          ////
12
////                                                             ////
13
//// This source file may be used and distributed without        ////
14
//// restriction provided that this copyright statement is not   ////
15
//// removed from the file and that any derivative work contains ////
16
//// the original copyright notice and the associated disclaimer.////
17
////                                                             ////
18
//// This source file is free software; you can redistribute it  ////
19
//// and/or modify it under the terms of the GNU Lesser General  ////
20
//// Public License as published by the Free Software Foundation.////
21
////                                                             ////
22
//// This source is distributed in the hope that it will be      ////
23
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
24
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
25
//// PURPOSE.  See the GNU Lesser General Public License for more////
26
//// details. http://www.gnu.org/licenses/lgpl.html              ////
27
////                                                             ////
28
//////////////////////////////////////////////////////////////////##>
29
 
30
OUTFILE PREFIX_serial_TOPO.v
31
 
32
ITER OX ORDER
33
ITER CX COEFF_NUM
34
ITER SX ADD_STAGES
35
 
36
//  Built In Parameters:
37
//  
38
//    Filter Order             = ORDER
39
//    Input Precision          = DIN_BITS
40
//    Coefficient Precision    = COEFF_BITS
41
//    Sum of Products Latency  = LATENCY
42
 
43
module PREFIX_serial_TOPO (PORTS);
44
 
45
        input  clk;
46
        input  reset;
47
    input  clken;
48
        input  [EXPR(COEFF_BITS-1):0] kCX;
49
        input  [EXPR(DIN_BITS-1):0] data_in;
50
        output [EXPR(DOUT_BITS-1):0] data_out;
51
        output valid;
52
 
53
    wire [EXPR(COEFF_BITS-1):0] k;
54
    wire [EXPR(MULT_BITS-1):0] mult;
55
    reg [EXPR(DOUT_BITS-1):0] multCX;
56
    wire [EXPR(DOUT_BITS-1):0] add;
57
        wire addCX;
58
        reg [EXPR(DOUT_BITS-1):0] mult_sum;
59
        reg [EXPR(DOUT_BITS-1):0] data_out;
60
        reg valid;
61
 
62
        reg active;
63
    reg [EXPR(ADD_STAGES-1):0] phase;
64
    reg [EXPR(ADD_STAGES-1):0] cycle;
65
 
66
        wire phaseCX;
67
        wire cycleCX;
68
 
69
        assign phaseCX = phase == 'dCX;
70
        assign cycleCX = cycle == 'dCX;
71
 
72
    assign k =
73
          phaseOX ? kOX :
74
          kORDER;
75
 
76
    //a single multiplayer and a single adder
77
    assign mult = k * data_in;
78
        assign add  = mult + (
79
                                  addOX ? multOX :
80
                                          multORDER);
81
 
82
 
83
    always @(posedge clk or posedge reset)
84
      if (reset)
85
        active <= #FFD 1'b0;
86
          else if (clken)
87
        active <= #FFD 1'b1;
88
          else if (phase == 'dORDER)
89
        active <= #FFD 1'b0;
90
 
91
    always @(posedge clk or posedge reset)
92
      if (reset)
93
        phase <= #FFD {ADD_STAGES{1'b0}};
94
      else if (phase == 'dORDER)
95
        phase <= #FFD {ADD_STAGES{1'b0}};
96
      else if (active)
97
        phase <= #FFD phase + 1'b1;
98
 
99
    always @(posedge clk or posedge reset)
100
      if (reset)
101
        cycle <= #FFD {ADD_STAGES{1'b0}};
102
          else if (phase == 'dORDER)
103
            begin
104
                  if (cycle == 'dORDER)
105
            cycle <= #FFD {ADD_STAGES{1'b0}};
106
                  else
107
            cycle <= cycle + 1'b1;
108
                end
109
 
110
LOOP PX COEFF_NUM
111
        assign addPX = active & (
112
            (phaseEXPR((COEFF_NUM+PX-CX)%COEFF_NUM) && cycleCX) ||
113
                STOMP || );
114
 
115
        always @(posedge clk or posedge reset)
116
          if (reset)
117
            multPX <= #FFD {MULT_BITS{1'b0}};
118
          else if (phase1 && cyclePX)
119
            multPX <= #FFD {MULT_BITS{1'b0}};
120
          else if (addPX)
121
            multPX <= #FFD add;
122
 
123
ENDLOOP PX
124
 
125
 
126
 //sample when valid
127
 always @(posedge clk or posedge reset)
128
  if (reset)
129
    mult_sum <= #FFD {DOUT_BITS{1'b0}};
130
  else if (phase1)
131
    begin
132
LOOP CX COEFF_NUM
133
        if (cycleCX)
134
    mult_sum <= #FFD multCX;
135
        else
136
STOMP NEWLINE
137
ENDLOOP CX
138
STOMP else
139
    end
140
 
141
 //sync to clock enable
142
 always @(posedge clk or posedge reset)
143
  if (reset)
144
    begin
145
      data_out <= #FFD {DOUT_BITS{1'b0}};
146
          valid <= #FFD 1'b0;
147
        end
148
  else if (clken)
149
    begin
150
      data_out <= #FFD mult_sum;
151
          valid <= #FFD 1'b1;
152
        end
153
  else
154
    begin
155
          valid <= #FFD 1'b0;
156
        end
157
 
158
 
159
endmodule
160
 
161
 
162
 
163
 
164
 

powered by: WebSVN 2.1.0

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