1 |
134 |
jt_eaton |
eval 'exec `which perl` -S $0 ${1+"$@"}'
|
2 |
|
|
if 0;
|
3 |
135 |
jt_eaton |
#/****************************************************************************/
|
4 |
|
|
#/* */
|
5 |
|
|
#/* SOCGEN Design for Reuse toolset */
|
6 |
|
|
#/* */
|
7 |
|
|
#/* Version 1.0.0 */
|
8 |
|
|
#/* */
|
9 |
|
|
#/* Author(s): */
|
10 |
|
|
#/* - John Eaton, z3qmtr45@gmail.com */
|
11 |
|
|
#/* */
|
12 |
|
|
#/****************************************************************************/
|
13 |
|
|
#/* */
|
14 |
|
|
#/* */
|
15 |
|
|
#/* Copyright 2016 John T Eaton */
|
16 |
|
|
#/* */
|
17 |
|
|
#/* Licensed under the Apache License, Version 2.0 (the "License"); */
|
18 |
|
|
#/* you may not use this file except in compliance with the License. */
|
19 |
|
|
#/* You may obtain a copy of the License at */
|
20 |
|
|
#/* */
|
21 |
|
|
#/* http://www.apache.org/licenses/LICENSE-2.0 */
|
22 |
|
|
#/* */
|
23 |
|
|
#/* Unless required by applicable law or agreed to in writing, software */
|
24 |
|
|
#/* distributed under the License is distributed on an "AS IS" BASIS, */
|
25 |
|
|
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
26 |
|
|
#/* See the License for the specific language governing permissions and */
|
27 |
|
|
#/* limitations under the License. */
|
28 |
|
|
#/* */
|
29 |
|
|
#/* */
|
30 |
|
|
#/****************************************************************************/
|
31 |
134 |
jt_eaton |
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
############################################################################
|
35 |
|
|
# General PERL config
|
36 |
|
|
############################################################################
|
37 |
|
|
use Getopt::Long;
|
38 |
|
|
use English;
|
39 |
|
|
use File::Basename;
|
40 |
|
|
use Cwd;
|
41 |
|
|
use XML::LibXML;
|
42 |
|
|
use lib './tools';
|
43 |
|
|
use sys::lib;
|
44 |
|
|
use yp::lib;
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
############################################################################
|
51 |
|
|
### Process the options
|
52 |
|
|
############################################################################
|
53 |
|
|
|
54 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
55 |
|
|
GetOptions("h","help",
|
56 |
|
|
"envidentifier=s" => \$envidentifier,
|
57 |
|
|
"prefix=s" => \$prefix,
|
58 |
|
|
"vendor=s" => \$vendor,
|
59 |
|
|
"library=s" => \$library,
|
60 |
|
|
"component=s" => \$component,
|
61 |
|
|
"version=s" => \$version,
|
62 |
|
|
"configuration=s" => \$configuration,
|
63 |
|
|
"dest_dir=s" => \$dest_dir,
|
64 |
|
|
"view=s" => \$view
|
65 |
|
|
) || die "(use '$program_name -h' for help)";
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
##############################################################################
|
69 |
|
|
## Help option
|
70 |
|
|
##############################################################################
|
71 |
|
|
if ( $opt_h or ($opt_help) )
|
72 |
|
|
{
|
73 |
|
|
print "\n gen_elab_verilogLib -envidentifier *simulation* -prefix /work -vendor vendor_name -library library_name -component component_name -version version_name -dest_dir dest_dir";
|
74 |
|
|
print "\n";
|
75 |
|
|
exit 1;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
##############################################################################
|
80 |
|
|
##
|
81 |
|
|
##############################################################################
|
82 |
|
|
|
83 |
|
|
my $parser = XML::LibXML->new();
|
84 |
|
|
|
85 |
|
|
my $socgen_file = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
|
86 |
|
|
my $ip_name_base_macro = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:ip_name_base_macro/text()")->to_literal;
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
$home = cwd();
|
92 |
|
|
my @search_paths = ();
|
93 |
|
|
my $variant;
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
my @configs = yp::lib::get_component_configs($vendor,$library,$component,$version);
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
print "\n ---GEN_elab_verilogLib -envidentifier $envidentifier -prefix $prefix -vendor $vendor -library $library -component $component -version $version -dest_dir $dest_dir -configuration $configuration \n";
|
108 |
|
|
|
109 |
|
|
foreach my $config (@configs)
|
110 |
|
|
|
111 |
|
|
{
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
print "+++GEN_verilogLib Configuration $config \n";
|
117 |
|
|
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
if($version) {$variant = "${component}_${version}";}
|
127 |
|
|
else {$variant = "${component}";}
|
128 |
|
|
|
129 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
|
130 |
|
|
my $comp_xml_sep = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
|
131 |
|
|
my $module_name = yp::lib::get_module_name($vendor,$library,$component,$version);
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
my $parser = XML::LibXML->new();
|
141 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
if($dest_dir ne "../views")
|
145 |
|
|
{
|
146 |
135 |
jt_eaton |
#print "XXXXXXXXXXXXXXXXXXX Building $view $library $component $verison $variant $dest_dir Dest_dir not ./views \n" ;
|
147 |
134 |
jt_eaton |
}
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
#print "VVVVVVVV Building $view Verilog Lib RTL for $prefix $library $component $verison $variant $dest_dir \n" ;
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
my $path = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}";
|
156 |
|
|
mkdir $path,0755 unless( -e $path );
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
my $path = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines";
|
160 |
|
|
mkdir $path,0755 unless( -e $path );
|
161 |
|
|
|
162 |
|
|
my $path = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists";
|
163 |
|
|
mkdir $path,0755 unless( -e $path );
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
my $path = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}";
|
167 |
|
|
mkdir $path,0755 unless( -e $path );
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
#/**********************************************************************/
|
172 |
|
|
#/* */
|
173 |
|
|
#/* build a `define file for module names */
|
174 |
|
|
#/* */
|
175 |
|
|
#/* */
|
176 |
|
|
#/* */
|
177 |
|
|
#/* */
|
178 |
|
|
#/**********************************************************************/
|
179 |
|
|
|
180 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v";
|
181 |
|
|
open DEFLIST,">$outfile" or die "unable to open $outfile";
|
182 |
|
|
|
183 |
|
|
if(defined $configuration && length $configuration >0 )
|
184 |
|
|
{
|
185 |
|
|
print DEFLIST " \`define $ip_name_base_macro ${module_name}_${configuration} \n";
|
186 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}_${configuration}.MOD";
|
187 |
|
|
open FILELIST,">$outfile" or die "unable to open $outfile";
|
188 |
|
|
}
|
189 |
|
|
else
|
190 |
|
|
{
|
191 |
|
|
print DEFLIST " \`define $ip_name_base_macro ${module_name} \n";
|
192 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD";
|
193 |
|
|
open FILELIST,">$outfile" or die "unable to open $outfile";
|
194 |
|
|
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC";
|
202 |
|
|
open INCLIST,">$outfile" or die "unable to open $outfile";
|
203 |
|
|
|
204 |
|
|
print INCLIST "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v\n";
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
135 |
jt_eaton |
foreach my $comp_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:model/ipxact:views/ipxact:view/ipxact:envIdentifier[./text() = '$envidentifier']"))
|
212 |
134 |
jt_eaton |
{
|
213 |
135 |
jt_eaton |
my($view_name) = $comp_view->findnodes('../ipxact:name/text()')->to_literal ;
|
214 |
|
|
my($view_fileset) = $comp_view->findnodes('../ipxact:fileSetRef/ipxact:localName/text()')->to_literal ;
|
215 |
134 |
jt_eaton |
# print " VVVVVVVVVVVVVL Found $view -- $view_name $view_fileset $dest_dir $configuration \n" ;
|
216 |
|
|
|
217 |
|
|
if($view ne $view_name)
|
218 |
|
|
{
|
219 |
135 |
jt_eaton |
#print "XXXXXXXXXXXXXXXXXXXXX Building $view $view_name not equal $vendor, $library, $component, $version \n" ;
|
220 |
134 |
jt_eaton |
}
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
my @includes = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"include") ;
|
226 |
|
|
|
227 |
|
|
# print " VVVVVVVK $vendor,$library,$component,$version,$view_fileset include $view_name \n";
|
228 |
|
|
|
229 |
|
|
foreach my $include (@includes)
|
230 |
|
|
{
|
231 |
|
|
# print " VVVVVVVJ |${include}| \n";
|
232 |
|
|
print INCLIST "${home}${prefix}/${include}\n";
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
my @modules = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"module") ;
|
236 |
|
|
|
237 |
|
|
foreach my $module (@modules)
|
238 |
|
|
{
|
239 |
|
|
# print " VVVVVVVI |${module}| $configuration \n";
|
240 |
|
|
# need to tag the top module but no others
|
241 |
|
|
|
242 |
|
|
if(defined $configuration && length $configuration >0 )
|
243 |
|
|
{
|
244 |
|
|
$_ = $module;
|
245 |
|
|
if(/(\S+)${component}_${version}/)
|
246 |
|
|
{
|
247 |
|
|
$_ = $module;
|
248 |
|
|
if(/(\S+)${component}_${version}(\S+)/)
|
249 |
|
|
{
|
250 |
|
|
# print "No_TAG $module \n";
|
251 |
|
|
print FILELIST "${home}${prefix}/${module}\n";
|
252 |
|
|
}
|
253 |
|
|
else
|
254 |
|
|
{
|
255 |
|
|
# print " TAG $module \n";
|
256 |
|
|
print FILELIST "${home}${prefix}/${module}_${configuration}\n";
|
257 |
|
|
}
|
258 |
|
|
}
|
259 |
|
|
else
|
260 |
|
|
{
|
261 |
|
|
# print "No_TAG $module \n";
|
262 |
|
|
print FILELIST "${home}${prefix}/${module}\n";
|
263 |
|
|
}
|
264 |
|
|
}
|
265 |
|
|
else
|
266 |
|
|
{
|
267 |
|
|
print FILELIST "${home}${prefix}/${module}\n";
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
my @libraryDirs = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"libraryDir") ;
|
272 |
|
|
|
273 |
|
|
foreach my $libraryDir (@libraryDirs)
|
274 |
|
|
{
|
275 |
|
|
# print " VVVVVVVM |${libraryDir}| \n";
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
#print " VVVVVVVV $envidentifier $view \n" ;
|
289 |
|
|
|
290 |
|
|
|
291 |
|
|
my @filelist = yp::lib::parse_component_brothers("$vendor","$library","$component","$version");
|
292 |
|
|
|
293 |
|
|
foreach $line (@filelist)
|
294 |
|
|
{
|
295 |
|
|
$_ = $line;
|
296 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
297 |
|
|
{
|
298 |
|
|
$new_library = $2;
|
299 |
|
|
$new_component = $3;
|
300 |
|
|
$new_vendor = $1;
|
301 |
|
|
$new_version = $4;
|
302 |
|
|
|
303 |
|
|
# print " VVVVVVVVVVVVVVVVVVVVV Brother $new_vendor $new_library $new_component $new_version \n" ;
|
304 |
|
|
|
305 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));
|
306 |
|
|
|
307 |
135 |
jt_eaton |
foreach my $comp_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:model/ipxact:views/ipxact:view/ipxact:envIdentifier[./text() = '$envidentifier']"))
|
308 |
134 |
jt_eaton |
{
|
309 |
135 |
jt_eaton |
my($view_name) = $comp_view->findnodes('../ipxact:name/text()')->to_literal ;
|
310 |
|
|
my($view_fileset) = $comp_view->findnodes('../ipxact:fileSetRef/ipxact:localName/text()')->to_literal ;
|
311 |
134 |
jt_eaton |
# print " VVVVVVVVVVVVVV Found $view_name $view_fileset \n" ;
|
312 |
|
|
|
313 |
|
|
#/**********************************************************************/
|
314 |
|
|
#/* */
|
315 |
|
|
#/* build a fileset in the following order */
|
316 |
|
|
#/* */
|
317 |
|
|
#/* deflist for module names */
|
318 |
|
|
#/* all include files */
|
319 |
|
|
#/* all module files */
|
320 |
|
|
#/* */
|
321 |
|
|
#/* */
|
322 |
|
|
#/**********************************************************************/
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
135 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//ipxact:fileSets/ipxact:fileSet/ipxact:file/ipxact:name"))
|
328 |
134 |
jt_eaton |
{
|
329 |
|
|
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
330 |
135 |
jt_eaton |
my($file_logicalname) = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
|
331 |
|
|
my($file_type) = $i_name ->findnodes('../ipxact:fileType/text()')->to_literal ;
|
332 |
|
|
my($file_usertype) = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
|
333 |
|
|
my($view_file) = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;
|
334 |
134 |
jt_eaton |
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
if(($file_usertype eq "libraryDir")&& ($view_file eq $view_fileset) && ($file_type eq "verilogSource") )
|
338 |
|
|
{
|
339 |
|
|
# print " VVVVVMVV ${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
|
340 |
|
|
push @search_paths, "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}";
|
341 |
|
|
};
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
if(($file_usertype eq "module") && ($view_file eq $view_fileset) && ($file_type eq "verilogSource") )
|
345 |
|
|
{
|
346 |
|
|
|
347 |
|
|
# print " VVVVVIVV ${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
|
348 |
|
|
# print FILELIST "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
|
349 |
|
|
if($file_logicalname )
|
350 |
|
|
{
|
351 |
|
|
print DEFLIST sprintf( "\`define %s _%s\n", uc($file_logicalname) , $file_logicalname );
|
352 |
|
|
}
|
353 |
|
|
};
|
354 |
|
|
}
|
355 |
|
|
}
|
356 |
|
|
}
|
357 |
|
|
}
|
358 |
|
|
#/**********************************************************************/
|
359 |
|
|
#/* */
|
360 |
|
|
#/* Every leaf cell is processed through a the verilog preprocessor */
|
361 |
|
|
#/* to customize the module names,remove all verilog tic(`) statements */
|
362 |
|
|
#/* and to create seperate versions for simulation and synthesys */
|
363 |
|
|
#/* */
|
364 |
|
|
#/* */
|
365 |
|
|
#/**********************************************************************/
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
|
369 |
|
|
if(defined $configuration && length $configuration >0 )
|
370 |
|
|
{
|
371 |
|
|
$file_out = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}_${configuration}.v";
|
372 |
|
|
}
|
373 |
|
|
else
|
374 |
|
|
{
|
375 |
|
|
$file_out = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}.v";
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
if( -e $file_out )
|
379 |
|
|
{
|
380 |
|
|
$cmd ="rm $file_out \n";
|
381 |
|
|
if (system($cmd)) {}
|
382 |
|
|
};
|
383 |
|
|
|
384 |
|
|
my $cmd_path;
|
385 |
|
|
|
386 |
|
|
foreach $search_path (@search_paths)
|
387 |
|
|
{
|
388 |
|
|
$cmd_path = " $cmd_path -I${search_path} " ;
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
if(defined $configuration && length $configuration >0 )
|
395 |
|
|
{
|
396 |
|
|
$cmd ="vppreproc --noline --noblank $cmd_path -f ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC -f ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}_${configuration}.MOD >> $file_out \n";
|
397 |
|
|
}
|
398 |
|
|
else
|
399 |
|
|
{
|
400 |
|
|
$cmd ="vppreproc --noline --noblank $cmd_path -f ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC -f ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD >> $file_out \n";
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
|
405 |
|
|
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
if (system($cmd)) {}
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
1
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
|