OpenCores
URL https://opencores.org/ocsvn/socgen/socgen/trunk

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [simulation/] [build_verilator_filelists] - Blame information for rev 125

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 125 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
#/*                                                                    */
15
#/*                                                                    */
16
#/*  Author(s):                                                        */
17
#/*      - John Eaton, jt_eaton@opencores.org                          */
18
#/*                                                                    */
19
#/**********************************************************************/
20
#/*                                                                    */
21
#/*    Copyright (C) <2010-2011>                */
22
#/*                                                                    */
23
#/*  This source file may be used and distributed without              */
24
#/*  restriction provided that this copyright statement is not         */
25
#/*  removed from the file and that any derivative work contains       */
26
#/*  the original copyright notice and the associated disclaimer.      */
27
#/*                                                                    */
28
#/*  This source file is free software; you can redistribute it        */
29
#/*  and/or modify it under the terms of the GNU Lesser General        */
30
#/*  Public License as published by the Free Software Foundation;      */
31
#/*  either version 2.1 of the License, or (at your option) any        */
32
#/*  later version.                                                    */
33
#/*                                                                    */
34
#/*  This source is distributed in the hope that it will be            */
35
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
36
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
37
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
38
#/*  details.                                                          */
39
#/*                                                                    */
40
#/*  You should have received a copy of the GNU Lesser General         */
41
#/*  Public License along with this source; if not, download it        */
42
#/*  from http://www.opencores.org/lgpl.shtml                          */
43
#/*                                                                    */
44
#/**********************************************************************/
45
 
46
 
47
 
48
 
49
############################################################################
50
# General PERL config
51
############################################################################
52
use Getopt::Long;
53
use English;
54
use File::Basename;
55
use Cwd;
56
use XML::LibXML;
57
use lib './tools';
58
use sys::lib;
59
use yp::lib;
60
 
61
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
62
 
63
 
64
############################################################################
65
### Process the options
66
############################################################################
67
Getopt::Long::config("require_order", "prefix=-");
68
GetOptions("h","help",
69
           "work_site=s" => \$work_site,
70
           "vendor=s" => \$vendor,
71
           "project=s" => \$project,
72
           "component=s" => \$component,
73
           "version=s" => \$version
74
) || die "(use '$program_name -h' for help)";
75
 
76
 
77
 
78
##############################################################################
79
## Help option
80
##############################################################################
81
if ( $opt_h  or $opt_help)
82
  { print "\n build_sim_filelists -work_site /work  -vendor vendor_name  -project project_name  -component component_name   ";
83
    print "\n";
84
    exit 1;
85
  }
86
 
87
 
88
##############################################################################
89
##
90
##############################################################################
91
 
92
 
93
 
94
$home = cwd();
95
 
96
my $variant = "";
97
if($version) {$variant = "${component}_${version}"}
98
else         {$variant = "${component}"}
99
 
100
#############################################################################
101
##
102
##
103
#############################################################################
104
 
105
my $parser = XML::LibXML->new();
106
 
107
 
108
 
109
#/*********************************************************************************************/
110
#/                                                                                            */
111
#/  Create filelists for simulation, code coverage                                            */
112
#/                                                                                            */
113
#/                                                                                            */
114
#/*********************************************************************************************/
115
 
116
@filelist_sim = (  );
117
@filelist_cov = (  );
118
 
119
 
120
my  @filelist =       yp::lib::parse_component_file("$vendor","$project","$component","$version");
121
 
122
 
123
 
124
 
125
foreach $line (@filelist)
126
   {
127
   $_ = $line;
128
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
129
     {
130
     $new_proj      = $2;
131
     $new_comp      = $3;
132
     $new_vendor    = $1;
133
     $new_version   = $4;
134
     }
135
 
136
 
137
 
138
   #############################################################################
139
   ## Read destination from source xml file
140
   ##
141
   #############################################################################
142
 
143
 
144
 
145
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version));
146
 
147
 
148
 
149
 
150
   if($new_version){$new_variant   = "${new_comp}_${new_version}"}
151
   else             {$new_variant   = $new_comp}
152
 
153
 
154
 
155
 
156
   if($new_proj eq $project )
157
        {
158
 
159
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
160
              {
161
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
162
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
163
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
164
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
165
              my $component_path  = yp::lib::find_ipxact_component_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
166
 
167
              if( ($file_type eq "libraryDir") &&  ($view_file eq "fs-syn")  &&  ($logical_name eq "dest_dir")                    )
168
                 {
169
                 push(@filelist_sim,"../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
170
                 };
171
 
172
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) &&  ($logical_name eq "dest_dir")  )
173
                 {
174
                 push(@filelist_cov,"-v  ../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
175
                 };
176
              }
177
        }
