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

Subversion Repositories socgen

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

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

Line No. Rev Author Line
1 131 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
           "path=s"          => \$path,
77
           "bus_name=s"      => \$bus_name,
78 133 jt_eaton
           "test_name=s"      => \$test_name,
79
           "dest_dir=s"      => \$dest_dir
80 131 jt_eaton
 
81
 
82
 
83
) || die "(use '$program_name -h' for help)";
84
 
85
 
86
##############################################################################
87
## Help option
88
##############################################################################
89
if ( $opt_h  or $opt_help  )
90 133 jt_eaton
  { print "\n trace_bus -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name -path root.dut.core.cpu -bus_name cpu -dest_dir dest_dir    \n";
91 131 jt_eaton
    exit 1;
92
  }
93
 
94
 
95
 
96
#############################################################################
97
##
98
##
99
#############################################################################
100
 
101
$home = cwd();
102
 
103
unless ($prefix)
104
 {
105
 $prefix   = yp::lib::get_workspace();
106
 $prefix   =  "/${prefix}";
107
 }
108
 
109
 
110
unless ($path)
111
 {
112
 $path   =  "root";
113
 }
114
 
115
 
116
 
117
 
118
 
119
my   $variant;
120 133 jt_eaton
unless(defined   $dest_dir  ){ $dest_dir            = "elab";}
121 131 jt_eaton
 
122 133 jt_eaton
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version);
123 131 jt_eaton
 
124 133 jt_eaton
my   $destination         = "${main_module_name}";
125
 
126
if($test_name)
127
  {
128
  $destination         = "${destination}_${test_name}";
129
  }
130
 
131
 
132 131 jt_eaton
my @reg_list ="";
133
my @param_list ="";
134
 
135
my $root                =      "root";
136
 
137
if($version)       {$variant   = "${component}_${version}";}
138
else               {$variant   = "${component}";}
139
 
140 134 jt_eaton
#print "trace_bus  -prefix $prefix -vendor $vendor -library $library -component $component -version $version -path $path   -bus_name $bus_name -test_name $test_name  \n";
141 131 jt_eaton
 
142
my $parser = XML::LibXML->new();
143
 
144
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
145
 
146
#unless ($socgen_file)      { print "No socgen ip file   \n";};
147
 
148
 
149
 
150
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
151
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
152
 
153 133 jt_eaton
my $root_path;
154
if($dest_dir eq "elab")
155
{
156
 $root_path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/../${dest_dir}";
157
}
158
else
159
{
160
 $root_path  = "${home}/${dest_dir}";
161
}
162 131 jt_eaton
 
163
 
164 133 jt_eaton
 unless( -e $root_path )
165
      {
166 134 jt_eaton
      #print "$root_path does not exist... creating \n";
167 133 jt_eaton
      my $cmd = "mkdir $root_path \n";
168
      if(system($cmd)){};
169
      }
170 131 jt_eaton
 
171 133 jt_eaton
 
172
 $root_path  = "${root_path}/${destination}";
173
 
174
 
175
 unless( -e $root_path )
176
      {
177 134 jt_eaton
      #print "$root_path does not exist... creating \n";
178 133 jt_eaton
      my $cmd = "mkdir $root_path \n";
179
      if(system($cmd)){};
180
      }
181
 
182
 
183
 
184 131 jt_eaton
my $sw_dir     = "${root_path}/sw";
185
mkdir $sw_dir,0755             unless( -e $sw_dir );
186
 
187
 
188
my $output_file = "${sw_dir}/${path}_${bus_name}.v";
189
$output_file =~s/root.dut.//;
190
open PARAM_FILE,">$output_file" or die "unable to open $output_file";
191
 
192
my $output_file = "${sw_dir}/${path}_${bus_name}.h";
193
$output_file =~s/root.dut.//;
194
open PARAMH_FILE,">$output_file" or die "unable to open $output_file";
195
 
196
 
197
my $report_dir     = "${root_path}/memmaps";
198
mkdir $report_dir,0755             unless( -e $report_dir );
199
 
