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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [simulation/] [build_icarus_filelists.cand] - Blame information for rev 135

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 135 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
use BerkeleyDB;
61
 
62
 
63
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
64
 
65
 
66
############################################################################
67
### Process the options
68
############################################################################
69
Getopt::Long::config("require_order", "prefix=-");
70
GetOptions("h","help",
71
           "work_site=s" => \$work_site,
72
           "vendor=s" => \$vendor,
73
           "library=s" => \$library,
74
           "component=s" => \$component,
75
           "version=s" => \$version
76
) || die "(use '$program_name -h' for help)";
77
 
78
 
79
 
80
##############################################################################
81
## Help option
82
##############################################################################
83
if ( $opt_h  or $opt_help)
84
  { print "\n build_icarus_filelists -work_site /work  -vendor vendor_name  -library library_name  -component component_name   ";
85
    print "\n";
86
    exit 1;
87
  }
88
 
89
 
90
##############################################################################
91
##
92
##############################################################################
93
 
94
 
95
 
96
$home = cwd();
97
 
98
my $variant = "";
99
if($version) {$variant = "${component}_${version}"}
100
else         {$variant = "${component}"}
101
 
102
#############################################################################
103
##
104
##
105
#############################################################################
106
 
107
my $parser = XML::LibXML->new();
108
 
109
 
110
 
111
#/*********************************************************************************************/
112
#/                                                                                            */
113
#/  Create filelists for simulation, code coverage                                            */
114
#/                                                                                            */
115
#/                                                                                            */
116
#/*********************************************************************************************/
117
 
118
@filelist_sim = (  );
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
#############################################################################
128
##
129
##
130
#############################################################################
131
 
132
print "Building SIM filelists for  $work_site  $vendor $library   $component $version $variant \n" ;
133
my $sim_library_path ;
134
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
135
my $socgen_file               = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
136
my $lib_comp_sep             = yp::lib::find_lib_comp_sep($vendor,$library,$component);
137
 
138
my $sim_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
139
 
140
if ($sim_comp_path)
141
{
142
$sim_library_path            ="${lib_comp_sep}${sim_comp_path}";
143
}
144
else
145
{
146
$sim_library_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
147
}
148
 
149
 
150
#/*********************************************************************************************/
151
#/                                                                                            */
152
#/                                                                                            */
153
#/  Read each variants parameters and defaults into an array and their order into an array    */
154
#/  order must be preservered so that parameters can use the values of other parameters       */
155
#/                                                                                            */
156
#/*********************************************************************************************/
157
 
158
my %default_parameters = ();
159
my @parameter_order    = ();
160
 
161
 