178
   else
179
        {
180
 
181
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
182
              {
183
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
184
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
185
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
186
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
187
              my $library_path    = yp::lib::find_ipxact_library_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
188
 
189
 
190
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-syn") ) &&  ($logical_name eq "dest_dir")  )
191
                 {
192
                 push(@filelist_sim,"../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
193
                 };
194
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) &&  ($logical_name eq "dest_dir")  )
195
                 {
196
                 push(@filelist_cov,"-v ../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
197
                 };
198
              }
199
 
200
        }
201
 
202
   }
203
 
204
 
205
 
206
 
207
 
208
 
209
#############################################################################
210
##
211
##
212
#############################################################################
213
 
214
print "Building SIM filelists for  $work_site  $vendor $project   $component $version $variant \n" ;
215
 
216
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
217
my $sogen_file           = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
218
 
219
my $library_path = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
220
 
221
 
222
 
223
#/*********************************************************************************************/
224
#/                                                                                            */
225
#/                                                                                            */
226
#/  Read each variants parameters and defaults into an array and their order into an array    */
227
#/  order must be preservered so that parameters can use the values of other parameters       */
228
#/                                                                                            */
229
#/*********************************************************************************************/
230
 
231
my %default_parameters = ();
232
my @parameter_order    = ();
233
 
234
 
235
foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$variant']/socgen:parameters/socgen:parameter"))
236
      {
237
      my($parameter_name)     = $i_name ->findnodes('socgen:name/text()')->to_literal ;
238
      my($parameter_default)  = $i_name ->findnodes('socgen:value/text()')->to_literal ;
239
      $default_parameters{$parameter_name}  = $parameter_default;
240
      push  @parameter_order ,$parameter_name ;
241
 #     print "XXXXY $parameter_name     $parameter_default       \n";
242
      }
243
 
244
 
245
 
246
 
247
 
248
 
249
 
250
 
251
 
252
foreach my $comp ($spirit_component_file->findnodes('//spirit:component'))
253
   {
254
   my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
255
   my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
256
   my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
257
   my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
258
   my $variant = "";
259
   if($version) {$variant = "${name}_${version}"}
260
   else         {$variant = "${name}"}
261
   print "rtl/gen directories  for    $project - $component         VLNV        $vendor - $library -  $name -  $variant \n";
262
   }
263
 
264
 
265
 
266
 
267
 
268
 
269
 
270
 
271
 
272
 
273
 
274
   print "CREATING componentRef filelists for   $project   $component  $name $variant \n";
275
 
276
 
277
 
278
        @filelist_cov =       sys::lib::trim_sort(@filelist_cov);
279
        @filelist_sim =       sys::lib::trim_sort(@filelist_sim);
280
 
281
 
282
 
283
 
284
 
285
   #/*********************************************************************************************/
286
   #/                                                                                            */
287
   #/                                                                                            */
288
   #/                                                                                            */
289
   #/                                                                                            */
290
   #/                                                                                            */
291
   #/                                                                                            */
292
   #/*********************************************************************************************/
293
 
294
 
295
foreach  my   $i_name ($sogen_file->findnodes("//socgen:testbench[socgen:variant/text() = '$variant']/socgen:code_coverage"))
296
   {
297
 
298
 
299
 
300
 
301
   my $path ="${home}${work_site}/${vendor}__${project}${library_path}/cov";
302
   mkdir $path,0755          unless( -e $path );
303
   $path ="${home}${work_site}/${vendor}__${project}${library_path}/cov/${variant}";
304
   mkdir $path,0755          unless( -e $path );
305
   my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/cov/${variant}/filelist.cov";
306
   open COVFILE,">$outfile" or die "unable to open $outfile";
307
 
308
   foreach  my   $i_line (@filelist_cov) {print COVFILE  "$i_line";}
309
 
310
   my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/cov/${variant}/TestBench";
311
   open  DUTFILE,">$outfile" or die "unable to open $outfile";
312
   print  DUTFILE  "`define SYNTHESIS   \n";
313
   print  DUTFILE  "`timescale    1ns/1ns   \n";
314
   print  DUTFILE  " module TB();   \n";
315
   print  DUTFILE  " $variant test (   );   \n";
316
   print  DUTFILE  " endmodule   \n";
317
   }
