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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_tb] - Blame information for rev 134

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

Line No. Rev Author Line
1 133 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
#/**********************************************************************/
4
#/*                                                                    */
5
#/*             -------                                                */
6
#/*            /   SOC  \                                              */
7
#/*           /    GEN   \                                             */
8
#/*          /    TOOL    \                                            */
9
#/*          ==============                                            */
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
# General PERL config
49
############################################################################
50
use Getopt::Long;
51
use English;
52
use File::Basename;
53
use Cwd;
54
use Scalar::Util qw(looks_like_number);
55
use XML::LibXML;
56
use lib './tools';
57
use sys::lib;
58
use yp::lib;
59
use BerkeleyDB;
60
 
61
 
62
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
63
 
64
 
65
############################################################################
66
### Process the options
67
############################################################################
68
Getopt::Long::config("require_order", "prefix=-");
69
GetOptions("h","help",
70
           "envidentifier=s" => \$envidentifier,
71
           "prefix=s" => \$prefix,
72
           "vendor=s" => \$vendor,
73
           "library=s" => \$library,
74
           "component=s" => \$component,
75
           "version=s" => \$version,
76
           "tb=s" => \$tb,
77
           "verbose"
78
) || die "(use '$program_name -h' for help)";
79
 
80
 
81
##############################################################################
82
## Help option
83
##############################################################################
84
if ( $opt_h  or $opt_help  )
85
  { print "\n gen_tb    -vendor vendor_name -library library_name  -component component_name  -version version_name -tb tb  verbose \n";
86
    exit 1;
87
  }
88
 
89
 
90
 
91
 
92
 
93
 
94
#############################################################################
95
##
96
##
97
#############################################################################
98
 
99
 
100
$home = cwd();
101
 
102
 
103
my $variant;
104
 
105
if($version)       {$variant   = "${component}_${version}";}
106
else               {$variant   = "${component}";}
107
 
108
 
109
unless($tb)       {$tb   = "tb";}
110
 
111
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
112
my $parser = XML::LibXML->new();
113
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
114
 
115
if($opt_verbose) {print "\n READ_ports     $vendor $library $component $version         \n";}
116
 
117
 
118
 
119
my $io_ports  = yp::lib::get_io_ports() ;
120
 
121
   my $gen_port_outfile = yp::lib::get_io_ports_db_filename($vendor,$library,$component,$version);
122 134 jt_eaton
   print "$gen_port_outfile \n";
123 133 jt_eaton
   $ports_db   = new BerkeleyDB::Hash( -Filename => $gen_port_outfile, -Flags => DB_CREATE ) or die "Cannot open ${gen_port_outfile}: $!";
124
 
125
   my $key;
126
   my $value;
127
 
128
   my @adhoc_list;
129
   my @parameter_list;
130
 
131
   $cursor = $ports_db ->db_cursor() ;
132
   while ($cursor->c_get($key, $value, DB_NEXT) == 0)
133
 
134
   {
135
    my $key_type;
136
    my $busref;
137
    my $conn;
138
 
139
   print " $key   $value   \n";
140
 
141
   ( ${key_type},${busref},${conn}) = split( /\./ , $key);
142
 
143
   ( ${log_name},${direction},${type},${vector},${left},${right},${phy_name}) = split ':', $value;
144
                 if(($key_type eq "BusRef"))
145
                    {
146
                    }
147
                 else
148
                    {
149
#                    print " $value \n";
150
                    if($direction eq "input")
151
                      {
152
                      push (@adhoc_list,"${log_name}::${vector}::${left}:${right}");
153
                      }
154
                    if($direction eq "output")
155
                      {
156
                      push (@adhoc_list,"${log_name}::${vector}::${left}:${right}");
157
                      }
158
                    if($direction eq "inout")
159
                      {
160
                      push (@adhoc_list,"${log_name}::${vector}::${left}:${right}");
161
                      }
162
 
163
                    }
164
   }
165
 
166
   my $status = $cursor->c_close() ;
167
 
168
 
