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

Subversion Repositories socgen

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

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 135 jt_eaton
#/****************************************************************************/
4
#/*                                                                          */
5
#/*   SOCGEN Design for Reuse toolset                                        */
6
#/*                                                                          */
7
#/*   Version 1.0.0                                                          */
8
#/*                                                                          */
9
#/*   Author(s):                                                             */
10
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
11
#/*                                                                          */
12
#/****************************************************************************/
13
#/*                                                                          */
14
#/*                                                                          */
15
#/*             Copyright 2016 John T Eaton                                  */
16
#/*                                                                          */
17
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
18
#/* you may not use this file except in compliance with the License.         */
19
#/* You may obtain a copy of the License at                                  */
20
#/*                                                                          */
21
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
22
#/*                                                                          */
23
#/* Unless required by applicable law or agreed to in writing, software      */
24
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
25
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
26
#/* See the License for the specific language governing permissions and      */
27
#/* limitations under the License.                                           */
28
#/*                                                                          */
29
#/*                                                                          */
30
#/****************************************************************************/
31 133 jt_eaton
 
32
 
33 135 jt_eaton
 
34 133 jt_eaton
############################################################################
35
# General PERL config
36
############################################################################
37
use Getopt::Long;
38
use English;
39
use File::Basename;
40
use Cwd;
41
use Scalar::Util qw(looks_like_number);
42
use XML::LibXML;
43
use lib './tools';
44
use sys::lib;
45
use yp::lib;
46
use BerkeleyDB;
47
 
48
 
49
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
50
 
51
 
52
############################################################################
53
### Process the options
54
############################################################################
55
Getopt::Long::config("require_order", "prefix=-");
56
GetOptions("h","help",
57
           "envidentifier=s" => \$envidentifier,
58
           "prefix=s" => \$prefix,
59
           "vendor=s" => \$vendor,
60
           "library=s" => \$library,
61
           "component=s" => \$component,
62
           "version=s" => \$version,
63
           "tb=s" => \$tb,
64
           "verbose"
65
) || die "(use '$program_name -h' for help)";
66
 
67
 
68
##############################################################################
69
## Help option
70
##############################################################################
71
if ( $opt_h  or $opt_help  )
72
  { print "\n gen_tb    -vendor vendor_name -library library_name  -component component_name  -version version_name -tb tb  verbose \n";
73
    exit 1;
74
  }
75
 
76
 
77
 
78
 
79
 
80
 
81
#############################################################################
82
##
83
##
84
#############################################################################
85
 
86
 
87
$home = cwd();
88
 
89
 
90
my $variant;
91
 
92
if($version)       {$variant   = "${component}_${version}";}
93
else               {$variant   = "${component}";}
94
 
95
 
96
unless($tb)       {$tb   = "tb";}
97
 
98
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
99
my $parser = XML::LibXML->new();
100
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
101
 
102
if($opt_verbose) {print "\n READ_ports     $vendor $library $component $version         \n";}
103
 
104
 
105
 
106
my $io_ports  = yp::lib::get_io_ports() ;
107
 
108
   my $gen_port_outfile = yp::lib::get_io_ports_db_filename($vendor,$library,$component,$version);
109 134 jt_eaton
   print "$gen_port_outfile \n";
110 133 jt_eaton
   $ports_db   = new BerkeleyDB::Hash( -Filename => $gen_port_outfile, -Flags => DB_CREATE ) or die "Cannot open ${gen_port_outfile}: $!";
111
 
112
   my $key;
113
   my $value;
114
 
115
   my @adhoc_list;
116
   my @parameter_list;
117
 
118
   $cursor = $ports_db ->db_cursor() ;
119
   while ($cursor->c_get($key, $value, DB_NEXT) == 0)
120
 
121
   {
122
    my $key_type;
123
    my $busref;
124
    my $conn;
125
 
126
   print " $key   $value   \n";
127
 
128
   ( ${key_type},${busref},${conn}) = split( /\./ , $key);
129
 
130
   ( ${log_name},${direction},${type},${vector},${left},${right},${phy_name}) = split ':', $value;
131
                 if(($key_type eq "BusRef"))
132
                    {
133
                    }
134
                 else
135
                    {
136
#                    print " $value \n";
137
                    if($direction eq "input")
138
                      {
139
                      push (@adhoc_list,"${log_name}::${vector}::${left}:${right}");
140
                      }
141
                    if($direction eq "output")
142
                      {
143
                      push (@adhoc_list,"${log_name}::${vector}::${left}:${right}");
144
                      }
145
                    if($direction eq "inout")
146
                      {
147
                      push (@adhoc_list,"${log_name}::${vector}::${left}:${right}");
148
                      }
149
 
150
                    }
151
   }