318
 
319
 
320
 
321
   #/*********************************************************************************************/
322
   #/                                                                                            */
323
   #/ Make simulation file set                                                                   */
324
   #/                                                                                            */
325
   #/                                                                                            */
326
   #/                                                                                            */
327
   #/                                                                                            */
328
   #/*********************************************************************************************/
329
 
330
   print "CREATING sim files for   $project  $component   $chip   $name  $variant \n";
331
 
332
 
333
 
334
 
335
 
336
 
337
    foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:verilator/socgen:test[socgen:variant/text() = '$variant']"))
338
      {
339
      my($simulation)      = $i_name ->findnodes('socgen:name/text()')->to_literal ;
340
      my($configuration)   = $i_name ->findnodes('socgen:configuration/text()')->to_literal ;
341
      print " sim files for   $project  $component   $variant  $simulation $configuration          \n";
342
 
343
      my $path ="${home}${work_site}/${vendor}__${project}${library_path}/verilator";
344
      mkdir $path,0755          unless( -e $path );
345
      $path ="${home}${work_site}/${vendor}__${project}${library_path}/verilator/${simulation}";
346
      mkdir $path,0755          unless( -e $path );
347
 
348
      my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/verilator/${simulation}/Makefile";
349
      open  MAKSIMFILE,">$outfile" or die "unable to open $outfile";
350
 
351
      my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/verilator/${simulation}/filelist.sim";
352
      open SIMFILE,">$outfile" or die "unable to open $outfile";
353
 
354
      my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/verilator/${simulation}/TestBench";
355
      open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
356
 
357
 
358
 
359
 
360
 
361
      my %local_parameters =  %default_parameters;
362
      my @local_order      =  @parameter_order;
363
 
364
 
365
 
366
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:testbenches/socgen:testbench[socgen:variant/text() = '$variant']/./socgen:parameters/socgen:parameter/socgen:name"))
367
         {
368
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
369
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
370
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
371
         $local_parameters{$par_name} = $par_value;
372
         }
373
 
374
 
375
 
376
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
377
         {
378
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
379
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
380
         if($local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
381
         $local_parameters{$par_name} = $par_value;
382
         }
383
 
384
 
385
 
386
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:verilator/socgen:test[socgen:name/text() = '$simulation']/./socgen:parameters/socgen:parameter/socgen:name"))
387
         {
388
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
389
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
390
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
391
         $local_parameters{$par_name} = $par_value;
392
         }
393
 
394
     my $timeout = $local_parameters{"TIMEOUT"};
395
 
396
      print MAKSIMFILE  "include ../../../../../bin/Makefile.root\n";
397
      print MAKSIMFILE  "comp=${variant}\n";
398
      print MAKSIMFILE  "test=${simulation}\n";
399
      print MAKSIMFILE  "timeout=${timeout}\n";
400
 
401
      foreach  my   $i_line (@filelist_sim){ print SIMFILE  "$i_line";}
402
 
403
 
404
      my $module_name = yp::lib::get_module_name($vendor,$project,$component,$version);
405
 
406
 
407
 
408
 
409
      print SIM_PARM_FILE  "//  Testbench  for  $project    $component    $variant   $configuration    $simulation\n";
410
      print SIM_PARM_FILE  "                \n";
411
      print SIM_PARM_FILE  "module TB(input clk, input START,     output FINISH,output FAIL                 );                                \n";
412
      print SIM_PARM_FILE  "                                \n";
413
      print SIM_PARM_FILE  "     $module_name   \n";
414
 
415
      my $first =1;
416
 
417
      foreach  my  $parameter_name  (@local_order)
418
         {
419
         my($parameter_default)  =    $local_parameters{$parameter_name};
420
         if($first)
421
           {
422
           print SIM_PARM_FILE  "   #(  .${parameter_name}(${parameter_default})";
423
           $first = 0;
424
           }
425
         else
426
           {
427
           print SIM_PARM_FILE  ",\n       .${parameter_name}(${parameter_default})";
428
           }
429
         }
430
      print SIM_PARM_FILE  ") test \n (.clk(clk),.START(START),.FAIL(FAIL),.FINISH(FINISH)); \n\n\n\n";
431
      print SIM_PARM_FILE  "endmodule                                \n";
432
 
433
 
434
      }
435
 
436
 
437
 
438
 
439
 
440
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.