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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [simulation/] [build_icarus_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
 
121
 
122
my  @filelist =       yp::lib::parse_component_file("$vendor","$project","$component","$version");
123
 
124
 
125
 
126
 
127
 
128
foreach $line (@filelist)
129
   {
130
   $_ = $line;
131
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
132
     {
133
     $new_proj      = $2;
134
     $new_comp      = $3;
135
     $new_vendor    = $1;
136
     $new_version   = $4;
137
     }
138
 
139
 
140
 
141
   #############################################################################
142
   ## Read destination from source xml file
143
   ##
144
   #############################################################################
145
 
146
 
147
 
148
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version));
149
 
150
 
151
 
152
 
153
   if($new_version){$new_variant   = "${new_comp}_${new_version}"}
154
   else             {$new_variant   = $new_comp}
155
 
156
 
157
 
158
 
159
   if($new_proj eq $project )
160
        {
161
 
162
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
163
              {
164
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
165
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
166
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
167
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
168
              my $component_path  = yp::lib::find_ipxact_component_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
169
 
170
              if( ($file_type eq "libraryDir") &&  ($view_file eq "fs-sim")  &&  ($logical_name eq "dest_dir")                    )
171
                 {
172
                 push(@filelist_sim,"../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
173
                 };
174
 
175
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) &&  ($logical_name eq "dest_dir")  )
176
                 {
177
                 push(@filelist_cov,"-v  ../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
178
                 };
179
              }
180
        }
181
   else
182
        {
183
 
184
           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
185
              {
186
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
187
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
188
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
189
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
190
              my $library_path    = yp::lib::find_ipxact_library_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);
191
 
192
 
193
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-sim") ) &&  ($logical_name eq "dest_dir")  )
194
                 {
195
                 push(@filelist_sim,"../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
196
                 };
197
              if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) &&  ($logical_name eq "dest_dir")  )
198
                 {
199
                 push(@filelist_cov,"-v ../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
200
                 };
201
              }
202
 
203
        }
204
 
205
   }
206
 
207
 
208
 
209
 
210
 
211
 
212
#############################################################################
213
##
214
##
215
#############################################################################
216
 
217
print "Building SIM filelists for  $work_site  $vendor $project   $component $version $variant \n" ;
218
 
219
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
220
my $sogen_file           = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
221
 
222
my $library_path = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
223
 
224
 
225
 
226
#/*********************************************************************************************/
227
#/                                                                                            */
228
#/                                                                                            */
229
#/  Read each variants parameters and defaults into an array and their order into an array    */
230
#/  order must be preservered so that parameters can use the values of other parameters       */
231
#/                                                                                            */
232
#/*********************************************************************************************/
233
 
234
my %default_parameters = ();
235
my @parameter_order    = ();
236
 
237
 
238
foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$variant']/socgen:parameters/socgen:parameter"))
239
      {
240
      my($parameter_name)     = $i_name ->findnodes('socgen:name/text()')->to_literal ;
241
      my($parameter_default)  = $i_name ->findnodes('socgen:value/text()')->to_literal ;
242
      $default_parameters{$parameter_name}  = $parameter_default;
243
      push  @parameter_order ,$parameter_name ;
244
 #     print "XXXXY $parameter_name     $parameter_default       \n";
245
      }
246
 
247
 
248
 
249
 
250
 
251
 
252
 
253
 
254
 
255
foreach my $comp ($spirit_component_file->findnodes('//spirit:component'))
256
   {
257
   my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
258
   my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
259
   my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
260
   my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
261
   my $variant = "";
262
   if($version) {$variant = "${name}_${version}"}
263
   else         {$variant = "${name}"}
264
   print "rtl/gen directories  for    $project - $component         VLNV        $vendor - $library -  $name -  $variant \n";
265
   }
266
 
267
 
268
 
269
 
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
   print "CREATING componentRef filelists for   $project   $component  $name $variant \n";
278
 
279
 
280
 
281
        @filelist_cov =       sys::lib::trim_sort(@filelist_cov);
282
        @filelist_sim =       sys::lib::trim_sort(@filelist_sim);
283
 
284
 
285
 
286
 
287
 
288
   #/*********************************************************************************************/
289
   #/                                                                                            */
290
   #/                                                                                            */
291
   #/                                                                                            */
292
   #/                                                                                            */
293
   #/                                                                                            */
294
   #/                                                                                            */
295
   #/*********************************************************************************************/
296
 
297
 
298
foreach  my   $i_name ($sogen_file->findnodes("//socgen:testbench[socgen:variant/text() = '$variant']/socgen:code_coverage"))
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:icarus/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
 
344
      my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/icarus/${simulation}/Makefile";
