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

Subversion Repositories socgen

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

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

powered by: WebSVN 2.1.0

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