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

Subversion Repositories pipelined_fft_64

[/] [pipelined_fft_64/] [trunk/] [BENCH/] [USFFT64_2B_TB.v] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 unicore
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Testbench for the UNFFT64_core - FFT 64 processor          ////
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
// FUNCTION:a set of 4 sine waves is inputted to the FFT processor,
40
//          the results are compared with the expected waves,
41
//          the square root mean error is calculated (without a root)
42
// FILES:   USFFT64_2B_TB.v - this file, contains
43
//            USFFT64_2B.v - unit under test
44
//          sin_tst_rom.v - rom with the test waveform, generating by 
45
//          sinerom64_gen.pl   
46
//  PROPERTIES: 1) the calculated error after ca. 4us modeling 
47
//              is outputted to the console      as the note:
48
//            rms error is           1 lsb
49
//              2)if the error is 0,1,2 then the test is OK
50
//              3) the customer can exchange the test selecting the 
51
//              different frequencies and generating the wave ROM by
52
//          the script  sinerom64_gen.pl                        
53
//              4) the proper operation can be checked by investigation
54
//          of the core output waveforms
55
/////////////////////////////////////////////////////////////////////
56
`include "FFT64_CONFIG.inc"
57
 
58
`timescale 1ns / 1ps
59
module USFFT64_2B_tb;
60
        //Parameters declaration: 
61
        //defparam UUT.nb = 12;
62
        `USFFT64paramnb
63
 
64
        //Internal signals declarations:
65
        reg CLK;
66
        reg RST;
67
        reg ED;
68
        reg START;
69
        reg [3:0]SHIFT;
70
        wire [nb-1:0]DR;
71
        wire [nb-1:0]DI;
72
        wire RDY;
73
        wire OVF1;
74
        wire OVF2;
75
        wire [5:0]ADDR;
76
        wire signed [nb+2:0]DOR;
77
        wire signed [nb+2:0]DOI;
78
 
79
        initial
80
                begin
81
                        CLK = 1'b0;
82
                        forever #5 CLK = ~CLK;
83
                end
84
        initial
85
                begin
86
                        SHIFT = 4'b0000;
87
                        ED = 1'b1;
88
                        RST = 1'b0;
89
                        START = 1'b0;
90
                        #13 RST =1'b1;
91
                        #43 RST =1'b0;
92
                        #53 START =1'b1;
93
                        #12 START =1'b0;
94
                end
95
 
96
        reg [5:0] ct64;
97
        always @(posedge CLK or posedge START) begin
98
                        if (START) ct64 = 6'b000000;
99
                        else ct64 = ct64 + 'd1;
100
                end
101
 
102
        wire [15:0] DATA_RE,DATA_IM,DATA_0;
103
        Wave_ROM64 UG( .ADDR(ct64) ,
104
                .DATA_RE(DATA_RE), .DATA_IM(DATA_IM), .DATA_REF(DATA_0) );// 
105
 
106
        assign DR=DATA_RE[15:15-nb+1];
107
        assign DI=DATA_IM[15:15-nb+1];
108
 
109
        // Unit Under Test 
110
        USFFT64_2B UUT (
111
                .CLK(CLK),
112
                .RST(RST),
113
                .ED(ED),
114
                .START(START),
115
                .SHIFT(SHIFT),
116
                .DR(DR),
117
                .DI(DI),
118
                .RDY(RDY),
119
                .OVF1(OVF1),
120
                .OVF2(OVF2),
121
                .ADDR(ADDR),
122
                .DOR(DOR),
123
                .DOI(DOI));
124
 
125
                wire [5:0] addrr;
126
        `ifdef USFFT64paramifft
127
                assign addrr= (64-ADDR);  //the result order if IFFT 
128
        `else
129
                assign addrr= ADDR;
130
        `endif
131
 
132
 
133
                wire signed [15:0] DATA_R0,DATA_I0,DATA_REF;
134
        Wave_ROM64 UR( .ADDR(addrr) ,
135
                .DATA_RE(DATA_R0), .DATA_IM(DATA_I0), .DATA_REF(DATA_REF) );// 
136
 
137
        wire signed [18:15-nb+1] DREF=2*DATA_REF[15:15-nb+1];
138
 
139
        integer sqra;
140
        integer ctres;
141
        reg f;
142
        initial f=0;
143
        always@(posedge CLK) begin
144
                if (f)
145
                        ctres=ctres+1;
146
                        if (RST || RDY)  begin
147
                                if (RDY) f=1;
148
                                sqra=0;
149
                                ctres=0; end
150
                        else if (ctres<64) begin
151
                                        #2 sqra = sqra +(DREF-DOR)*(DREF-DOR);
152
                                #2 sqra = sqra +(DOI)*(DOI); end
153
                        else if (ctres==64)
154
                                $display("rms error is ", (sqra/128), " lsb");
155
                end
156
 
157
 
158
endmodule

powered by: WebSVN 2.1.0

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