152
 
153
   my $status = $cursor->c_close() ;
154
 
155
 
156
   $ports_db   -> db_close();
157
 
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
#############################################################################
169
 
170
$home = cwd();
171
 
172
unless ($prefix)
173
 {
174
 $prefix   = yp::lib::get_workspace();
175
 $prefix   =  "/${prefix}";
176
 }
177
 
178
 
179
my   $variant;
180
my   $configuration;
181
 
182
my $dest_dir            = "elab";
183
my $destination         = "${component}_${version}_${tb}";
184
 
185
 
186
 
187
 
188
 
189
 
190
my $root                =      "root";
191
 
192
if($version)       {$variant   = "${component}_${version}";}
193
else               {$variant   = "${component}";}
194
 
195
 
196
 
197
 
198
my $parser = XML::LibXML->new();
199
 
200
 
201
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
202
 
203
unless ($socgen_file)      { print "No socgen ip file   \n";};
204
 
205
 
206
 
207
 
208
 
209
 
210
 
211 134 jt_eaton
my $elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,"default");
212 133 jt_eaton
 
213
 
214
 
215 134 jt_eaton
if(-e  $elab_db_file  )
216 133 jt_eaton
        {
217 134 jt_eaton
        print "$elab_db_file  does exist  \n";
218 133 jt_eaton
        }
219
 
220
 
221
 
222
 
223
 
224 134 jt_eaton
   my $elab_db  = new BerkeleyDB::Hash( -Filename => "$elab_db_file", -Flags => DB_CREATE ) or die "Cannot open $elab_db_file: $!";
225 133 jt_eaton
 
226
 
227
   $cursor = $elab_db ->db_cursor() ;
228
   while ($cursor->c_get($key, $value, DB_NEXT) == 0)
229
   {
230
   my $index;
231
   my $param;
232
 
233
  ( $index,$param) = split( /\__/ , $key);
234
 
235 134 jt_eaton
  if($index eq "parameter_root")
236 133 jt_eaton
    {
237
        print   "$key  $param            \n";
238
    push (@parameter_list,"${param}");
239
    }
240
   }
241
 
242
   my $status = $cursor->c_close() ;
243
 
244
   $elab_db->db_close();
245
 
246
 
247
 
248
   @adhoc_list        = sys::lib::trim_sort(@adhoc_list);
249
   @parameter_list    = sys::lib::trim_sort(@parameter_list);
250
my @tb_adhoc_list;
251
 
252
 
253
    foreach my $list (@adhoc_list)
254
     {
255
     my $name;
256
     my $vector;
257
     my $index;
258
     my $left;
259
     my $right;
260
 
261
if($opt_verbose) {   print "-- ${list}|||  \n"; }
262
 
263
    ( $name,$vector,$index) = split( /\::/ , $list);
264
    ( $left,$right) = split( /\:/ , $index);
265
 
266
 
267
 
268
          if ( $vector eq "vector" )
269
             {
270
        print   "  $name  [${index}]          \n";
271 135 jt_eaton
             push (@tb_adhoc_list,  "\n${name}<\/ipxact:name>\n\n\n<\/ipxact:adHocConnection>\n"     );
272 133 jt_eaton
             }
273
             else
274
            {
275
        print   "  $name           \n";
276 135 jt_eaton
            push (@tb_adhoc_list,  "\n${name}<\/ipxact:name>\n\n\n<\/ipxact:adHocConnection>\n"     );
277 133 jt_eaton
             }
278
 
279
 
280
     }
281
 
282
 
283
 
284
 
285
 
286
 
287
 
288
 
289
 
290
 
291
 
292
 
293
 
294
 
295
 
296
my $repo = yp::lib::find_component_repo($vendor,$library,$component) ;
297
 
298
 
299
my $variant;
300
my $view;
301
 
302
 
303
 
304
 
305
if($version)       {$variant   = "${component}_${version}";}
306
else               {$variant   = "${component}";}
307
 
