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

Subversion Repositories pipelined_fft_128

[/] [pipelined_fft_128/] [trunk/] [SRC/] [cnorm.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 unicore
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  FFT/IFFT 128 points transform                              ////
4
////                                                             ////
5
////  Authors: Anatoliy Sergienko, Volodya Lepeha                ////
6
////  Company: Unicore Systems http://unicore.co.ua              ////
7
////                                                             ////
8
////  Downloaded from: http://www.opencores.org                  ////
9
////                                                             ////
10
/////////////////////////////////////////////////////////////////////
11
////                                                             ////
12
//// Copyright (C) 2006-2010 Unicore Systems LTD                 ////
13
//// www.unicore.co.ua                                           ////
14
//// o.uzenkov@unicore.co.ua                                     ////
15
////                                                             ////
16
//// This source file may be used and distributed without        ////
17
//// restriction provided that this copyright statement is not   ////
18
//// removed from the file and that any derivative work contains ////
19
//// the original copyright notice and the associated disclaimer.////
20
////                                                             ////
21
//// THIS SOFTWARE IS PROVIDED "AS IS"                           ////
22
//// AND ANY EXPRESSED OR IMPLIED WARRANTIES,                    ////
23
//// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED                  ////
24
//// WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT              ////
25
//// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.        ////
26
//// IN NO EVENT SHALL THE UNICORE SYSTEMS OR ITS                ////
27
//// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,            ////
28
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL            ////
29
//// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT         ////
30
//// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,               ////
31
//// DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                 ////
32
//// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,              ////
33
//// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT              ////
34
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING                 ////
35
//// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,                 ////
36
//// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.          ////
37
////                                                             ////
38
/////////////////////////////////////////////////////////////////////
39
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~           
40
// DESCRIPTION  :       Normalization unit
41
// FUNCTION:            shifting left up to 3 bits
42
//      FILES:                  CNORM.v
43
//  PROPERTIES: 1) shifting left up to 3 bits controlled by the 2-bit code SHIFT
44
//                                                      2) Is registered
45
//                                                      3) Overflow detector detects the overflow event 
46
//                          by the given shift condition. The detector is zeroed by the START signal
47
//                         4) RDY is the START signal delayed to a single clock cycle
48
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49
// File        : 
50
// Generated   : 
51
//
52
// Description : 
53
//
54
//-----------------------------------------------------------------------------
55
`timescale 1 ns / 1 ps
56
`include "FFT128_CONFIG.inc"
57
 
58
module CNORM ( CLK ,ED ,START ,DR ,DI ,SHIFT ,OVF ,RDY ,DOR ,DOI );
59
        `FFT128paramnb
60
 
61
        output OVF ;
62
        reg OVF ;
63
        output RDY ;
64
        reg RDY ;
65
        output [nb+1:0] DOR ;
66
        wire [nb+1:0] DOR ;
67
        output [nb+1:0] DOI ;
68
        wire [nb+1:0] DOI ;
69
 
70
        input CLK ;
71
        wire CLK ;
72
        input ED ;
73
        wire ED ;
74
        input START ;
75
        wire START ;
76
        input [nb+2:0] DR ;
77
        wire [nb+2:0] DR ;
78
        input [nb+2:0] DI ;
79
        wire [nb+2:0] DI ;
80
        input [1:0] SHIFT ;                        //shift left code to 0,1,2,3 bits
81
        wire [1:0] SHIFT ;
82
 
83
        wire signed [nb+3:0]      diri,diii;
84
        assign diri = DR << SHIFT;
85
        assign diii = DI << SHIFT;
86
 
87
        reg [nb+2:0]     dir,dii;
88
 
89
        `ifdef FFT128round                      //rounding
90
        always @( posedge CLK )    begin
91
                        if (ED)   begin
92
                                        if (diri[nb+2] && ~diri[0])      // <0 with LSB=00 
93
                                                dir<=diri;
94
                                        else   dir<=diri+2;
95
                                        if (diii[nb+2] && ~diii[0])
96
                                                dii<=diii;
97
                                        else   dii<=diii+2;
98
                                end
99
                end
100
 
101
        `else                                                            //truncation    
102
        always @( posedge CLK )    begin
103
                        if (ED)   begin
104
                                        dir<=diri;
105
                                        dii<=diii;
106
                                end
107
                end
108
 
109
 
110
        `endif
111
 
112
        always @( posedge CLK )         begin
113
                        if (ED)   begin
114
                                        RDY<=START;
115
                                        if (START)
116
                                                OVF<=0;
117
                                        else
118
                                                case (SHIFT)
119
                                                        2'b01 : OVF<= (DR[nb+3] != DR[nb+2]) || (DI[nb+3] != DI[nb+2]);
120
                                                        2'b10 : OVF<= (DR[nb+3] != DR[nb+2]) || (DI[nb+3] != DI[nb+2]) ||
121
                                                                (DR[nb+3] != DR[nb+1]) || (DI[nb+3] != DI[nb+1]);
122
                                                        2'b11 : OVF<= (DR[nb+3] != DR[nb+2]) || (DI[nb+3] != DI[nb+2])||
123
                                                                (DR[nb+3] != DR[nb]) || (DI[nb+3] != DI[nb]) ||
124
                                                                (DR[nb+3] != DR[nb+1]) || (DI[nb+3] != DI[nb+1]);
125
                                                endcase
126
                                end
127
                end
128
 
129
        assign DOR= dir[nb+3:2];
130
        assign DOI= dii[nb+3:2];
131
 
132
endmodule

powered by: WebSVN 2.1.0

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