Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perlmod / uniquify_module,1.0
CommitLineData
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
37sub Help;
38
39MAIN:
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
77system("mv $netlist $netlist.org");
78
79open(f1,"<$netlist.org");
80open(f2,">$netlist") ;
81
82@arr = <f1> ;
83%modh = ();
84
85foreach $elem (@arr) {
86
87$_ = $elem ;
88if(/^module/) {
89($jnk,$modl,$jnk2) = split (/ /) ;
90
91if($modl ne $top) {
92$modh{$modl} = 1 ;
93 }
94}
95else {
96 }
97
98}
99
100foreach $elem (@arr) {
101$_ = $elem ;
102
103if(/^module/ ) {
104($jnk,$name,$jnk2) = split (/ /) ;
105if($modh{$name} == 1) {
106$nname = "$top"."_syn_"."$name";
107s/$name/$nname/ ;
108print f2 ;
109}
110else { print f2 ; }
111}
112elsif(/ .* \(/) {
113s/^ //;
114($name,$jnk2) = split (/ /) ;
115if($modh{$name} == 1) {
116$nname = "$top"."_syn_"."$name";
117s/$name/$nname/ ;
118print f2 ;
119}
120else {
121print f2 ;
122}
123}
124else {
125print f2 ;
126}
127
128}
129
130close (f2);
131close (f1) ;
132 exit(0);
133}
134
135
136sub 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