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

Subversion Repositories socgen

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

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

powered by: WebSVN 2.1.0

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