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

Subversion Repositories socgen

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

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

powered by: WebSVN 2.1.0

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