345
      open  MAKSIMFILE,">$outfile" or die "unable to open $outfile";
346
 
347
      my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/icarus/${simulation}/filelist.sim";
348
      open SIMFILE,">$outfile" or die "unable to open $outfile";
349
 
350
      my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/icarus/${simulation}/TestBench";
351
      open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
352
 
353
      print MAKSIMFILE  "include ../../../../../bin/Makefile.root\n";
354
      print MAKSIMFILE  "comp=${variant}\n";
355
      print MAKSIMFILE  "test=${simulation}\n";
356
 
357
 
358
 
359
      foreach  my   $i_line (@filelist_sim){ print SIMFILE  "$i_line";}
360
 
361
 
362
 
363
      my %local_parameters =  %default_parameters;
364
      my @local_order      =  @parameter_order;
365
 
366
 
367
 
368
      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"))
369
         {
370
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
371
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
372
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
373
         $local_parameters{$par_name} = $par_value;
374
         }
375
 
376
 
377
 
378
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
379
         {
380
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
381
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
382
         if($local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
383
         $local_parameters{$par_name} = $par_value;
384
         }
385
 
386
 
387
 
388
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:icarus/socgen:test[socgen:name/text() = '$simulation']/./socgen:parameters/socgen:parameter/socgen:name"))
389
         {
390
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
391
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
392
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
393
         $local_parameters{$par_name} = $par_value;
394
         }
395
 
396
 
397
 
398
 
399
 
400
 
401
 
402
 
403
 
404
      print SIM_PARM_FILE  "//  Testbench  for  $project    $component    $variant   $configuration    $simulation\n";
405
      print SIM_PARM_FILE  "`ifndef     TIMESCALE                                \n";
406
      print SIM_PARM_FILE  "`define     TIMESCALE   1ns/1ns                                \n";
407
      print SIM_PARM_FILE  "`endif                                \n";
408
      print SIM_PARM_FILE  "                                \n";
409
      print SIM_PARM_FILE  "`ifndef     TIMEFORMAT                                \n";
410
      print SIM_PARM_FILE  "`define     TIMEFORMAT  \$timeformat(-6, 2, \" us\", 14);                                \n";
411
      print SIM_PARM_FILE  "`endif                                \n";
412
      print SIM_PARM_FILE  "                                \n";
413
      print SIM_PARM_FILE  "`timescale `TIMESCALE                                \n";
414
      print SIM_PARM_FILE  "                                \n";
415
      print SIM_PARM_FILE  "module TB();                                \n";
416
      print SIM_PARM_FILE  "                                \n";
417
      print SIM_PARM_FILE  "initial                                \n";
418
      print SIM_PARM_FILE  "begin                                \n";
419
      print SIM_PARM_FILE  "`TIMEFORMAT                                \n";
420
      print SIM_PARM_FILE  "end                                \n";
421
      print SIM_PARM_FILE  "                                \n";
422
      print SIM_PARM_FILE  "`ifdef VCD                                \n";
423
      print SIM_PARM_FILE  "initial                                \n";
424
      print SIM_PARM_FILE  " begin                                \n";
425
      print SIM_PARM_FILE  "`include \"./dmp_define\"                                \n";
426
      print SIM_PARM_FILE  " end                                \n";
427
      print SIM_PARM_FILE  "`endif                                \n";
428
      print SIM_PARM_FILE  " reg clk,START;            \n";
429
      print SIM_PARM_FILE  " wire FAIL,FINISH;                               \n";
430
      print SIM_PARM_FILE  " reg  failed;                               \n";
431
      print SIM_PARM_FILE  " reg [31:0] failcount;                               \n";
432
      print SIM_PARM_FILE  "initial                             \n";
433
      print SIM_PARM_FILE  "begin                             \n";
434
      print SIM_PARM_FILE  "clk=0;                             \n";
435
      print SIM_PARM_FILE  "START=0;                             \n";
436
      print SIM_PARM_FILE  "@ (posedge clk);                             \n";
437
      print SIM_PARM_FILE  "@ (posedge clk);                             \n";
438
      print SIM_PARM_FILE  "@ (posedge clk) ;                             \n";
439
      print SIM_PARM_FILE  "START = 1;                             \n";
440
      print SIM_PARM_FILE  "end                       \n";
441
 
442
 
443
 
444
 
445
 
446
 
447
 
448
 
449
      print SIM_PARM_FILE  "always@(posedge clk)           \n";
450
      print SIM_PARM_FILE  "if(START && FINISH)           \n";
451
      print SIM_PARM_FILE  "begin           \n";
452
      print SIM_PARM_FILE  "   if(failed)        \n";
453
      print SIM_PARM_FILE  "     begin        \n";
454
      print SIM_PARM_FILE  "     \$display(\"%t  SIM over: ERROR    %d failures\",\$realtime ,failcount );        \n";
455
      print SIM_PARM_FILE  "     end        \n";
456
      print SIM_PARM_FILE  "  else        \n";
457
      print SIM_PARM_FILE  "     begin        \n";
458
      print SIM_PARM_FILE  "     \$display(\"%t  SIM over: PASSED\",\$realtime  );        \n";
459
      print SIM_PARM_FILE  "     end // else: !if(failed)        \n";
460
      print SIM_PARM_FILE  "\$dumpflush;           \n";
461
      print SIM_PARM_FILE  "\$finish;           \n";
462
      print SIM_PARM_FILE  "end           \n";
463
      print SIM_PARM_FILE  "always@(posedge clk or negedge START)        \n";
464
      print SIM_PARM_FILE  "if(!START)        \n";
465
      print SIM_PARM_FILE  "begin        \n";
466
      print SIM_PARM_FILE  "failed <= 1\'b0;        \n";
467
      print SIM_PARM_FILE  "failcount <= 32\'h0;        \n";
468
      print SIM_PARM_FILE  "end        \n";
469
      print SIM_PARM_FILE  "else        \n";
470
      print SIM_PARM_FILE  "begin        \n";
471
      print SIM_PARM_FILE  "if(FAIL)        \n";
472
      print SIM_PARM_FILE  "begin        \n";
473
      print SIM_PARM_FILE  "failed <= 1\'b1;        \n";
474
      print SIM_PARM_FILE  "failcount <= failcount + 32\'h00000001;        \n";
475
      print SIM_PARM_FILE  "end        \n";
476
      print SIM_PARM_FILE  "else        \n";
477
      print SIM_PARM_FILE  "begin        \n";
478
      print SIM_PARM_FILE  "failed <= failed;        \n";
479
      print SIM_PARM_FILE  "failcount <= failcount;        \n";
480
      print SIM_PARM_FILE  "end        \n";
481
      print SIM_PARM_FILE  "end           \n";
482
 
483
      print SIM_PARM_FILE  "always                       \n";
484
      print SIM_PARM_FILE  " #($local_parameters{\"PERIOD\"}/2) clk = !clk;                       \n";
485
      print SIM_PARM_FILE  "`include \"./test_define\"                                \n";
486
 
487
      my $module_name = yp::lib::get_module_name($vendor,$project,$component,$version);
488
 
489
      print SIM_PARM_FILE  "     $module_name   \n";
490
      my $first =1;
491
      foreach  my  $parameter_name  (@local_order)
492
         {
493
         my($parameter_default)  =    $local_parameters{$parameter_name};
494
         if($first)
495
           {
496
           print SIM_PARM_FILE  "   #(  .${parameter_name}(${parameter_default})";
497
           $first = 0;
498
           }
499
         else
500
           {
501
           print SIM_PARM_FILE  ",\n       .${parameter_name}(${parameter_default})";
502
           }
503
         }
504
      print SIM_PARM_FILE  ") test \n (.clk(clk),.START(START),.FAIL(FAIL),.FINISH(FINISH)); \n\n\n\n";
505
 
506
 
507
 
508
      print SIM_PARM_FILE  "task automatic next;           \n";
509
      print SIM_PARM_FILE  "  input [31:0] num;           \n";
510
      print SIM_PARM_FILE  "  repeat (num)       @ (posedge clk);           \n";
511
      print SIM_PARM_FILE  "endtask            \n";
512
      print SIM_PARM_FILE  "           \n";
513
      print SIM_PARM_FILE  "           \n";
514
      print SIM_PARM_FILE  "initial           \n";
515
      print SIM_PARM_FILE  "   begin           \n";
516
      print SIM_PARM_FILE  "   next($local_parameters{\"TIMEOUT\"});           \n";
517
      print SIM_PARM_FILE  "   \$display(\"%t  Sim over :ERROR    TIMEOUT\",\$realtime  );           \n";
518
      print SIM_PARM_FILE  "   @ (posedge clk)           \n";
519
      print SIM_PARM_FILE  "   \$dumpflush;                      \n";
520
      print SIM_PARM_FILE  "   \$finish;                         \n";
521
      print SIM_PARM_FILE  "   end           \n";
522
      print SIM_PARM_FILE  "            \n";
523
 
524
 
525
 
526
 
527
 
528
 
529
      print SIM_PARM_FILE  "endmodule                                \n";
530
 
531
 
532
 
533
 
534
 
535
      }
536
 
537
 
538
 
539
 
540
 
541
 

powered by: WebSVN 2.1.0

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