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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [documentation/] [ver2gedasym] - Blame information for rev 135

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 128 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3 135 jt_eaton
#/****************************************************************************/
4
#/*                                                                          */
5
#/*   SOCGEN Design for Reuse toolset                                        */
6
#/*                                                                          */
7
#/*   Version 1.0.0                                                          */
8
#/*                                                                          */
9
#/*   Author(s):                                                             */
10
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
11
#/*                                                                          */
12
#/****************************************************************************/
13
#/*                                                                          */
14
#/*                                                                          */
15
#/*             Copyright 2016 John T Eaton                                  */
16
#/*                                                                          */
17
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
18
#/* you may not use this file except in compliance with the License.         */
19
#/* You may obtain a copy of the License at                                  */
20
#/*                                                                          */
21
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
22
#/*                                                                          */
23
#/* Unless required by applicable law or agreed to in writing, software      */
24
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
25
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
26
#/* See the License for the specific language governing permissions and      */
27
#/* limitations under the License.                                           */
28
#/*                                                                          */
29
#/*                                                                          */
30
#/****************************************************************************/
31 128 jt_eaton
 
32
#  ToDo:
33
#  parse reg from output bus name
34
#  parse bus and change pin type to bus
35
 
36
use Verilog::Netlist;
37
 
38
# Setup options so files can be found
39
use Verilog::Getopt;
40
my $opt = new Verilog::Getopt;
41
$opt->parameter( "+incdir+verilog",
42
                    "-y","verilog",
43
               );
44
 
45
 
46
 
47
 
48
 
49
 
50
 
51
 
52
my @files            = ();
53
 
54
$SRCFILE            = @ARGV[0];
55
$outfile            = @ARGV[1];
56
 
57
 
58
 
59
 
60
             push @files,  "$SRCFILE";
61
 
62
 
63
 
64
 
65
# Prepare netlist
66
my $nl = new Verilog::Netlist (options => $opt,);
67
 
68
foreach $file (@files) {
69
                        print "Parsing   $file\n";
70
                        $nl->read_file (filename=>$file);
71
}
72
 
73
 
74
 
75
 
76
 
77
 
78
 
79
# Read in any sub-modules
80
$nl->link();
81
$nl->exit_if_error();
82
 
83
 
84
foreach my $mod ($nl->top_modules_sorted) {make_sch ($mod);}
85
 
86
 
87
 