308
unless($destination) { $destination = $variant;}
309
 
310
print "\n GENERATE    $prefix $vendor $library $component $version $configuration      $dest_dir  $destination   \n";
311
 
312
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
313
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
314
 
315
my $parser = XML::LibXML->new();
316
 
317
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
318
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
319
my $doc_library_path         = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:doc/socgen:library_path/text()")->to_literal;
320
 
321
 
322
my $sim_library_path ;
323
 
324
my $sim_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
325
 
326
if ($sim_comp_path)  {$sim_library_path  ="${lib_comp_sep}${sim_comp_path}";}
327
else                 {$sim_library_path  = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;}
328
 
329
 
330
 
331
 
332
 
333
   print "Creating testbench for   $vendor $library $component  $version \n";
334
 
335
 
336
   my $path  ="${home}${repo}/${vendor}/${library}${sim_library_path}";
337
   mkdir $path,0755             unless( -e $path );
338
 
339
   my $path  ="${home}${repo}/${vendor}/${library}${sim_library_path}/testbenches";
340
   mkdir $path,0755             unless( -e $path );
341
 
342
      $path  ="${home}${repo}/${vendor}/${library}${sim_library_path}/testbenches/xml";
343
   mkdir $path,0755             unless( -e $path );
344
 
345
 
346
 
347
   $outfile ="${home}${repo}/${vendor}/${library}${sim_library_path}/testbenches/xml/${variant}_duth.design.xml";
348
   open TB_DESIGN_FILE,">$outfile" or die "unable to open $outfile";
349
 
350
 
351
   print TB_DESIGN_FILE  "\n";
352
   print TB_DESIGN_FILE  "           \n";
359 135 jt_eaton
   print TB_DESIGN_FILE  "
360 133 jt_eaton
   print TB_DESIGN_FILE  "xmlns:spirit=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\"\n";
361
   print TB_DESIGN_FILE  "xmlns:socgen=\"http://opencores.org\"\n";
362
   print TB_DESIGN_FILE  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
363
   print TB_DESIGN_FILE  "xsi:schemaLocation=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\n";
364
   print TB_DESIGN_FILE  "http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009/index.xsd\">\n";
365 135 jt_eaton
   print TB_DESIGN_FILE  "${vendor}\n";
366
   print TB_DESIGN_FILE  "${library}\n";
367
   print TB_DESIGN_FILE  "${component}\n";
368
   print TB_DESIGN_FILE  "${version}_duth.design\n";
369 133 jt_eaton
 
370
 
371
 
372
 
373
 
374
     @tb_adhoc_list      = sys::lib::trim_sort(@tb_adhoc_list);
375 135 jt_eaton
     print TB_DESIGN_FILE  "\n\n";
376 133 jt_eaton
 
377
     foreach $adhoc_line (@tb_adhoc_list)
378
        {
379
 
380
            print TB_DESIGN_FILE  "${adhoc_line}\n";
381
 
382
 
383
        }
384
 
385 135 jt_eaton
     print TB_DESIGN_FILE  "\n\n";
386 133 jt_eaton
 
387
 
388
 
389
 
390
 
391
 
392 135 jt_eaton
print TB_DESIGN_FILE    "\n\n";
393 133 jt_eaton
 
394
 
395
 
396
 
397 135 jt_eaton
print TB_DESIGN_FILE    "\n";
398
print TB_DESIGN_FILE    "dut\n";
399
print TB_DESIGN_FILE    "\n";
400
print TB_DESIGN_FILE    "\n";
401 133 jt_eaton
 
402
 
403
    foreach my $parameter_name (@parameter_list)
404
 
405
 
406
        {
407 135 jt_eaton
        print TB_DESIGN_FILE  " ${parameter_name}<\/ipxact:configurableElementValue>\n";
408 133 jt_eaton
        }
409
 
410 135 jt_eaton
print TB_DESIGN_FILE    "\n";
411
print TB_DESIGN_FILE    "\n";
412
print TB_DESIGN_FILE    "\n";
413
print TB_DESIGN_FILE    "\n";
414 133 jt_eaton
 
415
 
416
 
417
 
418
 
419
 
420
 
421
 
422
 
423
 
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
1
451
 
452
 

powered by: WebSVN 2.1.0

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