162
foreach  my   $i_name ($socgen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$variant']/socgen:parameters/socgen:parameter"))
163
      {
164
      my($parameter_name)     = $i_name ->findnodes('socgen:name/text()')->to_literal ;
165
      my($parameter_default)  = $i_name ->findnodes('socgen:value/text()')->to_literal ;
166
      $default_parameters{$parameter_name}  = $parameter_default;
167
      push  @parameter_order ,$parameter_name ;
168
      }
169
 
170
 
171
 
172
 
173
 
174
 
175
 
176
 
177
 
178
foreach my $comp ($spirit_component_file->findnodes('//ipxact:component'))
179
   {
180
   my($vendor)   = $comp->findnodes('./ipxact:vendor/text()')->to_literal ;
181
   my($library)  = $comp->findnodes('./ipxact:library/text()')->to_literal ;
182
   my($name)     = $comp->findnodes('./ipxact:name/text()')->to_literal ;
183
   my($version)  = $comp->findnodes('./ipxact:version/text()')->to_literal ;
184
   my $variant = "";
185
   if($version) {$variant = "${name}_${version}"}
186
   else         {$variant = "${name}"}
187
   print "rtl/gen directories  for    $library - $component         VLNV        $vendor - $library -  $name -  $variant \n";
188
   $module_name = yp::lib::get_module_name($vendor,$library,$name,$version);
189
   }
190
 
191
 
192
   print "CREATING componentRef filelists for   $library   $component  $name $variant \n";
193
 
194
 
195
   #/*********************************************************************************************/
196
   #/                                                                                            */
197
   #/                                                                                            */
198
   #/                                                                                            */
199
   #/                                                                                            */
200
   #/                                                                                            */
201
   #/                                                                                            */
202
   #/*********************************************************************************************/
203
 
204
 
205
foreach  my   $i_name ($socgen_file->findnodes("//socgen:testbench[socgen:variant/text() = '$variant']/socgen:code_coverage"))
206
   {
207
 
208
   my $path ="${home}${work_site}/${vendor}__${library}${sim_library_path}/cov";
209
   mkdir $path,0755          unless( -e $path );
210
   $path ="${home}${work_site}/${vendor}__${library}${sim_library_path}/cov/${variant}";
211
   mkdir $path,0755          unless( -e $path );
212
 
213
 
214
   my $outfile ="${home}${work_site}/${vendor}__${library}${sim_library_path}/cov/${variant}/TestBench";
215
   open  DUTFILE,">$outfile" or die "unable to open $outfile";
216
   print  DUTFILE  "`timescale    1ns/1ns   \n";
217
   print  DUTFILE  " module TB();   \n";
218
 
219
 
220
 
221
 
222
      print DUTFILE  "     $module_name   \n";
223
      my $first =1;
224
      foreach  my  $parameter_name  (@parameter_order)
225
         {
226
         my($parameter_default)  =    $default_parameters{$parameter_name};
227
         if($first)
228
           {
229
           print DUTFILE  "   #(  .${parameter_name}(${parameter_default})";
230
           $first = 0;
231
           }
232
         else
233
           {
234
           print DUTFILE  ",\n       .${parameter_name}(${parameter_default})";
235
           }
236
         }
237
         if($first)
238
           {
239
           print DUTFILE  "\n  test \n (); \n\n\n\n";
240
           }
241
          else
242
           {
243
           print DUTFILE  ") \n test \n (); \n\n\n\n";
244
           }
245
 
246
 
247
   print  DUTFILE  " endmodule   \n";
248
 
249
 
250
 
251
 
252
 
253
 
254
 
255
 
256
 
257
 
258
 
259
 
260
   }
261
 
262
 
263
 
264
   #/*********************************************************************************************/
265
   #/                                                                                            */
266
   #/ Make simulation file set                                                                   */
267
   #/                                                                                            */
268
   #/                                                                                            */
269
   #/                                                                                            */
270
   #/                                                                                            */
271
   #/*********************************************************************************************/
272
 
273
   print "CREATING sim files for   $library  $component   $chip   $name  $variant \n";
274
 
275
 
276
 
277
 
278
 
279
 
280
    foreach  my   $i_name ($socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:icarus/socgen:test[socgen:variant/text() = '$variant']"))
281
      {
282
      my($simulation)      = $i_name ->findnodes('socgen:name/text()')->to_literal ;
283
      my($configuration)   = $i_name ->findnodes('socgen:configuration/text()')->to_literal ;
284
      print " sim files for   $library  $component   $variant  $simulation $configuration          \n";
285
 
286
 
287
 
288
 
289
 
290
     my $design_db_filename = yp::lib::get_design_db_file;
291
     my $design_db   = new BerkeleyDB::Hash( -Filename => $design_db_filename, -Flags => DB_CREATE ) or die "Cannot open ${design_db_filename}: $!";
292
 
293
 
294
 
295
     my $data_db_filename = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,$simulation);
296
     my $data_db   = new BerkeleyDB::Hash( -Filename => $data_db_filename, -Flags => DB_CREATE ) or die "Cannot open ${data_db_filename}: $!";
297
 
298
 
299
     my $key;
300
     my $value;
301
 
302
 
303
     my @configs = ();
304
 
305
 
306
     my $cursor = $data_db ->db_cursor() ;
307
     while ($cursor->c_get($key, $value, DB_NEXT) == 0)
308
       {
309
 
310
 
311
       $_ = $key;
312
       if(/parameter_root__(\S+)/)
313
         {
314
#         print "$key $value  \n";
315
         push @configs,"${1}--${value}:::";
316
         }
317
 
318
       }
319
 
320
       my $status = $cursor->c_close() ;
321
 
322
       $data_db   -> db_close();
323
 
324
       @configs      = sys::lib::trim_sort(@configs);
325
 
326
       my $config_n;
327
 
328
       foreach my $config (@configs)
329
              {
330
              $config_n = "${config}${config_n}";
331
              }
332
 
333
      my $new_value;
334
      $config_n="CONFIG___${config_n}";
335
      $design_db->db_get($config_n, $new_value );
336
      $config_n=$new_value;
337
 
338
 
339
 
340
      my $outfile ="${home}${work_site}/${vendor}__${library}${sim_library_path}/icarus/${simulation}/TestBench";
341
      open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
342
 
343
      my %local_parameters =  %default_parameters;
344
      my @local_order      =  @parameter_order;
345
 
346
 
347
 
348
      foreach  my   $i_name ($socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:testbenches/socgen:testbench[socgen:variant/text() = '$variant']/./socgen:parameters/socgen:parameter/socgen:name"))
349
         {
350
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
351
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
352
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
353
         $local_parameters{$par_name} = $par_value;
354
         }
355
 
356
 
357
 
358
      foreach  my   $i_name ($socgen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
359
         {
360
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
361
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
362
         if($local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
363
         $local_parameters{$par_name} = $par_value;
364
         }
365
 
366
 
367
 
368
      foreach  my   $i_name ($socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:icarus/socgen:test[socgen:name/text() = '$simulation']/./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
 
379
 
380
 
381
 
382
 
383
 
384
      print SIM_PARM_FILE  "//  Testbench  for  $library    $component    $variant   $configuration    $simulation\n";
385
      print SIM_PARM_FILE  "`ifndef     TIMESCALE                                \n";
386
      print SIM_PARM_FILE  "`define     TIMESCALE   1ns/1ns                                \n";
387
      print SIM_PARM_FILE  "`endif                                \n";
388
      print SIM_PARM_FILE  "                                \n";
389
      print SIM_PARM_FILE  "`ifndef     TIMEFORMAT                                \n";
390
      print SIM_PARM_FILE  "`define     TIMEFORMAT  \$timeformat(-6, 2, \" us\", 14);                                \n";
391
      print SIM_PARM_FILE  "`endif                                \n";
392
      print SIM_PARM_FILE  "                                \n";
393
      print SIM_PARM_FILE  "`timescale `TIMESCALE                                \n";
394
      print SIM_PARM_FILE  "                                \n";
395
      print SIM_PARM_FILE  "module TB();                                \n";
396
      print SIM_PARM_FILE  "                                \n";
397
      print SIM_PARM_FILE  "initial                                \n";
398
      print SIM_PARM_FILE  "begin                                \n";
399
      print SIM_PARM_FILE  "`TIMEFORMAT                                \n";
400
      print SIM_PARM_FILE  "end                                \n";
401
      print SIM_PARM_FILE  "                                \n";
402
      print SIM_PARM_FILE  "`ifdef VCD                                \n";
403
      print SIM_PARM_FILE  "initial                                \n";
404
      print SIM_PARM_FILE  " begin                                \n";
405
      print SIM_PARM_FILE  "`include \"./dmp_define\"                                \n";
406
      print SIM_PARM_FILE  " end                                \n";
407
      print SIM_PARM_FILE  "`endif                                \n";
408
      print SIM_PARM_FILE  " reg clk,START;            \n";
409
      print SIM_PARM_FILE  " wire FAIL,FINISH;                               \n";
410
      print SIM_PARM_FILE  " reg  failed;                               \n";
411
      print SIM_PARM_FILE  " reg [31:0] failcount;                               \n";
412
      print SIM_PARM_FILE  "initial                             \n";
413
      print SIM_PARM_FILE  "begin                             \n";
414
      print SIM_PARM_FILE  "clk=0;                             \n";
415
      print SIM_PARM_FILE  "START=0;                             \n";
416
      print SIM_PARM_FILE  "@ (posedge clk);                             \n";
417
      print SIM_PARM_FILE  "@ (posedge clk);                             \n";
418
      print SIM_PARM_FILE  "@ (posedge clk) ;                             \n";
419
      print SIM_PARM_FILE  "START = 1;                             \n";
420
      print SIM_PARM_FILE  "end                       \n";
421
      print SIM_PARM_FILE  "always@(posedge clk)           \n";
422
      print SIM_PARM_FILE  "if(START && FINISH)           \n";
423
      print SIM_PARM_FILE  "begin           \n";
424
      print SIM_PARM_FILE  "   if(failed)        \n";
425
      print SIM_PARM_FILE  "     begin        \n";
426
      print SIM_PARM_FILE  "     \$display(\"%t  SIM over: ERROR    %d failures\",\$realtime ,failcount );        \n";
427
      print SIM_PARM_FILE  "     end        \n";
428
      print SIM_PARM_FILE  "  else        \n";
429
      print SIM_PARM_FILE  "     begin        \n";
430
      print SIM_PARM_FILE  "     \$display(\"%t  SIM over: PASSED\",\$realtime  );        \n";
431
      print SIM_PARM_FILE  "     end // else: !if(failed)        \n";
432
      print SIM_PARM_FILE  "\$dumpflush;           \n";
433
      print SIM_PARM_FILE  "\$finish;           \n";
434
      print SIM_PARM_FILE  "end           \n";
435
      print SIM_PARM_FILE  "always@(posedge clk or negedge START)        \n";
436
      print SIM_PARM_FILE  "if(!START)        \n";
437
      print SIM_PARM_FILE  "begin        \n";
438
      print SIM_PARM_FILE  "failed <= 1\'b0;        \n";
439
      print SIM_PARM_FILE  "failcount <= 32\'h0;        \n";
440
      print SIM_PARM_FILE  "end        \n";
441
      print SIM_PARM_FILE  "else        \n";
442
      print SIM_PARM_FILE  "begin        \n";
443
      print SIM_PARM_FILE  "if(FAIL)        \n";
444
      print SIM_PARM_FILE  "begin        \n";
445
      print SIM_PARM_FILE  "failed <= 1\'b1;        \n";
446
      print SIM_PARM_FILE  "failcount <= failcount + 32\'h00000001;        \n";
447
      print SIM_PARM_FILE  "end        \n";
448
      print SIM_PARM_FILE  "else        \n";
449
      print SIM_PARM_FILE  "begin        \n";
450
      print SIM_PARM_FILE  "failed <= failed;        \n";
451
      print SIM_PARM_FILE  "failcount <= failcount;        \n";
452
      print SIM_PARM_FILE  "end        \n";
453
      print SIM_PARM_FILE  "end           \n";
454
 
455
      print SIM_PARM_FILE  "always                       \n";
456
      print SIM_PARM_FILE  " #($local_parameters{\"PERIOD\"}/2) clk = !clk;                       \n";
457
      print SIM_PARM_FILE  "`include \"./test_define\"                                \n";
458
 
459
 
460
 
461
      print SIM_PARM_FILE  "     ${module_name}_${config_n}   \n";
462
 
463
      print SIM_PARM_FILE  "    test \n (.clk(clk),.START(START),.FAIL(FAIL),.FINISH(FINISH)); \n\n\n\n";
464
      print SIM_PARM_FILE  "task automatic next;           \n";
465
      print SIM_PARM_FILE  "  input [31:0] num;           \n";
466
      print SIM_PARM_FILE  "  repeat (num)       @ (posedge clk);           \n";
467
      print SIM_PARM_FILE  "endtask            \n";
468
      print SIM_PARM_FILE  "           \n";
469
      print SIM_PARM_FILE  "           \n";
470
      print SIM_PARM_FILE  "initial           \n";
471
      print SIM_PARM_FILE  "   begin           \n";
472
      print SIM_PARM_FILE  "   next($local_parameters{\"TIMEOUT\"});           \n";
473
      print SIM_PARM_FILE  "   \$display(\"%t  Sim over :ERROR    TIMEOUT\",\$realtime  );           \n";
474
      print SIM_PARM_FILE  "   @ (posedge clk)           \n";
475
      print SIM_PARM_FILE  "   \$dumpflush;                      \n";
476
      print SIM_PARM_FILE  "   \$finish;                         \n";
477
      print SIM_PARM_FILE  "   end           \n";
478
      print SIM_PARM_FILE  "            \n";
479
 
480
 
481
 
482
 
483
 
484
 
485
      print SIM_PARM_FILE  "endmodule                                \n";
486
 
487
 
488
 
489
 
490
 
491
      }
492
 
493
 
494
 
495
 
496
 
497
 

powered by: WebSVN 2.1.0

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