169
   $ports_db   -> db_close();
170
 
171
 
172
 
173
 
174
 
175
 
176
 
177
 
178
 
179
 
180
 
181
#############################################################################
182
 
183
$home = cwd();
184
 
185
unless ($prefix)
186
 {
187
 $prefix   = yp::lib::get_workspace();
188
 $prefix   =  "/${prefix}";
189
 }
190
 
191
 
192
my   $variant;
193
my   $configuration;
194
 
195
my $dest_dir            = "elab";
196
my $destination         = "${component}_${version}_${tb}";
197
 
198
 
199
 
200
 
201
 
202
 
203
my $root                =      "root";
204
 
205
if($version)       {$variant   = "${component}_${version}";}
206
else               {$variant   = "${component}";}
207
 
208
 
209
 
210
 
211
my $parser = XML::LibXML->new();
212
 
213
 
214
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
215
 
216
unless ($socgen_file)      { print "No socgen ip file   \n";};
217
 
218
 
219
 
220
 
221
 
222
 
223
 
224 134 jt_eaton
my $elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,"default");
225 133 jt_eaton
 
226
 
227
 
228 134 jt_eaton
if(-e  $elab_db_file  )
229 133 jt_eaton
        {
230 134 jt_eaton
        print "$elab_db_file  does exist  \n";
231 133 jt_eaton
        }
232
 
233
 
234
 
235
 
236
 
237 134 jt_eaton
   my $elab_db  = new BerkeleyDB::Hash( -Filename => "$elab_db_file", -Flags => DB_CREATE ) or die "Cannot open $elab_db_file: $!";
238 133 jt_eaton
 
239
 
240
   $cursor = $elab_db ->db_cursor() ;
241
   while ($cursor->c_get($key, $value, DB_NEXT) == 0)
242
   {
243
   my $index;
244
   my $param;
245
 
246
  ( $index,$param) = split( /\__/ , $key);
247
 
248 134 jt_eaton
  if($index eq "parameter_root")
249 133 jt_eaton
    {
250
        print   "$key  $param            \n";
251
    push (@parameter_list,"${param}");
252
    }
253
   }
254
 
255
   my $status = $cursor->c_close() ;
256
 
257
   $elab_db->db_close();
258
 
259
 
260
 
261
   @adhoc_list        = sys::lib::trim_sort(@adhoc_list);
262
   @parameter_list    = sys::lib::trim_sort(@parameter_list);
263
my @tb_adhoc_list;
264
 
265
 
266
    foreach my $list (@adhoc_list)
267
     {
268
     my $name;
269
     my $vector;
270
     my $index;
271
     my $left;
272
     my $right;
273
 
274
if($opt_verbose) {   print "-- ${list}|||  \n"; }
275
 
276
    ( $name,$vector,$index) = split( /\::/ , $list);
277
    ( $left,$right) = split( /\:/ , $index);
278
 
279
 
280
 
281
          if ( $vector eq "vector" )
282
             {
283
        print   "  $name  [${index}]          \n";
284
             push (@tb_adhoc_list,  "\n${name}<\/spirit:name>\n\n\n<\/spirit:adHocConnection>\n"     );
285
             }
286
             else
287
            {
288
        print   "  $name           \n";
289
            push (@tb_adhoc_list,  "\n${name}<\/spirit:name>\n\n\n<\/spirit:adHocConnection>\n"     );
290
             }
291
 
292
 
293
     }
294
 
295
 
296
 
297
 
298
 
299
 
300
 
301
 
302
 
303
 
304
 
305
 
306
 
307
 
308
 
309
my $repo = yp::lib::find_component_repo($vendor,$library,$component) ;
310
 
311
 
312
my $variant;
313
my $view;
314
 
315
 
316
 
317
 
318
if($version)       {$variant   = "${component}_${version}";}
319
else               {$variant   = "${component}";}
320
 
321
unless($destination) { $destination = $variant;}
322
 
323
print "\n GENERATE    $prefix $vendor $library $component $version $configuration      $dest_dir  $destination   \n";
324
 
