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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [bin/] [ver2gedasym] - Blame information for rev 127

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
 
4
#/**********************************************************************/
5
#/*                                                                    */
6
#/*             -------                                                */
7
#/*            /   SOC  \                                              */
8
#/*           /    GEN   \                                             */
9
#/*          /    TOOL    \                                            */
10
#/*          ==============                                            */
11
#/*          |            |                                            */
12
#/*          |____________|                                            */
13
#/*                                                                    */
14
#/*  convert verilog file(s) to a geda symbol                          */
15
#/*                                                                    */
16
#/*                                                                    */
17
#/*  Author(s):                                                        */
18
#/*      - John Eaton, jt_eaton@opencores.org                          */
19
#/*                                                                    */
20
#/**********************************************************************/
21
#/*                                                                    */
22
#/*    Copyright (C) <2010>                     */
23
#/*                                                                    */
24
#/*  This source file may be used and distributed without              */
25
#/*  restriction provided that this copyright statement is not         */
26
#/*  removed from the file and that any derivative work contains       */
27
#/*  the original copyright notice and the associated disclaimer.      */
28
#/*                                                                    */
29
#/*  This source file is free software; you can redistribute it        */
30
#/*  and/or modify it under the terms of the GNU Lesser General        */
31
#/*  Public License as published by the Free Software Foundation;      */
32
#/*  either version 2.1 of the License, or (at your option) any        */
33
#/*  later version.                                                    */
34
#/*                                                                    */
35
#/*  This source is distributed in the hope that it will be            */
36
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
37
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
38
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
39
#/*  details.                                                          */
40
#/*                                                                    */
41
#/*  You should have received a copy of the GNU Lesser General         */
42
#/*  Public License along with this source; if not, download it        */
43
#/*  from http://www.opencores.org/lgpl.shtml                          */
44
#/*                                                                    */
45
#/**********************************************************************/
46
 
47
#  ToDo:
48
#  parse reg from output bus name
49
#  parse bus and change pin type to bus
50
 
51
use Verilog::Netlist;
52
 
53
# Setup options so files can be found
54
use Verilog::Getopt;
55
my $opt = new Verilog::Getopt;
56
$opt->parameter( "+incdir+verilog",
57
                    "-y","verilog",
58
               );
59
 
60
 
61
@files            = @ARGV;
62
 
63
 
64
# Prepare netlist
65
my $nl = new Verilog::Netlist (options => $opt,);
66
 
67
foreach $file (@files) {
68
                        print "Parsing   $file\n";
69
                        $nl->read_file (filename=>$file);
70
}
71
 
72
 
73
 
74
 
75
 
76
 
77
 
78
# Read in any sub-modules
79
$nl->link();
80
$nl->exit_if_error();
81
 
82
 
83
foreach my $mod ($nl->top_modules_sorted) {make_sch ($mod);}
84
 
85
 
86
 
