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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [documentation/] [ver2gedasch] - Blame information for rev 131

Go to most recent revision | 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
 
4
#/**********************************************************************/
5
#/*                                                                    */
6
#/*             -------                                                */
7
#/*            /   SOC  \                                              */
8
#/*           /    GEN   \                                             */
9
#/*          /    TOOL    \                                            */
10
#/*          ==============                                            */
11
#/*          |            |                                            */
12
#/*          |____________|                                            */
13
#/*                                                                    */
14
#/*  convert verilog file(s)ports  to a geda schematic                 */
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
 
62
 
63
my @files            = ();
64
 
65
$SRCFILE            = @ARGV[0];
66
$outfile            = @ARGV[1];
67
 
68
 
69
 
70
 
71
             push @files,  "$SRCFILE";
72
 
73
 
74
 
75
 
76
 
77
 
78
# Prepare netlist
79
my $nl = new Verilog::Netlist (options => $opt,);
80
 
81
 
82
 
83
 
84
 
85
 
86
foreach $file (@files) {
87
                        print "Parsing   $file\n";
88
                        $nl->read_file (filename=>$file);
89
}
90
 
91
 
92
 
93
 
94
 
95
 
96
 
97
# Read in any sub-modules
98
$nl->link();
99
$nl->exit_if_error();
100
 
101
 
102
foreach my $mod ($nl->top_modules_sorted) {make_sch ($mod);}
103
 
104
 
105
 
106
sub make_sch {
107
        my $mod = shift;
108
        my $mod_name  = $mod->name;
109
 
110
        my $in_count   = 0;
111
        my $out_count  = 0;
112
        my $in_length  = 0;
113
        my $out_length = 0;
114
 
115
        my $color =  5;
116
        my $size  = 10;
117
 
118
 
119
        open(FILE,">${outfile}${mod_name}.sch") or die "No sch directory";
120
 
121
        foreach my $sig ($mod->ports_sorted) {
122
 
123
            my $dir       =  $sig->direction;
124
            my $data_type =  $sig->data_type;
125
            my $sig_name  =  $sig->name;
126
            $data_type  =~ s/reg //;
127
            $data_type  =~ s/reg//;
128
 
129
 
130
 
131
 
132
 
133
 
134
            if($data_type)
135
              {
136
              $pin_name = "$sig_name"."$data_type";
137
              if("in" eq  $dir)
138
                {
139
                push(@invads,$pin_name);
140
                $in_count = $in_count+1;
141
                if( length($pin_name) > $in_length) { $in_length =  length($pin_name)};
142
                }
143
              if("out" eq  $dir)
144
                {
145
                push(@outvads,$pin_name);
146
                $out_count = $out_count+1;
147
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
148
                }
149
              if("inout" eq  $dir)
150
                {
151
                push(@inoutvads,$pin_name);
152
                $in_count = $in_count+1;
153
                if( length($pin_name) > $in_length){  $in_length =  length($pin_name)            }
154
                }
155
 
156
              }
157
            else
158
              {
159
              $pin_name = $sig_name;
160
              if("in" eq  $dir)
161
                {
162
                push(@inpads,$pin_name);
163
                $in_count = $in_count+1;
164
                if( length($pin_name) > $in_length){  $in_length =  length($pin_name)            }
165
                }
166
              if("out" eq  $dir)
167
                {
168
                push(@outpads,$pin_name);
169
                $out_count = $out_count+1;
170
                if( length($pin_name) > $out_length){  $out_length =  length($pin_name)            }
171
                }
172
 
173
              if("inout" eq  $dir)
174
                {
175
                push(@inoutpads,$pin_name);
176
                $in_count = $in_count+1;
177
                if( length($pin_name) > $in_length){  $in_length =  length($pin_name)            }
178
              }
179
 
180
 
181
           };
182
 
183
 
184
        }
185
 
186
        my $max_pins;
187
 
188
        if($in_count > $out_count) {$max_pins = $in_count ;} else  {$max_pins = $out_count ;}
189
 
190
        my $in_edg  = ($in_length)*10*$size +200;
191
        my $in_pad  = ($in_length)*10*$size +200;
192
        my $out_edg = ($in_length +$out_length)*10*$size +2500;
193
        my $out_pad = ($in_length +$out_length)*10*$size +1500;
194
 
195
        printf FILE ("v 20100214 1\n");
196
 
197
        printf  ("%s\n", $mod->name);
198
 
199
         my $pin_y = 300;
200
 
201
         while( $name =pop(@invads))
202
          {
203
         printf FILE ("C $in_pad $pin_y 1 0 0 in_port_v.sym   \n{\nT $in_edg $pin_y $color $size 1 1 0 6 1 1\nrefdes=%s\n}\n",$name);
204
         $pin_y = $pin_y +400;
205
          }
206
 
207
 
208
         while( $name =pop(@inpads))
209
          {
210
           printf FILE ("C $in_pad $pin_y 1 0 0 in_port.sym  \n{\nT $in_edg $pin_y $color $size 1 1 0 6 1 1 \nrefdes=%s\n}\n",$name);
211
           $pin_y = $pin_y +400;
212
          }
213
 
214
 
215
 
216
         while( $name =pop(@inoutvads))
217
          {
218
         printf FILE ("C $in_pad $pin_y 1 0 0 io_port_v.sym   \n{\nT $in_edg $pin_y $color $size 1 1 0 6 1 1\nrefdes=%s\n}\n",$name);
219
         $pin_y = $pin_y +400;
220
          }
221
 
222
 
223
         while( $name =pop(@inoutpads))
224
          {
225
           printf FILE ("C $in_pad $pin_y 1 0 0 io_port.sym  \n{\nT $in_edg $pin_y $color $size 1 1 0 6 1 1 \nrefdes=%s\n}\n",$name);
226
           $pin_y = $pin_y +400;
227
          }
228
 
229
 
230
 
231
 
232
         $pin_y = 300;
233
 
234
         while( $name =pop(@outvads))
235
          {
236
           printf FILE ("C $out_pad $pin_y  1 0  0 out_port_v.sym\n{\nT $out_edg $pin_y $color  $size 1 1 0 0 1 1 \nrefdes=%s\n}\n",$name);
237
           $pin_y = $pin_y +400;
238
          }
239
 
240
 
241
         while( $name =pop(@outpads))
242
          {
243
           printf FILE ("C $out_pad $pin_y  1 0 0 out_port.sym\n{\nT $out_edg $pin_y $color  $size 1 1 0 0 1 1\nrefdes=%s\n}\n",$name);
244
           $pin_y = $pin_y +400;
245
          }
246
 
247
 
248
 
249
 
250
 
251
 
252
        foreach my $cell ($mod->cells_sorted) {
253
            close(FILE);
254
            make_sch ($cell->submod, $cell->name) if $cell->submod;
255
        }
256
    }
257
 
258
 
259
 
260
 
261
 
262
 
263
 
264
1;
265
 
266
 
267
 
268
 
269
 
270
 
271
 

powered by: WebSVN 2.1.0

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