325
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
326
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
327
 
328
my $parser = XML::LibXML->new();
329
 
330
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
331
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
332
my $doc_library_path         = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:doc/socgen:library_path/text()")->to_literal;
333
 
334
 
335
my $sim_library_path ;
336
 
337
my $sim_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
338
 
339
if ($sim_comp_path)  {$sim_library_path  ="${lib_comp_sep}${sim_comp_path}";}
340
else                 {$sim_library_path  = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;}
341
 
342
 
343
 
344
 
345
 
346
   print "Creating testbench for   $vendor $library $component  $version \n";
347
 
348
 
349
   my $path  ="${home}${repo}/${vendor}/${library}${sim_library_path}";
350
   mkdir $path,0755             unless( -e $path );
351
 
352
   my $path  ="${home}${repo}/${vendor}/${library}${sim_library_path}/testbenches";
353
   mkdir $path,0755             unless( -e $path );
354
 
355
      $path  ="${home}${repo}/${vendor}/${library}${sim_library_path}/testbenches/xml";
356
   mkdir $path,0755             unless( -e $path );
357
 
358
 
359
 
360
   $outfile ="${home}${repo}/${vendor}/${library}${sim_library_path}/testbenches/xml/${variant}_duth.design.xml";
361
   open TB_DESIGN_FILE,">$outfile" or die "unable to open $outfile";
362
 
363
 
364
   print TB_DESIGN_FILE  "\n";
365
   print TB_DESIGN_FILE  "           \n";
372
   print TB_DESIGN_FILE  "
373
   print TB_DESIGN_FILE  "xmlns:spirit=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\"\n";
374
   print TB_DESIGN_FILE  "xmlns:socgen=\"http://opencores.org\"\n";
375
   print TB_DESIGN_FILE  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
376
   print TB_DESIGN_FILE  "xsi:schemaLocation=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\n";
377
   print TB_DESIGN_FILE  "http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009/index.xsd\">\n";
378
   print TB_DESIGN_FILE  "${vendor}\n";
379
   print TB_DESIGN_FILE  "${library}\n";
380
   print TB_DESIGN_FILE  "${component}\n";
381
   print TB_DESIGN_FILE  "${version}_duth.design\n";
382
 
383
 
384
 
385
 
386
 
387
     @tb_adhoc_list      = sys::lib::trim_sort(@tb_adhoc_list);
388
     print TB_DESIGN_FILE  "\n\n";
389
 
390
     foreach $adhoc_line (@tb_adhoc_list)
391
        {
392
 
393
            print TB_DESIGN_FILE  "${adhoc_line}\n";
394
 
395
 
396
        }
397
 
398
     print TB_DESIGN_FILE  "\n\n";
399
 
400
 
401
 
402
 
403
 
404
 
405
print TB_DESIGN_FILE    "\n\n";
406
 
407
 
408
 
409
 
410
print TB_DESIGN_FILE    "\n";
411
print TB_DESIGN_FILE    "dut\n";
412
print TB_DESIGN_FILE    "\n";
413
print TB_DESIGN_FILE    "\n";
414
 
415
 
416
    foreach my $parameter_name (@parameter_list)
417
 
418
 
419
        {
420
        print TB_DESIGN_FILE  " ${parameter_name}<\/spirit:configurableElementValue>\n";
421
        }
422
 
423
print TB_DESIGN_FILE    "\n";
424
print TB_DESIGN_FILE    "\n";
425
print TB_DESIGN_FILE    "\n";
426
print TB_DESIGN_FILE    "\n";
427
 
428
 
429
 
430
 
431
 
432
 
433
 
434
 
435
 
436
 
437
 
438
 
439
 
440
 
441
 
442
 
443
 
444
 
445
 
446
 
447
 
448
 
449
 
450
 
451
 
452
 
453
 
454
 
455
 
456
 
457
 
458
 
459
 
460
 
461
 
462
 
463
1
464
 
465
 

powered by: WebSVN 2.1.0

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