88
sub make_sch {
89
        my $mod = shift;
90
        my $mod_name  = $mod->name;
91
 
92
        my $in_count   = 0;
93
        my $out_count  = 0;
94
        my $in_length  = 0;
95
        my $out_length = 0;
96
 
97
        my $color =  5;
98
        my $size  = 10;
99
 
100
 
101
        open(FILE,">${outfile}/${mod_name}.sym") or die "No sym directory";
102
 
103
        foreach my $sig ($mod->ports_sorted) {
104
 
105
            my $dir       =  $sig->direction;
106
            my $data_type =  $sig->data_type;
107
            my $sig_name  =  $sig->name;
108
            $data_type  =~ s/reg //;
109
            $data_type  =~ s/reg//;
110
 
111
 
112
            if($data_type)
113
              {
114
              $pin_name = "$sig_name"."$data_type";
115
              if("in" eq  $dir)
116
                {
117
                push(@invads,$pin_name);
118
                $in_count = $in_count+1;
119
                if( length($pin_name) > $in_length) { $in_length =  length($pin_name)};
120
                }
121
              if("out" eq  $dir)
122
                {
123
                push(@outvads,$pin_name);
124
                $out_count = $out_count+1;
125
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
126
                }
127
 
128
              if("inout" eq  $dir)
129
                {
130
                push(@inoutvads,$pin_name);
131
                $out_count = $out_count+1;
132
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
133
                }
134
 
135
 
136
 
137
              }
138
            else
139
              {
140
              $pin_name = $sig_name;
141
              if("in" eq  $dir)
142
                {
143
                push(@inpads,$pin_name);
144
                $in_count = $in_count+1;
145
                if( length($pin_name) > $in_length){  $in_length =  length($pin_name)            }
146
                }
147
              if("out" eq  $dir)
148
                {
149
                push(@outpads,$pin_name);
150
                $out_count = $out_count+1;
151
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
152
                }
153
 
154
              if("inout" eq  $dir)
155
                {
156
                push(@inoutpads,$pin_name);
157
                $out_count = $out_count+1;
158
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
159
                }
160
 
161
              };
162
 
163
 
164
        }
165
 
166
        my $max_pins;
167
 
168
        if($in_count > $out_count) {$max_pins = $in_count ;} else  {$max_pins = $out_count ;}
169
 
170
        my $box_h   = ($max_pins * 200) +300;
171
        my $box_w   = ($in_length +$out_length)*10*$size +400;
172
        my $out_title = ($in_length +$out_length)*10*$size +600;
173
        my $out_edg = ($in_length +$out_length)*10*$size +700;
174
        my $out_pad = ($in_length +$out_length)*10*$size +1000;
175
        my $title   = $box_h +150;
176
        my $ref_des = $box_h +350;
177
 
178
        printf FILE ("v 20100214 1\n");
179
        printf FILE ("B 300 0  $box_w $box_h 3 60 0 0 -1 -1 0 -1 -1 -1 -1 -1\n");
180
        printf FILE ("T 400 $title 5 10 1 1 0 0 1 1\ndevice=%s\n", $mod->name);
181
        printf FILE ("T 400 $ref_des 8 10 1 1 0 0 1 1\n%srefdes=U?\n");
182
 
183
        printf  ("%s\n", $mod->name);
184
 
185
 
186
         my $pin_y = 200;
187
         my $pin_seq = 1;
188
 
189
         while( $name =pop(@invads))
190
          {
191
          printf FILE ("P 300 $pin_y 0 $pin_y 10 1 1 \n");
192
          printf FILE ("{\nT 400 $pin_y $color $size 1 1 0 1 1 1\npinnumber=%s\n",$name);
193
          printf FILE ("T 400 $pin_y $color $size 0 1 0 1 1 1\npinseq=%s\n}\n",$pin_seq);
194
          $pin_seq = $pin_seq +1;
195
          $pin_y = $pin_y +200;
196
          }
197
 
198
 
199
         while( $name =pop(@inpads))
200
          {
201
           printf FILE ("P 300 $pin_y 0 $pin_y 4 0 1  \n");
202
           printf FILE ("{\nT 400 $pin_y $color $size 1 1 0 1 1 1 \npinnumber=%s\n",$name);
203
           printf FILE ("T 400 $pin_y $color $size 0 1 0 1 1 1 \npinseq=%s\n}\n",$pin_seq);
204
           $pin_seq = $pin_seq +1;
205
           $pin_y = $pin_y +200;
206
          }
207
 
208
 
209
 
210
         $pin_y = 200;
211
 
212
         while( $name =pop(@outvads))
213
          {
214
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 10 1 1\n");
215
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1 \npinnumber=%s\n",$name);
216
           printf FILE ("T $out_title $pin_y $color  $size 0 1 0 7 1 1 \npinseq=%s\n}\n",$pin_seq);
217
           $pin_seq = $pin_seq +1;
218
           $pin_y = $pin_y +200;
219
          }
220
 
221
 
222
         while( $name =pop(@outpads))
223
          {
224
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 4 0 1\n");
225
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1\npinnumber=%s\n",$name);
226
           printf FILE ("T $out_edg $pin_y $color  $size 0 1 0 7 1 1\npinseq=%s\n}\n",$pin_seq);
227
           $pin_seq = $pin_seq +1;
228
           $pin_y = $pin_y +200;
229
          }
230
 
231
 
232
 
233
 
234
         while( $name =pop(@inoutvads))
235
          {
236
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 10 1 1\n");
237
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1 \npinnumber=%s\n",$name);
238
           printf FILE ("T $out_title $pin_y $color  $size 0 1 0 7 1 1 \npinseq=%s\n}\n",$pin_seq);
239
           $pin_seq = $pin_seq +1;
240
           $pin_y = $pin_y +200;
241
          }
242
 
243
 
244
         while( $name =pop(@inoutpads))
245
          {
246
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 4 0 1\n");
247
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1\npinnumber=%s\n",$name);
248
           printf FILE ("T $out_edg $pin_y $color  $size 0 1 0 7 1 1\npinseq=%s\n}\n",$pin_seq);
249
           $pin_seq = $pin_seq +1;
250
           $pin_y = $pin_y +200;
251
          }
252
 
253
 
254
 
255
 
256
 
257
 
258
 
259
 
260
        foreach my $cell ($mod->cells_sorted) {
261
            close(FILE);
262
            make_sch ($cell->submod, $cell->name) if $cell->submod;
263
        }
264
    }
265
 
266
 
267
 
268
 
269
 
270
 
271
 
272
1;
273
 
274
 
275
 
276
 
277
 
278
 
279
 

powered by: WebSVN 2.1.0

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