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

Subversion Repositories pipelined_fft_64

[/] [pipelined_fft_64/] [trunk/] [BENCH/] [sinerom64_gen.pl] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 unicore
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2
#
3
# Copyright(c) 2007 by Unicore Systems. All rights reserved
4
#
5
# DESIGN           :    UNFFT64_core
6
# FILENAME              :        sinerom64_gen.pl
7
# CREATED               :        1.11:2007
8
# MODIFIED              :       
9
# VERSION                       :       1.0
10
#
11
# AUTHORS:      Anatolij Sergiyenko.
12
# HISTORY       :       
13
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~            
14
# DESCRIPTION   :       Test generating PERL file1
15
# FUNCTION:             Generating sine wave ROM 
16
#                                        with $n samples  which consists of 4 sine wave sum
17
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~            
18
 
19
$aw=6;   ##   - address bit width
20
$n = 64; ### - period length
21
$n0 = 0; ### - init address  
22
$f1 = 1;  ## - first frequency
23
$f2 = 3;  ## -second frequency
24
$f3 = 5;  ## - 3-d frequency
25
$f4 = 7;  ## -4-th frequency
26
$Pi = 3.14159265358     ;
27
 
28
    open OutFile, ">Wave_ROM64.v" || die "Cannot open file .V";    # סמחהא¸ל פאיכ
29
 
30
 
31
        print OutFile   "//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
32
    print OutFile       "//   ROM with ".$n." samples of the sine waves at the frequencies = ".$f1." and ".$f2 ."\n";
33
    print OutFile       "//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
34
        print OutFile   "   `timescale 1 ns / 1 ps  \n";
35
        print OutFile   "module Wave_ROM64 ( ADDR ,DATA_RE,DATA_IM,DATA_REF ); \n";
36
    print OutFile       "       output [15:0] DATA_RE,DATA_IM,DATA_REF ;     \n";
37
    print OutFile       "       input [".($aw-1).":0]    ADDR ;     \n";
38
# # Cosine table generation
39
    print OutFile       "       reg [15:0] cosi[0:".($n-1)."];    \n";
40
    print OutFile       "       initial   begin    \n";
41
        for $j(0..$n/4-1){
42
          $cos_row=0;
43
         for $i(0..3){
44
 #      $CosArr=(16383*cos(2*$Pi*$f1*(($n0+$i+$j*4)/$n))
45
#                        +16383*cos(2*$Pi*$f2*(($n0+$i+$j*4)/$n))); 
46
        $CosArr=(8191*cos(2*$Pi*$f1*(($n0+$i+$j*4)/$n))
47
                         +8191*cos(2*$Pi*$f2*(($n0+$i+$j*4)/$n))
48
                                         +8191*cos(2*$Pi*$f3*(($n0+$i+$j*4)/$n))
49
                         +8191*cos(2*$Pi*$f4*(($n0+$i+$j*4)/$n)));
50
            $sinv= To_Hex4(int ($CosArr));
51
 
52
        print OutFile   "  cosi[".($n0+$i+$j*4)."]=16'h".$sinv.";";
53
}
54
print OutFile "\n";
55
}
56
print OutFile "     end \n\n";
57
         print "\n";
58
# # Sine table generation
59
    print OutFile       "       reg [15:0] sine[0:".($n-1)."];    \n";
60
    print OutFile       "       initial   begin    \n";
61
                for $j(0..$n/4-1){
62
          $sin_row=0;
63
         for $i(0..3){
64
 #      $SinArr=(16383*sin(2*$Pi*$f1*(($n0+$i+$j*4)/$n))
65
#                        +16383*sin(2*$Pi*$f2*(($n0+$i+$j*4)/$n)));     
66
        $SinArr=(8191*sin(2*$Pi*$f1*(($n0+$i+$j*4)/$n))
67
                         +8191*sin(2*$Pi*$f2*(($n0+$i+$j*4)/$n))
68
                                         +8191*sin(2*$Pi*$f3*(($n0+$i+$j*4)/$n))
69
                         +8191*sin(2*$Pi*$f4*(($n0+$i+$j*4)/$n)));
70
 
71
 
72
            $sinv= To_Hex4(int ($SinArr));
73
 
74
        print OutFile   "  sine[".($n0+$i+$j*4)."]=16'h".$sinv.";";
75
}
76
print OutFile "\n";
77
}
78
         print "\n";
79
print OutFile "      end \n\n";
80
 
81
##Reference table generation
82
    print OutFile       "       reg [15:0] deltas[0:".($n-1)."];    \n";
83
    print OutFile       "       initial   begin    \n";
84
        for $j(0..$n/4-1){
85
         for $i(0..3){
86
        print OutFile   " deltas[".($n0+$i+$j*4)."]=16'h0000;";
87
}
88
print OutFile "\n";
89
}
90
##print OutFile " deltas[".$f1."]=16'h3fff;  deltas[".$f2."]=16'h3fff;\n";
91
 print OutFile  " deltas[".$f1."]=16'h7ffc;  deltas[".$f2."]=16'h7ffc; deltas[".$f3."]=16'h7ffc; deltas[".$f4."]=16'h7ffc;\n";
92
print OutFile "     end \n\n";
93
 
94
print OutFile " assign DATA_RE=cosi[ADDR];      \n";
95
print OutFile " assign DATA_IM=sine[ADDR];      \n";
96
print OutFile " assign DATA_REF=deltas[ADDR];   \n";
97
print OutFile "endmodule   \n";
98
 
99
   close(OutFile);
100
 
101
 
102
   sub To_Hex2{
103
        my(%Hexnumbers)= (0,0,1,1,2,2,3,3,
104
                        4,4,5,5,6,6,7,7,
105
                        8,8,9,9,10,'A',11,'B',
106
                        12,'C',13,'D',14,'E',15,'F');
107
 
108
        $_[0]=($_[0]>=0) ? $_[0] : 256+$_[0];
109
        my($h21)=$_[0] % 16;
110
        my($h22)=int($_[0] / 16);
111
        return $Hexnumbers{$h22}.$Hexnumbers{$h21};
112
   };
113
 
114
    sub To_Hex4{
115
        my(%Hexnumbers)= (0,0,1,1,2,2,3,3,
116
                        4,4,5,5,6,6,7,7,
117
                        8,8,9,9,10,'A',11,'B',
118
                        12,'C',13,'D',14,'E',15,'F');
119
 
120
   $_[0]=($_[0]>=0) ? $_[0] : 65536+$_[0];
121
        my($h21)=$_[0] % 16;
122
        my($r21)=int($_[0] / 16);
123
        my($h22)=$r21 % 16;
124
        my($r22)=int($r21 / 16);
125
        my($h23)=$r22 % 16;
126
        my($h24)=int($r22 / 16);
127
   return $Hexnumbers{$h24}.$Hexnumbers{$h23}.$Hexnumbers{$h22}.$Hexnumbers{$h21};
128
  ##return $_[0];
129
  };
130
 
131
          open (File, "Wave_ROM64.v") || die  "Cannot open r";
132
          while ($line = <File>)
133
       {
134
           print $line;         # Ready file output to the screen
135
                   }
136
 
137
 
138
          close(File);

powered by: WebSVN 2.1.0

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