87
sub make_sch {
88
        my $mod = shift;
89
        my $mod_name  = $mod->name;
90
 
91
        my $in_count   = 0;
92
        my $out_count  = 0;
93
        my $in_length  = 0;
94
        my $out_length = 0;
95
 
96
        my $color =  5;
97
        my $size  = 10;
98
 
99
 
100
        open(FILE,">sym/${mod_name}.sym") or die "No sym directory";
101
 
102
        foreach my $sig ($mod->ports_sorted) {
103
 
104
            my $dir       =  $sig->direction;
105
            my $data_type =  $sig->data_type;
106
            my $sig_name  =  $sig->name;
107
            $data_type  =~ s/reg //;
108
            $data_type  =~ s/reg//;
109
 
110
 
111
            if($data_type)
112
              {
113
              $pin_name = "$sig_name"."$data_type";
114
              if("in" eq  $dir)
115
                {
116
                push(@invads,$pin_name);
117
                $in_count = $in_count+1;
118
                if( length($pin_name) > $in_length) { $in_length =  length($pin_name)};
119
                }
120
              if("out" eq  $dir)
121
                {
122
                push(@outvads,$pin_name);
123
                $out_count = $out_count+1;
124
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
125
                }
126
 
127
              if("inout" eq  $dir)
128
                {
129
                push(@inoutvads,$pin_name);
130
                $out_count = $out_count+1;
131
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
132
                }
133
 
134
 
135
 
136
              }
137
            else
138
              {
139
              $pin_name = $sig_name;
140
              if("in" eq  $dir)
141
                {
142
                push(@inpads,$pin_name);
143
                $in_count = $in_count+1;
144
                if( length($pin_name) > $in_length){  $in_length =  length($pin_name)            }
145
                }
146
              if("out" eq  $dir)
147
                {
148
                push(@outpads,$pin_name);
149
                $out_count = $out_count+1;
150
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
151
                }
152
 
153
              if("inout" eq  $dir)
154
                {
155
                push(@inoutpads,$pin_name);
156
                $out_count = $out_count+1;
157
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
158
                }
159
 
160
              };
161
 
162
 
163
        }
164
 
165
        my $max_pins;
166
 
167
        if($in_count > $out_count) {$max_pins = $in_count ;} else  {$max_pins = $out_count ;}
168
 
169
        my $box_h   = ($max_pins * 200) +300;
170
        my $box_w   = ($in_length +$out_length)*10*$size +400;
171
        my $out_title = ($in_length +$out_length)*10*$size +600;
172
        my $out_edg = ($in_length +$out_length)*10*$size +700;
173
        my $out_pad = ($in_length +$out_length)*10*$size +1000;
174
        my $title   = $box_h +150;
175
        my $ref_des = $box_h +350;
176
 
177
        printf FILE ("v 20100214 1\n");
178
        printf FILE ("B 300 0  $box_w $box_h 3 60 0 0 -1 -1 0 -1 -1 -1 -1 -1\n");
179
        printf FILE ("T 400 $title 5 10 1 1 0 0 1 1\ndevice=%s\n", $mod->name);
180
        printf FILE ("T 400 $ref_des 8 10 1 1 0 0 1 1\n%srefdes=U?\n");
181
 
182
        printf  ("%s\n", $mod->name);
183
 
184
 
185
         my $pin_y = 200;
186
         my $pin_seq = 1;
187
 
188
         while( $name =pop(@invads))
189
          {
190
          printf FILE ("P 300 $pin_y 0 $pin_y 10 1 1 \n");
191
          printf FILE ("{\nT 400 $pin_y $color $size 1 1 0 1 1 1\npinnumber=%s\n",$name);
192
          printf FILE ("T 400 $pin_y $color $size 0 1 0 1 1 1\npinseq=%s\n}\n",$pin_seq);
193
          $pin_seq = $pin_seq +1;
194
          $pin_y = $pin_y +200;
195
          }
196
 
197
 
198
         while( $name =pop(@inpads))
199
          {
200
           printf FILE ("P 300 $pin_y 0 $pin_y 4 0 1  \n");
201
           printf FILE ("{\nT 400 $pin_y $color $size 1 1 0 1 1 1 \npinnumber=%s\n",$name);
202
           printf FILE ("T 400 $pin_y $color $size 0 1 0 1 1 1 \npinseq=%s\n}\n",$pin_seq);
203
           $pin_seq = $pin_seq +1;
204
           $pin_y = $pin_y +200;
205
          }
206
 
207
 
208
 
209
         $pin_y = 200;
210
 
211
         while( $name =pop(@outvads))
212
          {
213
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 10 1 1\n");
214
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1 \npinnumber=%s\n",$name);
215
           printf FILE ("T $out_title $pin_y $color  $size 0 1 0 7 1 1 \npinseq=%s\n}\n",$pin_seq);
216
           $pin_seq = $pin_seq +1;
217
           $pin_y = $pin_y +200;
218
          }
219
 
220
 
221
         while( $name =pop(@outpads))
222
          {
223
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 4 0 1\n");
224
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1\npinnumber=%s\n",$name);
225
           printf FILE ("T $out_edg $pin_y $color  $size 0 1 0 7 1 1\npinseq=%s\n}\n",$pin_seq);
226
           $pin_seq = $pin_seq +1;
227
           $pin_y = $pin_y +200;
228
          }
229
 
230
 
231
 
232
 
233
         while( $name =pop(@inoutvads))
234
          {
235
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 10 1 1\n");
236
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1 \npinnumber=%s\n",$name);
237
           printf FILE ("T $out_title $pin_y $color  $size 0 1 0 7 1 1 \npinseq=%s\n}\n",$pin_seq);
238
           $pin_seq = $pin_seq +1;
239
           $pin_y = $pin_y +200;
240
          }
241
 
242
 
243
         while( $name =pop(@inoutpads))
244
          {
245
           printf FILE ("P $out_edg $pin_y $out_pad $pin_y 4 0 1\n");
246
           printf FILE ("{\nT $out_title $pin_y $color  $size 1 1 0 7 1 1\npinnumber=%s\n",$name);
247
           printf FILE ("T $out_edg $pin_y $color  $size 0 1 0 7 1 1\npinseq=%s\n}\n",$pin_seq);
248
           $pin_seq = $pin_seq +1;
249
           $pin_y = $pin_y +200;
250
          }
251
 
252
 
253
 
254
 
255
 
256
 
257
 
258
 
259
        foreach my $cell ($mod->cells_sorted) {
260
            close(FILE);
261
            make_sch ($cell->submod, $cell->name) if $cell->submod;
262
        }
263
    }
264
 
265
 
266
 
267
 
268
 
269
 
270
 
271
1;
272
 
273
 
274
 
275
 
276
 
277
 
278
 

powered by: WebSVN 2.1.0

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