200
$output_file = "${report_dir}/${path}_${bus_name}.txt";
201
$output_file =~s/root.dut.//;
202
 
203
open DEST_FILE,">$output_file" or die "unable to open $output_file";
204
 
205 134 jt_eaton
my $elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,"default");
206 131 jt_eaton
 
207
 
208
 
209 134 jt_eaton
unless(-e  $elab_db_file  )
210 131 jt_eaton
        {
211 134 jt_eaton
        #print "$elab_db_file  root file does not exist  \n";
212 131 jt_eaton
        }
213
 
214 134 jt_eaton
my $root_db = new BerkeleyDB::Hash( -Filename => "$elab_db_file", -Flags => DB_CREATE ) or die "Cannot open $elab_db_file: $!";
215 131 jt_eaton
 
216
 
217
my $comp_data;
218
 
219
my $bd_vendor;
220
my $bd_library;
221
my $bd_component;
222
my $bd_version;
223
 
224
 
225
 
226
 
227
#print "STARTING $path       ::  $bus_name  \n";
228
 
229
 
230
$root_db->db_get("component___${path}", $comp_data );
231
( $vendor,$library,$component,$version) = split( /\:/ , $comp_data);
232
 
233
 
234
 
235 134 jt_eaton
my $instance_db_file  = yp::lib::get_io_busses_db_filename($vendor,$library,$component,$version,"default");
236 131 jt_eaton
 
237
 
238
 
239
unless(-e  $instance_db_file  )
240
        {
241 134 jt_eaton
        #print "$instance_db_file  instance file does not exist  \n";
242 131 jt_eaton
        }
243
 
244
my $instance_db      = new BerkeleyDB::Hash( -Filename => "$instance_db_file", -Flags => DB_CREATE ) or die "Cannot open $instance_db_file: $!";
245
 
246
 
247
my $base_addr = hex(0x0000);
248
 
249
 
250
my $repo_data;
251
 
252
$instance_db->db_get("AbsDef.${bus_name}.master", $repo_data );
253
 
254
 
255
 
256
if($repo_data)
257
  {
258
  ( $bd_vendor,$bd_library,$bd_component,$bd_version) = split( /\:/ , $repo_data);
259
#  print  "MASTER $bd_vendor $bd_library $bd_component $bd_version   \n";
260
  $repo_data = "";
261
 
262
 
263
  $_ = "$path";
264
  if(/(\S+)\.(\S+)/)
265
    {
266
    $path      = $1;
267
    }
268
    follow_bus("${path}",$bus_name,$base_addr);
269
  }
270
 
271
 
272
$instance_db->db_get("AbsDef.${bus_name}.slave", $repo_data );
273
$instance_db->db_close();
274
 
275
if($repo_data)
276
  {
277
  ( $bd_vendor,$bd_library,$bd_component,$bd_version) = split( /\:/ , $repo_data);
278
#  print  "SLAVE $bd_vendor $bd_library $bd_component $bd_version   \n";
279
  $repo_data = "";
280
  follow_bus("${path}",$bus_name,$base_addr);
281
  }
282
 
283
 
284
 
285
$root_db->db_close();
286
 
287
@reg_list = sys::lib::trim_sort(@reg_list);
288
 
289
foreach my $reg_line (@reg_list)
290
{
291
print DEST_FILE "$reg_line  \n";
292
}
293
 
294
 
295
 
296
@param_list = sys::lib::trim_sort(@param_list);
297
 
298
foreach my $param_line (@param_list)
299
{
300
 
301
( $address,$parameter) = split( /\:/ , $param_line);
302
 
303
if($parameter)
304
{
305
print PARAM_FILE   "parameter $parameter = $address ; \n";
306
print PARAMH_FILE "$parameter = $address ; \n";
307
}
308
}
309
 
310
#print "FINISHED \n";
311
 
312
 
313
 
314
 
315
 
316
 
317
 
318
 
319
 
320
 
321
 
322
 
323
 
324
 
