Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perlmod / rsynp,1.0
CommitLineData
86530b38
AT
1#######################################################################
2# Run Synplicity script
3#
4# rsynp -help for help
5#######################################################################
6
7
8use warnings;
9use strict;
10use Cwd;
11use Cwd 'chdir';
12use Getopt::Long ;
13
14$| = 1;
15
16$SIG{__DIE__} = \&sighandler ;
17
18#######################################################################
19# Global variables
20#######################################################################
21
22my $prg = $0;
23$prg =~ s/.*\/// ;
24$prg =~ s/,.*// ;
25
26my $all = 0;
27my $flat = 0;
28my $syn_q = "/bin/sh";
29my $device = "XC4VLX200";
30my $blk_list = "";
31my $blk_dir;
32
33my @blocks = ();
34my @block_list = ();
35
36$blk_list = $ENV{DV_ROOT};
37$blk_list .= "/design/sys/synplicity/block.list";
38
39#######################################################################
40# Check command line options
41#######################################################################
42
43foreach my $argv (@ARGV)
44{
45 if ($argv =~ /-all/)
46 {
47 $all = 1;
48 } elsif (($argv =~ /-h/) or ($argv =~ /-help/))
49 {
50 &usage;
51 exit(0);
52 } elsif ($argv =~ /-syn_q_command/)
53 {
54 $syn_q = $argv;
55 $syn_q =~ s/-syn_q_command=(.*)/$1/ ;
56 } elsif ($argv =~ /-device/)
57 {
58 $device = $argv;
59 $device =~ s/-device=(.*)/$1/ ;
60 } elsif ($argv =~ /-flat/) {
61 $flat = 1;
62 } else
63 {
64 push @blocks, $argv;
65 }
66}
67
68my $count = 0;
69
70open (BLK_IN, "< $blk_list") or die ("DIE. could not open $blk_list");
71if ($all) {
72 while (<BLK_IN>)
73 {
74 my $line = $_ ;
75 $line =~ s/\s+$//;
76 $count++;
77 push @block_list, $line ;
78 }
79 print "$prg: Running Synplicity for all $count modules\n";
80} else {
81 my @all_blocks = <BLK_IN>;
82 foreach my $block (@blocks)
83 {
84 my (@search) = grep (/$block/, @all_blocks);
85 foreach my $line (@search)
86 {
87 $line =~ s/\s+$//;
88 push @block_list, $line ;
89 $count++;
90 }
91 }
92 if ($count) {
93 print "$prg: Running Synplicity for $count modules\n";
94 } else {
95 print "$prg: No matching modules found.\n";
96 &usage;
97 }
98}
99close(BLK_IN);
100
101# check the memory list and add memory to block list if needed
102
103foreach my $block (@block_list) {
104 $blk_dir = $ENV{DV_ROOT};
105 $blk_dir .= "/design/sys/iop/$block";
106 $blk_dir .= "/synplicity";
107 my $mod_name = $block;
108 $mod_name =~ s/.*\/// ;
109 my $mlist = $blk_dir;
110 $mlist .= "/$mod_name";
111 $mlist .= ".mlist";
112 if ((!$flat) && ( -f $mlist )) {
113 print "$prg: $mlist found.\n";
114 open (BLK_IN, "< $mlist") or
115 die("DIE. could not open $mlist");
116 while (<BLK_IN>)
117 {
118 my $line = $_ ;
119 $line =~ s/\s+$//;
120 $count++;
121 my $sub_blk = $ENV{DV_ROOT};
122 $sub_blk .= "/design/sys/iop/$line";
123 $sub_blk .= "/synplicity";
124 my $sub_blk_mod = $sub_blk;
125 my $line_mod = $line;
126 $line_mod =~ s/.*\/// ;
127 $sub_blk_mod .= "/$device/$line_mod";
128 $sub_blk_mod .= ".vm";
129 if ( -f $sub_blk_mod ) {
130 print "$prg: Pre-compiled $line found.\n";
131 } else {
132 my $cmd = "rsynp -device='$device' ";
133 $cmd .= "$line";
134 print "$prg: Pre-compiled $line not found.\n";
135 print "$prg: Running $cmd\n";
136 system($cmd);
137 }
138 }
139 close(BLK_IN);
140 }
141}
142
143foreach my $block (@block_list) {
144 print "$prg: Running Synplicity for $block\n";
145 my $cmd = $syn_q;
146 $blk_dir = $ENV{DV_ROOT};
147 $blk_dir .= "/design/sys/iop/$block";
148 $blk_dir .= "/synplicity";
149 chdir $blk_dir;
150 my $mod_name = $block;
151 $mod_name =~ s/.*\/// ;
152 &create_prj_file($mod_name);
153 print "$prg: module name $mod_name\n";
154 $cmd .= " $ENV{DV_ROOT}/tools/bin/synp_command";
155 system($cmd);
156
157 # if ed script exists, run it
158
159 my $sed_scr = $mod_name;
160 $sed_scr .= ".sed";
161 if (-f $sed_scr) {
162 my $cmd = "/bin/ed ";
163 $cmd .= "$device/$mod_name";
164 $cmd .= ".vm < $sed_scr";
165 print "$prg: Running script: $cmd\n";
166 system($cmd);
167 }
168}
169
170#######################################################################
171sub create_prj_file {
172 my $mod = shift;
173 my $flist = $mod;
174 $flist .= ".flist";
175
176 open (FLIST_IN, "< $flist") or die ("DIE. could not open $flist");
177 open OUT, ">proj.prj";
178 print OUT "# Synplicity Project File\n\n";
179 print OUT "set topmodule $mod\n";
180 print OUT "set rev $device\n";
181 print OUT "set dv_root [get_env DV_ROOT]\n\n";
182
183 while (<FLIST_IN>) {
184 next if(/^\/\//);
185 next if(/^#/);
186 chop;
187 if (/design/) {
188 print OUT "add_file -verilog \$dv_root/";
189 print OUT;
190 print OUT "\n";
191 next;
192 }
193 if (/lib/) {
194 print OUT "add_file -verilog \$dv_root/";
195 print OUT;
196 print OUT "\n";
197 next;
198 }
199 }
200 close FLIST_IN;
201
202 if ($flat) {
203 my $fmlist = $mod;
204 $fmlist .= ".fmlist";
205 if ( -f $fmlist ) {
206 open (FLIST_IN, "< $fmlist") or die ("DIE. could not open $fmlist");
207 while (<FLIST_IN>) {
208 next if(/^\/\//);
209 next if(/^#/);
210 chop;
211 if (/design/) {
212 print OUT "add_file -verilog \$dv_root/";
213 print OUT;
214 print OUT "\n";
215 next;
216 }
217 if (/lib/) {
218 print OUT "add_file -verilog \$dv_root/";
219 print OUT;
220 print OUT "\n";
221 next;
222 }
223 }
224 close FLIST_IN;
225 }
226 } else {
227 my $mlist = $mod;
228 $mlist .= ".mlist";
229 if ( -f $mlist ) {
230 print "$prg: $mlist found.\n";
231 open (BLK_IN, "< $mlist") or
232 die("DIE. could not open $mlist");
233 while (<BLK_IN>)
234 {
235 my $line = $_ ;
236 $line =~ s/\s+$//;
237 $count++;
238 my $sub_blk = $ENV{DV_ROOT};
239 $sub_blk .= "/design/sys/iop/$line";
240 $sub_blk .= "/synplicity";
241 my $sub_blk_mod = $sub_blk;
242 my $line_mod = $line;
243 $line_mod =~ s/.*\/// ;
244 $sub_blk_mod .= "/$device/$line_mod";
245 $sub_blk_mod .= ".vm";
246 if ( -f $sub_blk_mod ) {
247 print OUT "add_file -verilog $sub_blk_mod\n";
248 }
249 }
250
251 close(BLK_IN);
252 }
253 }
254
255 print OUT "\nsource \$dv_root/design/sys/synplicity/env.prj\n";
256 print OUT "source \$dv_root/design/sys/synplicity/$device.prj\n";
257 my $prj_file = $mod;
258 $prj_file .= ".prj";
259 if ( -f $prj_file ) {
260 print OUT "source $prj_file\n";
261 }
262 print OUT "source \$dv_root/design/sys/synplicity/pre_syn_settings.prj\n";
263 close OUT;
264
265}
266#######################################################################
267sub usage {
268 print "\n$prg : Run Synplicity for OpenSPARC T1\n\n";
269 print "Options are :\n";
270 print " -all \n\tto run Synplicity for all blocks\n";
271 print " -h / -help\n\tto print help\n";
272 print " -syn_q_command='Your job Queue command'\n\tto specify Job queue command\n";
273 print " -device='Target Device'\n\tto specify Target FPGA device\n";
274 print " -flat \n\tTo run synthesis flat, must use this for Altera parts.\n";
275 print " block_list :\n\tspecify list of blocks to synthesize\n\n";
276 print "Examples:\n\n";
277 print "\t$prg -all\n\t$prg -device=XC4VLX200 sparc\n";
278 print "\t$prg -flat -device=EP2S180 sparc\n\n";
279}
280#######################################################################