1 |
94 |
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 |
|
|
#/* Traverse a socgen project and link it */
|
15 |
|
|
#/* */
|
16 |
|
|
#/* */
|
17 |
|
|
#/* Author(s): */
|
18 |
|
|
#/* - John Eaton, jt_eaton@opencores.org */
|
19 |
|
|
#/* */
|
20 |
|
|
#/**********************************************************************/
|
21 |
|
|
#/* */
|
22 |
99 |
jt_eaton |
#/* Copyright (C) <2010-2011> */
|
23 |
94 |
jt_eaton |
#/* */
|
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 |
|
|
|
48 |
|
|
############################################################################
|
49 |
|
|
# General PERL config
|
50 |
|
|
############################################################################
|
51 |
|
|
use Getopt::Long;
|
52 |
|
|
use English;
|
53 |
|
|
use File::Basename;
|
54 |
99 |
jt_eaton |
use Cwd;
|
55 |
|
|
use XML::LibXML;
|
56 |
94 |
jt_eaton |
|
57 |
99 |
jt_eaton |
|
58 |
94 |
jt_eaton |
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
############################################################################
|
64 |
|
|
### Process the options
|
65 |
|
|
############################################################################
|
66 |
|
|
|
67 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
68 |
99 |
jt_eaton |
GetOptions("h","help",
|
69 |
|
|
"vendor=s" => \$vendor,
|
70 |
94 |
jt_eaton |
"project=s" => \$project,
|
71 |
|
|
"lib_comp_sep=s" => \$lib_comp_sep,
|
72 |
|
|
"component=s" => \$component,
|
73 |
|
|
"comp_xml_sep=s" => \$comp_xml_sep,
|
74 |
|
|
"variant=s" => \$variant
|
75 |
|
|
) || die "(use '$program_name -h' for help)";
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
##############################################################################
|
79 |
|
|
## Help option
|
80 |
|
|
##############################################################################
|
81 |
99 |
jt_eaton |
if ( $opt_h or $opt_help )
|
82 |
94 |
jt_eaton |
{
|
83 |
99 |
jt_eaton |
print "\n type soc_link_child -vendor vendor_name -project project_name -lib_comp_sep /ip/ -component component_name -comp_xml_sep /rtl/xml/ -variant variant_name new_seperator";
|
84 |
94 |
jt_eaton |
print "\n";
|
85 |
|
|
exit 1;
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
##############################################################################
|
90 |
|
|
##
|
91 |
|
|
##############################################################################
|
92 |
|
|
|
93 |
|
|
$home = cwd();
|
94 |
|
|
my $new_sep = $ARGV[0];
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
#/*********************************************************************************************/
|
100 |
|
|
#/ */
|
101 |
|
|
#/ */
|
102 |
|
|
#/ */
|
103 |
|
|
#/ */
|
104 |
|
|
#/ */
|
105 |
|
|
#/ */
|
106 |
|
|
#/*********************************************************************************************/
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
my @filelist_hier = ( );
|
111 |
|
|
my @filelist = ( );
|
112 |
|
|
|
113 |
|
|
@filelist_hier = ( );
|
114 |
|
|
@filelist = ( );
|
115 |
99 |
jt_eaton |
@filelist = parse_hier("$vendor","$project","$component",$new_sep,"$variant");
|
116 |
94 |
jt_eaton |
@filelist = trim_sort(@filelist);
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
foreach $line (@filelist)
|
121 |
|
|
{
|
122 |
|
|
$_ = $line;
|
123 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
124 |
|
|
{
|
125 |
|
|
$new_proj = $1;
|
126 |
|
|
$new_comp = $2;
|
127 |
|
|
$xxx_sep = $3;
|
128 |
|
|
$new_variant = $4;
|
129 |
|
|
if($new_proj ne $project ) { &link_child( $project,$new_comp, $new_proj ); }
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
#/*********************************************************************************************/
|
139 |
|
|
#/ */
|
140 |
|
|
#/ */
|
141 |
|
|
#/ */
|
142 |
|
|
#/ */
|
143 |
|
|
#/ */
|
144 |
|
|
#/ */
|
145 |
|
|
#/*********************************************************************************************/
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
sub link_child {
|
150 |
|
|
my $project = shift;
|
151 |
|
|
my $child_parent = shift;
|
152 |
|
|
my $child_family = shift;
|
153 |
|
|
my $path = "work/${project}/children";
|
154 |
|
|
mkdir $path,0755 unless( -e $path );
|
155 |
|
|
my $path = "work/${project}/children/${child_family}";
|
156 |
|
|
mkdir $path,0755 unless( -e $path );
|
157 |
|
|
my $path = "work/${project}/children/${child_family}/bin";
|
158 |
|
|
mkdir $path,0755 unless( -e $path );
|
159 |
99 |
jt_eaton |
$root = "${home}/projects/${vendor}/${child_family}/bin";
|
160 |
94 |
jt_eaton |
$dest = "${home}/work/${project}/children/${child_family}/bin";
|
161 |
|
|
&link_dir( "$root", "$dest" );
|
162 |
|
|
symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/children/${child_family}/bin/Makefile.root");
|
163 |
|
|
symlink( "${home}/tools/bin/Makefile", "${home}/work/${project}/children/${child_family}/bin/Makefile");
|
164 |
|
|
my $path = "work/${project}/children/${child_family}/sw";
|
165 |
|
|
mkdir $path,0755 unless( -e $path );
|
166 |
99 |
jt_eaton |
$root = "${home}/projects/${vendor}/${child_family}/sw";
|
167 |
94 |
jt_eaton |
$dest = "${home}/work/${project}/children/${child_family}/sw";
|
168 |
|
|
&link_dir( "$root", "$dest" );
|
169 |
|
|
my $path = "work/${project}/children/${child_family}/ip";
|
170 |
|
|
mkdir $path,0755 unless( -e $path );
|
171 |
|
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}";
|
172 |
|
|
mkdir $path,0755 unless( -e $path );
|
173 |
|
|
|
174 |
|
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
175 |
|
|
mkdir $path,0755 unless( -e $path );
|
176 |
99 |
jt_eaton |
$root = "${home}/projects/${vendor}/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
177 |
94 |
jt_eaton |
$dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
178 |
|
|
&link_dir( "$root", "$dest" );
|
179 |
115 |
jt_eaton |
|
180 |
|
|
|
181 |
|
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/ip-xact";
|
182 |
|
|
mkdir $path,0755 unless( -e $path );
|
183 |
|
|
$root = "${home}/projects/${vendor}/${child_family}${lib_comp_sep}${child_parent}/ip-xact";
|
184 |
|
|
$dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/ip-xact";
|
185 |
|
|
&link_dir( "$root", "$dest" );
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
94 |
jt_eaton |
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc";
|
190 |
|
|
mkdir $path,0755 unless( -e $path );
|
191 |
115 |
jt_eaton |
|
192 |
99 |
jt_eaton |
symlink( "${home}/projects/${vendor}/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v", "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v");
|
193 |
94 |
jt_eaton |
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
#/*********************************************************************************************/
|
198 |
|
|
#/ */
|
199 |
|
|
#/ */
|
200 |
|
|
#/ */
|
201 |
|
|
#/ */
|
202 |
|
|
#/ */
|
203 |
|
|
#/ */
|
204 |
|
|
#/*********************************************************************************************/
|
205 |
|
|
|
206 |
|
|
# recursively map directory information
|
207 |
|
|
|
208 |
|
|
sub link_dir {
|
209 |
|
|
my $src = shift;
|
210 |
|
|
my $dest = shift;
|
211 |
|
|
return unless( -e $src );
|
212 |
|
|
|
213 |
|
|
if( -d $src )
|
214 |
|
|
{
|
215 |
|
|
|
216 |
|
|
mkdir $dest,0755;
|
217 |
|
|
my @contents = ( );
|
218 |
|
|
opendir( DIR, $src );
|
219 |
|
|
while( my $item = readdir( DIR ))
|
220 |
|
|
{
|
221 |
|
|
next if( $item eq '.' or $item eq '..' or $item eq '.svn' );
|
222 |
|
|
push( @contents, $item );
|
223 |
|
|
}
|
224 |
|
|
closedir( DIR );
|
225 |
|
|
|
226 |
|
|
# recurse on items in the directory
|
227 |
|
|
foreach my $item ( @contents ) { &link_dir("$src/$item", "$dest/$item" );}
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
}
|
231 |
|
|
else {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
#/*********************************************************************************************/
|
238 |
|
|
#/ */
|
239 |
|
|
#/ */
|
240 |
|
|
#/ */
|
241 |
|
|
#/ */
|
242 |
|
|
#/ */
|
243 |
|
|
#/ */
|
244 |
|
|
#/*********************************************************************************************/
|
245 |
|
|
|
246 |
|
|
sub trim_sort {
|
247 |
|
|
my @output_files = @_;
|
248 |
|
|
my %trim = ();
|
249 |
|
|
foreach $descriptor (@output_files) { $trim{$descriptor} = 1; }
|
250 |
|
|
my @k = keys %trim;
|
251 |
|
|
@output_files = sort(sort @k);
|
252 |
|
|
return(@output_files);
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
#/*********************************************************************************************/
|
258 |
|
|
#/ */
|
259 |
|
|
#/ */
|
260 |
|
|
#/ */
|
261 |
|
|
#/ */
|
262 |
|
|
#/ */
|
263 |
|
|
#/ */
|
264 |
|
|
#/*********************************************************************************************/
|
265 |
|
|
|
266 |
|
|
sub parse_hier
|
267 |
|
|
{
|
268 |
|
|
my @params = @_;
|
269 |
|
|
my $variant = pop(@params);
|
270 |
|
|
my $comp_xml = pop(@params);
|
271 |
|
|
my $component = pop(@params);
|
272 |
|
|
my $project = pop(@params);
|
273 |
99 |
jt_eaton |
my $vendor = pop(@params);
|
274 |
94 |
jt_eaton |
|
275 |
|
|
$home = cwd();
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
my $parser = XML::LibXML->new();
|
280 |
|
|
|
281 |
107 |
jt_eaton |
my $spirit_component_file = $parser->parse_file("${home}/projects/${vendor}/${project}${lib_comp_sep}${component}${comp_xml}${variant}.xml");
|
282 |
|
|
push(@filelist_hier,"::${project}::${component}::${comp_xml}::${variant}::");
|
283 |
94 |
jt_eaton |
|
284 |
|
|
|
285 |
|
|
|
286 |
107 |
jt_eaton |
|
287 |
|
|
foreach my $comp_view ($spirit_component_file->findnodes('//spirit:component/spirit:model/spirit:views/spirit:view'))
|
288 |
|
|
{
|
289 |
|
|
my($view_name) = $comp_view->findnodes('./spirit:name/text()')->to_literal ;
|
290 |
|
|
if($view_name eq "Hierarchical")
|
291 |
|
|
{
|
292 |
|
|
my($hier_ref_vendor) = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:vendor')->to_literal ;
|
293 |
|
|
my($hier_ref_library) = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:library')->to_literal ;
|
294 |
|
|
my($hier_ref_component) = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:name')->to_literal ;
|
295 |
|
|
my($hier_ref_version) = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:version')->to_literal ;
|
296 |
|
|
my $spirit_designCfg_file
|
297 |
|
|
= $parser->parse_file("${home}/projects/${hier_ref_vendor}/${hier_ref_library}${lib_comp_sep}${hier_ref_component}/ip-xact/${hier_ref_component}_${hier_ref_version}.xml");
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
|
301 |
|
|
{
|
302 |
|
|
my($hier_xref_vendor) = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
|
303 |
|
|
my($hier_xref_library) = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
|
304 |
|
|
my($hier_xref_component) = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
|
305 |
|
|
my($hier_xref_version) = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
|
306 |
|
|
$spirit_design_file = $parser->parse_file("${home}/projects/${hier_xref_vendor}/${hier_xref_library}${lib_comp_sep}${hier_xref_component}${comp_xml}${hier_xref_component}_${hier_xref_version}.xml");
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
101 |
jt_eaton |
#/*********************************************************************************************/
|
323 |
|
|
#/ */
|
324 |
|
|
#/ Create filelists for simulation, code coverage, linting and synthesis */
|
325 |
|
|
#/ */
|
326 |
|
|
#/ */
|
327 |
|
|
#/*********************************************************************************************/
|
328 |
94 |
jt_eaton |
|
329 |
|
|
|
330 |
101 |
jt_eaton |
foreach my $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
|
331 |
94 |
jt_eaton |
{
|
332 |
101 |
jt_eaton |
my($vendor_name) = $i_name ->to_literal ;
|
333 |
|
|
my($library_name) = $i_name ->findnodes('../@spirit:library')->to_literal ;
|
334 |
|
|
my($component_name) = $i_name ->findnodes('../@spirit:name')->to_literal ;
|
335 |
|
|
my($version_name) = $i_name ->findnodes('../@spirit:version')->to_literal ;
|
336 |
94 |
jt_eaton |
|
337 |
|
|
my $variant_name = "";
|
338 |
|
|
if($version_name) {$variant_name = "${component_name}_${version_name}";}
|
339 |
|
|
else {$variant_name = "${component_name}";}
|
340 |
|
|
|
341 |
99 |
jt_eaton |
my @filelist_sub = parse_hier("$vendor_name","$library_name","$component_name","$comp_xml_sep","$variant_name");
|
342 |
94 |
jt_eaton |
foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
|
343 |
|
|
|
344 |
|
|
}
|
345 |
|
|
|
346 |
101 |
jt_eaton |
|
347 |
|
|
|
348 |
107 |
jt_eaton |
}
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
101 |
jt_eaton |
|
352 |
|
|
|
353 |
|
|
|
354 |
94 |
jt_eaton |
@filelist_hier = trim_sort(@filelist_hier);
|
355 |
|
|
return(@filelist_hier);
|
356 |
|
|
}
|