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

Subversion Repositories socgen

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

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

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

powered by: WebSVN 2.1.0

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