1 |
124 |
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 |
124 |
jt_eaton |
|
32 |
|
|
|
33 |
|
|
############################################################################
|
34 |
|
|
# General PERL config
|
35 |
|
|
############################################################################
|
36 |
|
|
use Getopt::Long;
|
37 |
|
|
use English;
|
38 |
|
|
use File::Basename;
|
39 |
|
|
use Cwd;
|
40 |
|
|
use XML::LibXML;
|
41 |
|
|
use lib './tools';
|
42 |
|
|
use sys::lib;
|
43 |
|
|
use yp::lib;
|
44 |
|
|
|
45 |
|
|
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
############################################################################
|
49 |
|
|
### Process the options
|
50 |
|
|
############################################################################
|
51 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
52 |
|
|
GetOptions("h","help",
|
53 |
|
|
"work_site=s" => \$work_site,
|
54 |
|
|
"vendor=s" => \$vendor,
|
55 |
131 |
jt_eaton |
"library=s" => \$library,
|
56 |
124 |
jt_eaton |
"component=s" => \$component,
|
57 |
|
|
"version=s" => \$version
|
58 |
|
|
) || die "(use '$program_name -h' for help)";
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
##############################################################################
|
63 |
|
|
## Help option
|
64 |
|
|
##############################################################################
|
65 |
|
|
if ( $opt_h or $opt_help)
|
66 |
131 |
jt_eaton |
{ print "\n build_lint_filelists -work_site /work -vendor vendor_name -library library_name -component component_name ";
|
67 |
124 |
jt_eaton |
print "\n";
|
68 |
|
|
exit 1;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
##############################################################################
|
73 |
|
|
##
|
74 |
|
|
##############################################################################
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
$home = cwd();
|
79 |
|
|
|
80 |
135 |
jt_eaton |
my $child_dir = yp::lib::get_child_dir;
|
81 |
|
|
|
82 |
124 |
jt_eaton |
my $variant = "";
|
83 |
|
|
if($version) {$variant = "${component}_${version}"}
|
84 |
|
|
else {$variant = "${component}"}
|
85 |
|
|
|
86 |
|
|
#############################################################################
|
87 |
|
|
##
|
88 |
|
|
##
|
89 |
|
|
#############################################################################
|
90 |
|
|
|
91 |
|
|
my $parser = XML::LibXML->new();
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
#/*********************************************************************************************/
|
96 |
|
|
#/ */
|
97 |
|
|
#/ Create filelists for simulation and linting */
|
98 |
|
|
#/ */
|
99 |
|
|
#/ */
|
100 |
|
|
#/*********************************************************************************************/
|
101 |
|
|
|
102 |
|
|
@filelist_sim = ( );
|
103 |
|
|
|
104 |
131 |
jt_eaton |
my @filelist = yp::lib::parse_component_file("$vendor","$library","$component","$version");
|
105 |
124 |
jt_eaton |
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
foreach $line (@filelist)
|
110 |
|
|
{
|
111 |
|
|
$_ = $line;
|
112 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
113 |
|
|
{
|
114 |
|
|
$new_proj = $2;
|
115 |
|
|
$new_comp = $3;
|
116 |
|
|
$new_vendor = $1;
|
117 |
|
|
$new_version = $4;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
#############################################################################
|
123 |
|
|
## Read destination from source xml file
|
124 |
|
|
##
|
125 |
|
|
#############################################################################
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
130 |
jt_eaton |
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_proj,$new_comp,$new_version));
|
130 |
124 |
jt_eaton |
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
if($new_version){$new_variant = "${new_comp}_${new_version}"}
|
135 |
|
|
else {$new_variant = $new_comp}
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
131 |
jt_eaton |
if(($new_vendor eq $vendor ) && ($new_proj eq $library ) && ($new_comp eq $component ) && ($new_version eq $version ) )
|
140 |
127 |
jt_eaton |
|
141 |
124 |
jt_eaton |
{
|
142 |
|
|
|
143 |
135 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//ipxact:fileSets/ipxact:fileSet/ipxact:file/ipxact:name"))
|
144 |
124 |
jt_eaton |
{
|
145 |
|
|
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
146 |
135 |
jt_eaton |
my($file_type) = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
|
147 |
|
|
my($logical_name) = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
|
148 |
|
|
my($view_file) = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;
|
149 |
130 |
jt_eaton |
my $comp_xml_sep = yp::lib::find_comp_xml_sep($new_vendor,$new_proj,$new_comp,$new_version);
|
150 |
124 |
jt_eaton |
|
151 |
|
|
if( ($file_type eq "libraryDir") && ($view_file eq "fs-lint") && ($logical_name eq "dest_dir") )
|
152 |
|
|
{
|
153 |
130 |
jt_eaton |
push(@filelist_sim,"../../../../${new_comp}${comp_xml_sep}/${file_name}${new_variant}.v\n");
|
154 |
124 |
jt_eaton |
};
|
155 |
|
|
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
else
|
159 |
|
|
{
|
160 |
|
|
|
161 |
135 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//ipxact:fileSets/ipxact:fileSet/ipxact:file/ipxact:name"))
|
162 |
124 |
jt_eaton |
{
|
163 |
|
|
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
164 |
135 |
jt_eaton |
my($file_type) = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
|
165 |
|
|
my($logical_name) = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
|
166 |
|
|
my($view_file) = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;
|
167 |
124 |
jt_eaton |
|
168 |
130 |
jt_eaton |
my $comp_xml_sep = yp::lib::find_comp_xml_sep($new_vendor,$new_proj,$new_comp,$new_version);
|
169 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($new_vendor,$new_proj,$new_comp);
|
170 |
|
|
my $library_path = "${lib_comp_sep}${component}${comp_xml_sep}";
|
171 |
124 |
jt_eaton |
|
172 |
|
|
if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) && ($logical_name eq "dest_dir") )
|
173 |
|
|
{
|
174 |
135 |
jt_eaton |
push(@filelist_sim,"../../../../../../${child_dir}/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
|
175 |
124 |
jt_eaton |
};
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
#############################################################################
|
188 |
|
|
##
|
189 |
|
|
##
|
190 |
|
|
#############################################################################
|
191 |
|
|
|
192 |
131 |
jt_eaton |
print "Building rtl_check filelists for $work_site $vendor $library $component $version $variant \n" ;
|
193 |
124 |
jt_eaton |
|
194 |
131 |
jt_eaton |
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
|
195 |
|
|
my $socgen_file = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
|
196 |
124 |
jt_eaton |
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
#/*********************************************************************************************/
|
202 |
|
|
#/ */
|
203 |
|
|
#/ */
|
204 |
|
|
#/ Read each variants parameters and defaults into an array and their order into an array */
|
205 |
|
|
#/ order must be preservered so that parameters can use the values of other parameters */
|
206 |
|
|
#/ */
|
207 |
|
|
#/*********************************************************************************************/
|
208 |
|
|
|
209 |
|
|
my %default_parameters = ();
|
210 |
|
|
my @parameter_order = ();
|
211 |
|
|
|
212 |
|
|
|
213 |
130 |
jt_eaton |
foreach my $i_name ($socgen_file->findnodes("//socgen:testbenches/socgen:testbench[socgen:variant/text() = '$variant']/socgen:parameters/socgen:parameter"))
|
214 |
124 |
jt_eaton |
{
|
215 |
|
|
my($parameter_name) = $i_name ->findnodes('socgen:name/text()')->to_literal ;
|
216 |
|
|
my($parameter_default) = $i_name ->findnodes('socgen:value/text()')->to_literal ;
|
217 |
|
|
$default_parameters{$parameter_name} = $parameter_default;
|
218 |
|
|
push @parameter_order ,$parameter_name ;
|
219 |
|
|
# print "XXXXY $parameter_name $parameter_default \n";
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
135 |
jt_eaton |
foreach my $comp ($spirit_component_file->findnodes('//ipxact:component'))
|
230 |
124 |
jt_eaton |
{
|
231 |
135 |
jt_eaton |
my($vendor) = $comp->findnodes('./ipxact:vendor/text()')->to_literal ;
|
232 |
|
|
my($library) = $comp->findnodes('./ipxact:library/text()')->to_literal ;
|
233 |
|
|
my($name) = $comp->findnodes('./ipxact:name/text()')->to_literal ;
|
234 |
|
|
my($version) = $comp->findnodes('./ipxact:version/text()')->to_literal ;
|
235 |
124 |
jt_eaton |
my $variant = "";
|
236 |
|
|
if($version) {$variant = "${name}_${version}"}
|
237 |
|
|
else {$variant = "${name}"}
|
238 |
131 |
jt_eaton |
print "rtl/gen directories for $library - $component VLNV $vendor - $library - $name - $variant \n";
|
239 |
124 |
jt_eaton |
}
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
push(@filelist_sim," ./TestBench\n");
|
252 |
|
|
|
253 |
131 |
jt_eaton |
print "CREATING componentRef filelists for $library $component $name $variant \n";
|
254 |
124 |
jt_eaton |
|
255 |
128 |
jt_eaton |
@filelist_sim = sys::lib::trim_sort(@filelist_sim);
|
256 |
124 |
jt_eaton |
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
#/*********************************************************************************************/
|
270 |
|
|
#/ */
|
271 |
|
|
#/ Make simulation file set */
|
272 |
|
|
#/ */
|
273 |
|
|
#/ */
|
274 |
|
|
#/ */
|
275 |
|
|
#/ */
|
276 |
|
|
#/*********************************************************************************************/
|
277 |
|
|
|
278 |
131 |
jt_eaton |
print "CREATING sim files for $library $component $chip $name $variant \n";
|
279 |
124 |
jt_eaton |
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
131 |
jt_eaton |
my $socgen_file = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
|
284 |
124 |
jt_eaton |
|
285 |
130 |
jt_eaton |
foreach my $i_name ($socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:rtl_check/socgen:lint[socgen:variant/text() = '$variant']"))
|
286 |
124 |
jt_eaton |
{
|
287 |
|
|
my($simulation) = $i_name ->findnodes('socgen:name/text()')->to_literal ;
|
288 |
|
|
my($configuration) = $i_name ->findnodes('socgen:configuration/text()')->to_literal ;
|
289 |
|
|
|
290 |
131 |
jt_eaton |
print " lint files for $library $component $variant $simulation $configuration \n";
|
291 |
124 |
jt_eaton |
|
292 |
130 |
jt_eaton |
my $sim_library_path ;
|
293 |
131 |
jt_eaton |
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
|
294 |
130 |
jt_eaton |
my $sim_comp_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
|
295 |
|
|
|
296 |
|
|
if ($sim_comp_path)
|
297 |
|
|
{
|
298 |
|
|
$sim_library_path ="${lib_comp_sep}${sim_comp_path}";
|
299 |
|
|
}
|
300 |
|
|
else
|
301 |
|
|
{
|
302 |
|
|
$sim_library_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
|
303 |
|
|
}
|
304 |
|
|
|
305 |
|
|
|
306 |
131 |
jt_eaton |
my $path = "${home}${work_site}/${vendor}__${library}${sim_library_path}/rtl_check";
|
307 |
124 |
jt_eaton |
|
308 |
125 |
jt_eaton |
mkdir $path,0755 unless (-e $path) ;
|
309 |
124 |
jt_eaton |
|
310 |
131 |
jt_eaton |
$path = "${home}${work_site}/${vendor}__${library}${sim_library_path}/rtl_check/${simulation}";
|
311 |
125 |
jt_eaton |
mkdir $path,0755 unless (-e $path);
|
312 |
124 |
jt_eaton |
|
313 |
|
|
|
314 |
131 |
jt_eaton |
$outfile ="${home}${work_site}/${vendor}__${library}${sim_library_path}/rtl_check/${simulation}/TestBench";
|
315 |
125 |
jt_eaton |
open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
|
316 |
124 |
jt_eaton |
|
317 |
|
|
my %local_parameters = %default_parameters;
|
318 |
|
|
my @local_order = @parameter_order;
|
319 |
|
|
|
320 |
130 |
jt_eaton |
foreach my $i_name ($socgen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
|
321 |
124 |
jt_eaton |
{
|
322 |
|
|
my($par_name) = $i_name ->findnodes('./text()')->to_literal ;
|
323 |
|
|
my($par_value) = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
|
324 |
|
|
if($local_parameters{$par_name} eq '' ) { push @local_order , $par_name; }
|
325 |
|
|
$local_parameters{$par_name} = $par_value;
|
326 |
|
|
}
|
327 |
|
|
|
328 |
130 |
jt_eaton |
foreach my $i_name ($socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:rtl_check/socgen:lint[socgen:name/text() = '$simulation']/./socgen:parameters/socgen:parameter/socgen:name"))
|
329 |
124 |
jt_eaton |
{
|
330 |
|
|
my($par_name) = $i_name ->findnodes('./text()')->to_literal ;
|
331 |
|
|
my($par_value) = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
|
332 |
|
|
if ( $local_parameters{$par_name} eq '' ) { push @local_order , $par_name; }
|
333 |
|
|
$local_parameters{$par_name} = $par_value;
|
334 |
|
|
}
|
335 |
|
|
|
336 |
125 |
jt_eaton |
|
337 |
|
|
|
338 |
131 |
jt_eaton |
my $module_name = yp::lib::get_module_name($vendor,$library,$component,$version);
|
339 |
125 |
jt_eaton |
|
340 |
131 |
jt_eaton |
print SIM_PARM_FILE "// Testbench for $library $component $variant $configuration $simulation\n";
|
341 |
124 |
jt_eaton |
print SIM_PARM_FILE " \n";
|
342 |
125 |
jt_eaton |
print SIM_PARM_FILE "module TB(input clk,input reset); \n";
|
343 |
|
|
print SIM_PARM_FILE " \n\n";
|
344 |
|
|
print SIM_PARM_FILE " $module_name \n";
|
345 |
124 |
jt_eaton |
|
346 |
|
|
my $first =1;
|
347 |
|
|
|
348 |
|
|
foreach my $parameter_name (@local_order)
|
349 |
|
|
{
|
350 |
128 |
jt_eaton |
|
351 |
124 |
jt_eaton |
my($parameter_default) = $local_parameters{$parameter_name};
|
352 |
128 |
jt_eaton |
|
353 |
|
|
# if a parameter is used to define a paramter then use its value instead. Only works for lookup- no alterations
|
354 |
|
|
if($local_parameters{$parameter_default}) { $parameter_default = $local_parameters{$parameter_default} }
|
355 |
|
|
|
356 |
124 |
jt_eaton |
if($first)
|
357 |
|
|
{
|
358 |
|
|
print SIM_PARM_FILE " #( .${parameter_name}(${parameter_default})";
|
359 |
|
|
$first = 0;
|
360 |
|
|
}
|
361 |
|
|
else
|
362 |
|
|
{
|
363 |
|
|
print SIM_PARM_FILE ",\n .${parameter_name}(${parameter_default})";
|
364 |
|
|
}
|
365 |
|
|
}
|
366 |
|
|
|
367 |
|
|
if($first) { print SIM_PARM_FILE " ";}
|
368 |
|
|
else { print SIM_PARM_FILE ") ";}
|
369 |
|
|
|
370 |
125 |
jt_eaton |
print SIM_PARM_FILE " test \n (.clk(clk),.reset(reset)); \n\n\n\n endmodule \n ";
|
371 |
124 |
jt_eaton |
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
}
|
375 |
|
|
|
376 |
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
|