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

Subversion Repositories pipelined_fft_256

[/] [pipelined_fft_256/] [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 256 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 "FFT256_CONFIG.inc"
57
 
58
module CNORM ( CLK ,ED ,START ,DR ,DI ,SHIFT ,OVF ,RDY ,DOR ,DOI );
59
        `FFT256paramnb
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+3:0] DR ;
77
        wire [nb+3:0] DR ;
78
        input [nb+3:0] DI ;
79
        wire [nb+3: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+3:0]     dir,dii;
88
 
89
`ifdef FFT256round                      //rounding
90
    always @( posedge CLK )    begin
91
                        if (ED)   begin
92
                                        dir<=diri;
93
                                dii<=diii;
94
                end
95
        end
96
 
97
`else                                                            //truncation    
98
    always @( posedge CLK )    begin
99
                if (ED)   begin
100
                        if (diri[nb+3] && ~diri[0])      // <0 with LSB=00 
101
                                dir<=diri;
102
                        else   dir<=diri+2;
103
                        if (diii[nb+3] && ~diii[0])
104
                                dii<=diii;
105
                        else   dii<=diii+2;
106
                end
107
        end
108
 
109
        `endif
110
 
111
 always @( posedge CLK )        begin
112
                        if (ED)   begin
113
                                RDY<=START;
114
                                if (START)
115
                                        OVF<=0;
116
                                else
117
                                        case (SHIFT)
118
                                        2'b01 : OVF<= (DR[nb+3] != DR[nb+2]) || (DI[nb+3] != DI[nb+2]);
119
                                        2'b10 : OVF<= (DR[nb+3] != DR[nb+2]) || (DI[nb+3] != DI[nb+2]) ||
120
                                                (DR[nb+3] != DR[nb+1]) || (DI[nb+3] != DI[nb+1]);
121
                                        2'b11 : OVF<= (DR[nb+3] != DR[nb+2]) || (DI[nb+3] != DI[nb+2])||
122
                                                (DR[nb+3] != DR[nb]) || (DI[nb+3] != DI[nb]) ||
123
                                                (DR[nb+3] != DR[nb+1]) || (DI[nb+3] != DI[nb+1]);
124
                                        endcase
125
                                end
126
                        end
127
 
128
        assign DOR= dir[nb+3:2];
129
        assign DOI= dii[nb+3:2];
130
 
131
endmodule

powered by: WebSVN 2.1.0

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