| 1 |
131 |
jt_eaton |
eval 'exec `which perl` -S $0 ${1+"$@"}'
|
| 2 |
|
|
if 0;
|
| 3 |
|
|
|
| 4 |
135 |
jt_eaton |
#/****************************************************************************/
|
| 5 |
|
|
#/* */
|
| 6 |
|
|
#/* SOCGEN Design for Reuse toolset */
|
| 7 |
|
|
#/* */
|
| 8 |
|
|
#/* Version 1.0.0 */
|
| 9 |
|
|
#/* */
|
| 10 |
|
|
#/* Author(s): */
|
| 11 |
|
|
#/* - John Eaton, z3qmtr45@gmail.com */
|
| 12 |
|
|
#/* */
|
| 13 |
|
|
#/****************************************************************************/
|
| 14 |
|
|
#/* */
|
| 15 |
|
|
#/* */
|
| 16 |
|
|
#/* Copyright 2016 John T Eaton */
|
| 17 |
|
|
#/* */
|
| 18 |
|
|
#/* Licensed under the Apache License, Version 2.0 (the "License"); */
|
| 19 |
|
|
#/* you may not use this file except in compliance with the License. */
|
| 20 |
|
|
#/* You may obtain a copy of the License at */
|
| 21 |
|
|
#/* */
|
| 22 |
|
|
#/* http://www.apache.org/licenses/LICENSE-2.0 */
|
| 23 |
|
|
#/* */
|
| 24 |
|
|
#/* Unless required by applicable law or agreed to in writing, software */
|
| 25 |
|
|
#/* distributed under the License is distributed on an "AS IS" BASIS, */
|
| 26 |
|
|
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
| 27 |
|
|
#/* See the License for the specific language governing permissions and */
|
| 28 |
|
|
#/* limitations under the License. */
|
| 29 |
|
|
#/* */
|
| 30 |
|
|
#/* */
|
| 31 |
|
|
#/****************************************************************************/
|
| 32 |
131 |
jt_eaton |
|
| 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 |
|
|
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
| 47 |
|
|
|
| 48 |
|
|
|
| 49 |
|
|
############################################################################
|
| 50 |
|
|
### Process the options
|
| 51 |
|
|
############################################################################
|
| 52 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
| 53 |
|
|
GetOptions("h","help",
|
| 54 |
|
|
"envidentifier=s" => \$envidentifier,
|
| 55 |
|
|
"prefix=s" => \$prefix,
|
| 56 |
|
|
"vendor=s" => \$vendor,
|
| 57 |
|
|
"library=s" => \$library,
|
| 58 |
|
|
"component=s" => \$component,
|
| 59 |
|
|
"version=s" => \$version,
|
| 60 |
|
|
"top_file=s" => \$top_file,
|
| 61 |
|
|
"suffix=s" => \$suffix,
|
| 62 |
|
|
"leader=s" => \$leader,
|
| 63 |
|
|
"overlay_src_ven=s" => \$overlay_src_ven,
|
| 64 |
|
|
"overlay_src_lib=s" => \$overlay_src_lib,
|
| 65 |
|
|
"overlay_des_ven=s" => \$overlay_des_ven,
|
| 66 |
|
|
"overlay_des_lib=s" => \$overlay_des_lib,
|
| 67 |
|
|
"top","top_lib"
|
| 68 |
|
|
) || die "(use '$program_name -h' for help)";
|
| 69 |
|
|
|
| 70 |
|
|
|
| 71 |
|
|
|
| 72 |
|
|
##############################################################################
|
| 73 |
|
|
## Help option
|
| 74 |
|
|
##############################################################################
|
| 75 |
|
|
if ( $opt_h or $opt_help)
|
| 76 |
|
|
{ print "\n gen_child_filelist -prefix /work -envidentifier *simulation* -vendor vendor_name -library library_name -component component_name -version version_name ";
|
| 77 |
|
|
print "\n";
|
| 78 |
|
|
exit 1;
|
| 79 |
|
|
}
|
| 80 |
|
|
|
| 81 |
|
|
|
| 82 |
|
|
##############################################################################
|
| 83 |
|
|
##
|
| 84 |
|
|
##############################################################################
|
| 85 |
|
|
|
| 86 |
|
|
$home = cwd();
|
| 87 |
|
|
my $variant;
|
| 88 |
|
|
my $view;
|
| 89 |
|
|
my $filesetref_name;
|
| 90 |
|
|
|
| 91 |
|
|
if($version) {$variant = "${component}_${version}";}
|
| 92 |
|
|
else {$variant = "${component}";}
|
| 93 |
|
|
|
| 94 |
|
|
my $parser = XML::LibXML->new();
|
| 95 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
|
| 96 |
|
|
my $comp_xml_sep = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
|
| 97 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
|
| 98 |
135 |
jt_eaton |
my $child_dir = yp::lib::get_child_dir;
|
| 99 |
131 |
jt_eaton |
|
| 100 |
|
|
|
| 101 |
|
|
#print "XXXXXS $vendor,$library,$component,$version \n";
|
| 102 |
|
|
|
| 103 |
135 |
jt_eaton |
foreach my $X_view ($spirit_component_file->findnodes('//ipxact:component/ipxact:model/ipxact:views/ipxact:view'))
|
| 104 |
131 |
jt_eaton |
{
|
| 105 |
135 |
jt_eaton |
my($Xview_name) = $X_view->findnodes('./ipxact:name/text()')->to_literal ;
|
| 106 |
|
|
my($Xview_envidentifier) = $X_view->findnodes('./ipxact:envIdentifier/text()')->to_literal ;
|
| 107 |
|
|
my($Xview_filesetref_name) = $X_view->findnodes('./ipxact:fileSetRef/ipxact:localName/text()')->to_literal ;
|
| 108 |
131 |
jt_eaton |
|
| 109 |
|
|
#print "XXXXX $Xview_name || $Xview_envidentifier || $Xview_filesetref_name \n";
|
| 110 |
|
|
|
| 111 |
|
|
if($envidentifier eq $Xview_envidentifier )
|
| 112 |
|
|
{
|
| 113 |
|
|
$view = $Xview_name;
|
| 114 |
|
|
$filesetref_name = $Xview_filesetref_name;
|
| 115 |
|
|
}
|
| 116 |
|
|
}
|
| 117 |
|
|
|
| 118 |
|
|
#print "XXXXZ $view || view_filesetref_name \n";
|
| 119 |
|
|
|
| 120 |
|
|
|
| 121 |
|
|
|
| 122 |
|
|
|
| 123 |
|
|
unless($suffix) { $suffix = $view };
|
| 124 |
|
|
|
| 125 |
|
|
|
| 126 |
|
|
|
| 127 |
|
|
if($suffix)
|
| 128 |
|
|
{
|
| 129 |
|
|
|
| 130 |
|
|
$path ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/../filelists";
|
| 131 |
|
|
mkdir $path,0755 unless( -e $path );
|
| 132 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/../filelists/${variant}.${suffix}\n";
|
| 133 |
|
|
open SIMFILE,">$outfile" or die "unable to open $outfile";
|
| 134 |
|
|
#print "OUT $outfile \n";
|
| 135 |
|
|
if($top_file) {print SIMFILE "$top_file \n";}
|
| 136 |
|
|
|
| 137 |
|
|
#/*********************************************************************************************/
|
| 138 |
|
|
#/ */
|
| 139 |
|
|
#/ Create filelists for simulation, synthesis and linting */
|
| 140 |
|
|
#/ */
|
| 141 |
|
|
#/ */
|
| 142 |
|
|
#/*********************************************************************************************/
|
| 143 |
|
|
|
| 144 |
|
|
@filelist_sim = ( );
|
| 145 |
|
|
|
| 146 |
|
|
my @filelist = yp::lib::parse_component_file("$vendor","$library","$component","$version");
|
| 147 |
|
|
|
| 148 |
|
|
|
| 149 |
|
|
|
| 150 |
|
|
|
| 151 |
|
|
foreach $line (@filelist)
|
| 152 |
|
|
{
|
| 153 |
|
|
$_ = $line;
|
| 154 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
| 155 |
|
|
{
|
| 156 |
|
|
$new_proj = $2;
|
| 157 |
|
|
$new_comp = $3;
|
| 158 |
|
|
$new_vendor = $1;
|
| 159 |
|
|
$new_version = $4;
|
| 160 |
|
|
}
|
| 161 |
|
|
#############################################################################
|
| 162 |
|
|
## Read destination from source xml file
|
| 163 |
|
|
##
|
| 164 |
|
|
#############################################################################
|
| 165 |
|
|
|
| 166 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_proj,$new_comp,$new_version));
|
| 167 |
|
|
|
| 168 |
|
|
if($new_version){$new_variant = "${new_comp}_${new_version}"}
|
| 169 |
|
|
else {$new_variant = $new_comp}
|
| 170 |
|
|
|
| 171 |
|
|
if($opt_top_lib)
|
| 172 |
|
|
{
|
| 173 |
|
|
my $fileXX = find_filename($filesetref_name ,$new_vendor,$new_proj,$new_comp,$new_version);
|
| 174 |
|
|
if($fileXX){push(@filelist_sim,"${home}${prefix}/${fileXX}\n")};
|
| 175 |
|
|
}
|
| 176 |
|
|
else
|
| 177 |
|
|
{
|
| 178 |
|
|
if(($new_vendor eq $vendor ) && ($new_proj eq $library ) && ($new_comp eq $component ) && ($new_version eq $version ) )
|
| 179 |
|
|
{
|
| 180 |
|
|
if($opt_top)
|
| 181 |
|
|
{
|
| 182 |
|
|
my $fileXX = find_filename($filesetref_name ,$new_vendor,$new_proj,$new_comp,$new_version);
|
| 183 |
|
|
if($fileXX){push(@filelist_sim,"${home}${prefix}/${fileXX}\n")};
|
| 184 |
|
|
}
|
| 185 |
|
|
}
|
| 186 |
|
|
else
|
| 187 |
|
|
{
|
| 188 |
|
|
if(($new_proj eq $overlay_src_lib ) & ($new_vendor eq $overlay_src_ven))
|
| 189 |
|
|
{
|
| 190 |
|
|
if(yp::lib::find_ipxact_component($overlay_des_ven,$overlay_des_lib,$new_comp,$new_version ) )
|
| 191 |
|
|
{
|
| 192 |
|
|
$new_vendor = $overlay_des_ven;
|
| 193 |
|
|
$new_proj = $overlay_des_lib;
|
| 194 |
|
|
|
| 195 |
|
|
}
|
| 196 |
|
|
}
|
| 197 |
|
|
|
| 198 |
|
|
|
| 199 |
|
|
my $fileXX = find_filename($filesetref_name ,$new_vendor,$new_proj,$new_comp,$new_version);
|
| 200 |
135 |
jt_eaton |
if($fileXX){push(@filelist_sim,"${home}/${child_dir}/${fileXX}\n");}
|
| 201 |
131 |
jt_eaton |
}
|
| 202 |
|
|
}
|
| 203 |
|
|
|
| 204 |
|
|
|
| 205 |
|
|
|
| 206 |
|
|
|
| 207 |
|
|
|
| 208 |
|
|
|
| 209 |
|
|
|
| 210 |
|
|
|
| 211 |
|
|
|
| 212 |
|
|
|
| 213 |
|
|
|
| 214 |
|
|
|
| 215 |
|
|
}
|
| 216 |
|
|
|
| 217 |
|
|
#############################################################################
|
| 218 |
|
|
##
|
| 219 |
|
|
##
|
| 220 |
|
|
#############################################################################
|
| 221 |
|
|
|
| 222 |
|
|
print "Building ALL filelists for $prefix $vendor $library $component $version $variant \n" ;
|
| 223 |
|
|
@filelist_sim = sys::lib::trim_sort(@filelist_sim);
|
| 224 |
|
|
foreach my $i_line (@filelist_sim)
|
| 225 |
|
|
{
|
| 226 |
|
|
#print "$i_line \n";
|
| 227 |
|
|
|
| 228 |
|
|
|
| 229 |
|
|
if($leader)
|
| 230 |
|
|
{
|
| 231 |
|
|
print SIMFILE "${leader}${i_line}";
|
| 232 |
|
|
}
|
| 233 |
|
|
else
|
| 234 |
|
|
{
|
| 235 |
|
|
print SIMFILE "$i_line";
|
| 236 |
|
|
}
|
| 237 |
|
|
|
| 238 |
|
|
|
| 239 |
|
|
|
| 240 |
|
|
}
|
| 241 |
|
|
}
|
| 242 |
|
|
|
| 243 |
|
|
|
| 244 |
|
|
|
| 245 |
|
|
#/*********************************************************************************************/
|
| 246 |
|
|
#/ find filename */
|
| 247 |
|
|
#/ */
|
| 248 |
|
|
#/ returns gloabal name of the file */
|
| 249 |
|
|
#/ */
|
| 250 |
|
|
#/ */
|
| 251 |
|
|
#/*********************************************************************************************/
|
| 252 |
|
|
|
| 253 |
|
|
sub find_filename
|
| 254 |
|
|
{
|
| 255 |
|
|
my @params = @_;
|
| 256 |
|
|
my $version = pop(@params);
|
| 257 |
|
|
my $component = pop(@params);
|
| 258 |
|
|
my $library = pop(@params);
|
| 259 |
|
|
my $vendor = pop(@params);
|
| 260 |
|
|
my $filesetref_name = pop(@params);
|
| 261 |
|
|
|
| 262 |
134 |
jt_eaton |
my $variant;
|
| 263 |
|
|
if($version) {$variant = "${component}_${version}";}
|
| 264 |
|
|
else {$variant = "${component}";}
|
| 265 |
131 |
jt_eaton |
|
| 266 |
134 |
jt_eaton |
my @filelist = yp::lib::parse_component_brothers("$vendor","$library","$component","$version");
|
| 267 |
|
|
my $comp_xml_sep = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
|
| 268 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
|
| 269 |
|
|
my $library_path = "${lib_comp_sep}${component}${comp_xml_sep}";
|
| 270 |
131 |
jt_eaton |
|
| 271 |
|
|
|
| 272 |
|
|
|
| 273 |
|
|
foreach $line (@filelist)
|
| 274 |
|
|
{
|
| 275 |
|
|
$_ = $line;
|
| 276 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
| 277 |
|
|
{
|
| 278 |
|
|
$new_library = $2;
|
| 279 |
|
|
$new_component = $3;
|
| 280 |
|
|
$new_vendor = $1;
|
| 281 |
|
|
$new_version = $4;
|
| 282 |
|
|
|
| 283 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));
|
| 284 |
|
|
|
| 285 |
|
|
|
| 286 |
135 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//ipxact:fileSets/ipxact:fileSet/ipxact:file/ipxact:name"))
|
| 287 |
131 |
jt_eaton |
{
|
| 288 |
|
|
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
| 289 |
135 |
jt_eaton |
my($file_type) = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
|
| 290 |
|
|
my($logical_name) = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
|
| 291 |
|
|
my($view_file) = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;
|
| 292 |
131 |
jt_eaton |
if(($file_type eq "libraryDir") && ($logical_name eq "dest_dir") )
|
| 293 |
|
|
{
|
| 294 |
134 |
jt_eaton |
|
| 295 |
131 |
jt_eaton |
if( $view_file eq $filesetref_name )
|
| 296 |
|
|
{
|
| 297 |
|
|
return ("${vendor}__${library}${library_path}/${file_name}${variant}.v");
|
| 298 |
|
|
};
|
| 299 |
|
|
}
|
| 300 |
|
|
}
|
| 301 |
|
|
}
|
| 302 |
|
|
}
|
| 303 |
|
|
}
|
| 304 |
|
|
|
| 305 |
|
|
|
| 306 |
|
|
1
|
| 307 |
|
|
|