Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # ========== Copyright Header Begin ========================================== |
2 | # | |
3 | # OpenSPARC T2 Processor File: uniquify_module,1.0 | |
4 | # Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | # 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | # | |
7 | # * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | # | |
9 | # This program is free software; you can redistribute it and/or modify | |
10 | # it under the terms of the GNU General Public License as published by | |
11 | # the Free Software Foundation; version 2 of the License. | |
12 | # | |
13 | # This program is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with this program; if not, write to the Free Software | |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | # | |
22 | # For the avoidance of doubt, and except that if any non-GPL license | |
23 | # choice is available it will apply instead, Sun elects to use only | |
24 | # the General Public License version 2 (GPLv2) at this time for any | |
25 | # software where a choice of GPL license versions is made | |
26 | # available with the language indicating that GPLv2 or any later version | |
27 | # may be used, or where a choice of which version of the GPL is applied is | |
28 | # otherwise unspecified. | |
29 | # | |
30 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | # CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | # have any questions. | |
33 | # | |
34 | # ========== Copyright Header End ============================================ | |
35 | #! /usr/bin/perl | |
36 | ||
37 | sub Help; | |
38 | ||
39 | MAIN: | |
40 | { | |
41 | #// Help | |
42 | if($#ARGV==-1){Help;exit(-1);} | |
43 | ||
44 | $netlist ; | |
45 | $top = "spc"; | |
46 | ||
47 | ||
48 | for(my $i=0;$i<$#ARGV+1;$i++) | |
49 | { | |
50 | if($ARGV[$i] eq "-netlist") | |
51 | { | |
52 | if($i==$#ARGV){printf (" Missing value for: %s\n",$ARGV[$i]);exit(-1);} | |
53 | $netlist=$ARGV[$i+1]; | |
54 | $i++; | |
55 | } | |
56 | elsif($ARGV[$i] eq "-top") | |
57 | { | |
58 | if($i==$#ARGV){printf(" Missing value for: %s\n",$ARGV[$i]);exit(-1);} | |
59 | $top=$ARGV[$i+1]; | |
60 | $i++; | |
61 | } | |
62 | elsif($ARGV[$i] eq "-h") | |
63 | { | |
64 | Help; | |
65 | exit(-1); | |
66 | } | |
67 | ||
68 | else | |
69 | { | |
70 | printf(" Invalid argument: %s\n",$ARGV[$i]); | |
71 | exit(-1); | |
72 | } | |
73 | } | |
74 | ||
75 | ||
76 | ||
77 | system("mv $netlist $netlist.org"); | |
78 | ||
79 | open(f1,"<$netlist.org"); | |
80 | open(f2,">$netlist") ; | |
81 | ||
82 | @arr = <f1> ; | |
83 | %modh = (); | |
84 | ||
85 | foreach $elem (@arr) { | |
86 | ||
87 | $_ = $elem ; | |
88 | if(/^module/) { | |
89 | ($jnk,$modl,$jnk2) = split (/ /) ; | |
90 | ||
91 | if($modl ne $top) { | |
92 | $modh{$modl} = 1 ; | |
93 | } | |
94 | } | |
95 | else { | |
96 | } | |
97 | ||
98 | } | |
99 | ||
100 | foreach $elem (@arr) { | |
101 | $_ = $elem ; | |
102 | ||
103 | if(/^module/ ) { | |
104 | ($jnk,$name,$jnk2) = split (/ /) ; | |
105 | if($modh{$name} == 1) { | |
106 | $nname = "$top"."_syn_"."$name"; | |
107 | s/$name/$nname/ ; | |
108 | print f2 ; | |
109 | } | |
110 | else { print f2 ; } | |
111 | } | |
112 | elsif(/ .* \(/) { | |
113 | s/^ //; | |
114 | ($name,$jnk2) = split (/ /) ; | |
115 | if($modh{$name} == 1) { | |
116 | $nname = "$top"."_syn_"."$name"; | |
117 | s/$name/$nname/ ; | |
118 | print f2 ; | |
119 | } | |
120 | else { | |
121 | print f2 ; | |
122 | } | |
123 | } | |
124 | else { | |
125 | print f2 ; | |
126 | } | |
127 | ||
128 | } | |
129 | ||
130 | close (f2); | |
131 | close (f1) ; | |
132 | exit(0); | |
133 | } | |
134 | ||
135 | ||
136 | sub Help | |
137 | { | |
138 | printf("uniquify_module \n"); | |
139 | printf("----------\n"); | |
140 | printf("Utility to uniqfy the module names in gate level netlist \n"); | |
141 | printf(" -netlist <path to netlist> : required, netlist files\n"); | |
142 | printf(" -top <module> : required, top module \n"); | |
143 | printf(" -h : optional, help\n"); | |
144 | } | |
145 | ||
146 |