325
sub follow_bus
326
   {
327
   my @params           = @_;
328
   my $base_addr        = pop(@params);
329
   my $bus_name         = pop(@params);
330
   my $path            = pop(@params);
331
 
332
   my $vendor;
333
   my $library;
334
   my $component;
335
   my $version;
336
   my $comp_data;
337
   my $bd_vendor;
338
   my $bd_library;
339
   my $bd_component;
340
   my $bd_version;
341
   my $repo_data;
342
 
343
#   print "START_FOLLOW   $path                 == $bus_name  \n";
344
 
345
   $root_db->db_get("component___${path}", $comp_data );
346
   ( $vendor,$library,$component,$version) = split( /\:/ , $comp_data);
347
 
348
#   print "QQQQQQ  $path    ||  $vendor $library $component $version ==  $bus_name  \n";
349
 
350
 
351
 
352 133 jt_eaton
 
353 134 jt_eaton
   my $instance_db_file  = yp::lib::get_io_busses_db_filename($vendor,$library,$component,$version,"default");
354 133 jt_eaton
 
355 131 jt_eaton
   unless(-e  $instance_db_file  )
356
        {
357 134 jt_eaton
        #print "$instance_db_file  instance file does not exist  \n";
358 131 jt_eaton
        }
359
 
360
   my $instance_db = new BerkeleyDB::Hash( -Filename => "$instance_db_file", -Flags => DB_CREATE ) or die "Cannot open $instance_db_file: $!";
361
 
362
 
363
 
364
   $instance_db->db_get("AbsDef.${bus_name}.master", $repo_data );
365
 
366
 
367
 
368
   if($repo_data)
369
     {
370
     ( $bd_vendor,$bd_library,$bd_component,$bd_version) = split( /\:/ , $repo_data);
371
#  print  "MASTER $bd_vendor $bd_library $bd_component $bd_version   \n";
372
     $repo_data = "";
373
     }
374
 
375
 
376
    $instance_db->db_get("AbsDef.${bus_name}.interconnect", $repo_data );
377
    if($repo_data)
378
      {
379
      my @couples = split( /\:/ , $repo_data);
380
      foreach my $pair (@couples)
381
        {
382
        my $new_instance;
383
        my $new_bus_name;
384
        ($new_instance,$new_bus_name) = split( /\.\./ , $pair);
385
#        print  "INTC    $path           $new_instance  ==  $new_bus_name   \n";
386
        follow_bus("${path}.${new_instance}",$new_bus_name,$base_addr);
387
        return(1);
388
        }
389
      $repo_data = "";
390
      }
391
 
392
   $instance_db->db_get("AbsDef.${bus_name}.slave", $repo_data );
393
 
394
 
395
   if($repo_data)
396
      {
397
      ( $bd_vendor,$bd_library,$bd_component,$bd_version) = split( /\:/ , $repo_data);
398
#      print  "SLAVE  $bd_vendor $bd_library $bd_component $bd_version   \n";
399
      $repo_data = "";
400
      $instance_db->db_get("AbsDef.${bus_name}.bridge", $repo_data );
401
      if($repo_data)
402
         {
403
         $_ = "$path";
404
         if(/(\S+)\.(\S+)/)
405
           {
406
           $path      = $1;
407
           }
408
 
409
 
410
         my @couples = split( /\::/ , $repo_data);
411
         foreach my $pair (@couples)
412
           {
413
           my $new_bus_name;
414
           my $new_base_addr;
415
 
416
          ($new_bus_name,$new_base_addr) = split( /\.\./ , $pair);
417
           my $mapped_addr = $base_addr + $new_base_addr;
418
#           print  "BRIDGE  $path        ==  ${bus_name}   $new_bus_name  $mapped_addr           \n";
419
           $instance_db->db_get("BlkDef.${bus_name}.${new_bus_name}", $Repo_data );
420
#           print "BlkDef.${bus_name}.${new_bus_name} $Repo_data  \n";
421
           ( $Base,$Range) = split( /\::/ , $Repo_data);
422
           $Saddr = $Base + $base_addr;
423
           $Eaddr = $Base + $base_addr + $Range-1;
424
#           print "FRRRRRRRR $base_addr $Base  $Range   $Saddr  $Eaddr  \n";
425
           my $hex = sprintf("0x%04x",$Saddr);
426
           push @reg_list ,"$hex                                     ${component}.${path} ($component) ${bus_name}  Start "  ;
427
           $hex = sprintf("0x%04x",$Eaddr);
428
           push @reg_list ,"$hex                                     ${bus_name}  End "  ;
429
           follow_bus( "${path}",$new_bus_name,$mapped_addr);
430
           }
431
        $repo_data = "";
432
        }
433
      else
434
        {
435
#        print "Now dump registers for $path     $bus_name   $base_addr\n";
436
         my $hex = sprintf("0x%04x",$base_addr);
437
 
438
 
439
         my $key;
440
         my $value;
441
         my $RegDef;
442
         my $reg_bus;
443
         my $reg_name;
444
 
445
         my $cursor = $instance_db ->db_cursor() ;
446
         while ($cursor->c_get($key, $value, DB_NEXT) == 0)
447
            {
448
            ($RegDef,$reg_bus,$reg_name) = split( /\./ , $key);
449
#   print " $key      $value  \n";
450
 
451
             if( ($RegDef eq "RegDef") && ($reg_bus eq $bus_name))
452
               {
453
               ( $Xoffset,$Xname,$Xsize,$Xaccess) = split( /\::/ , $value);
454
               $addr = $base_addr + $Xoffset;
455
               my $hex = sprintf("0x%04x    %16s ",$addr, $Xname);
456
               push @reg_list ,"$hex            $Xsize   $Xaccess";
457
               my $temp = "${path}_${Xname}";
458
               $temp =~s/root.dut.//;
459
               $temp =~s/\./_/g;
460
               $hex = sprintf("'h%04x:%16s ",$addr, $temp);
461
               if($hex) {push @param_list ,"$hex";}
462
 #   print  " $addr   $Xname   $Xsize   $Xaccess    \n";
463
   }
464
 
465
 
466
   if( ($RegDef eq "BlkDef") && ($reg_bus eq $bus_name))
467
   {
468
   ( $Base,$Range) = split( /\::/ , $value);
469
 
470
   $Saddr = $Base + $base_addr;
471
   $Eaddr = $Base + $base_addr + $Range-1;
472
#print "FRRRRRRRR $base_addr $Base  $Range   $Saddr  $Eaddr  \n";
473
 
474
   my $hex = sprintf("0x%04x",$Saddr);
475
   push @reg_list ,"$hex                                     ${component}.${path} ($component) ${bus_name}  Start "  ;
476
   $hex = sprintf("0x%04x",$Eaddr);
477
   push @reg_list ,"$hex                                     ${bus_name}  End "  ;
478
   }
479
 
480
   }
481
   my $status = $cursor->c_close() ;
482
 
483
        }
484
      }
485
 
486
 
487
$instance_db->db_get("AbsDef.${bus_name}.node", $repo_data );
488
if($repo_data)
489
  {
490
  ( $bd_vendor,$bd_library,$bd_component,$bd_version) = split( /\:/ , $repo_data);
491
#  print  "NODE   $bd_vendor $bd_library $bd_component $bd_version   \n";
492
  $repo_data = "";
493
  $instance_db->db_get("AbsDef.${bus_name}.interconnect", $repo_data );
494
  if($repo_data)
495
     {
496
#     print  "INTC   $repo_data \n";
497
     my @couples = split( /\:/ , $repo_data);
498
     foreach my $pair (@couples)
499
      {
500
       my $new_instance;
501
       my $new_bus_name;
502
      ($new_instance,$new_bus_name) = split( /\.\./ , $pair);
503
 
504
#       print  "NODE  $path         $new_instance  ==  $new_bus_name   \n";
505
       follow_bus("${path}.${new_instance}",$new_bus_name,$base_addr);
506
       return(1);
507
 
508
      }
509
     }
510
  }
511
 
512
$instance_db->db_close();
513
return(0);
514
   }
515
 
516
1
517
 

powered by: WebSVN 2.1.0

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