source: trunk/IPs/systemC/processor/Morpheo/Script/log_trace.pl @ 2

Last change on this file since 2 was 2, checked in by kane, 17 years ago

Import Morpheo

File size: 2.8 KB
Line 
1#! /usr/bin/perl -w
2
3### -------------------------------------------------------------- ###
4#                                                                    #
5# File       : log_trace.pl                                          #
6# Authors    : Sroka Marek                                          #
7# Date       : 20/07/2006                                            #
8# Modif.     : 18/08/2006                                            #
9# Version    : 1.0                                                   #
10#                                                                    #
11# Origin     : this description has been developed by CAO-VLSI team  #
12#              at ASIM laboratory, University Pierre et Marie Curie  #
13#              4 Place Jussieu 75252 Paris Cedex 05 - France         #
14#                                                                    #
15### -------------------------------------------------------------- ###
16
17my $TAB1='|  ';
18my $TAB2='+--';
19
20sub usage() 
21{
22    print "usage : $0 rob_trace_file nm_file\n";
23    print "      * rob_trace_file : Trace file generate by simulation\n";
24    print "      * nm_file        : List of symbol (generate by nm)\n";
25    exit(1);
26}
27
28my $rob = $ARGV[0];
29my $nm  = $ARGV[1];
30
31if (not defined $rob) 
32{
33    usage();
34}
35
36unless (defined $nm) 
37{
38    usage();
39}
40
41my %calls=();
42my %end=();
43
44open (nm_f,$nm) or die "could not open $nm : $!\n";
45
46my $current_section;
47
48while ($line = <nm_f>) 
49{ 
50    if ($line =~ /([0-9a-f]{8}) [Tt] (.*)/) 
51    { 
52        my $addr=hex $1;
53        $calls{$addr}=$2;
54        $end{$current_section} = $addr if (defined $current_section);
55        $current_section=$addr;
56    }
57}
58
59$end{$current_section}=0xffffffff;
60
61close nm_f;
62
63my @pile  = ();
64my $depth = 0;
65open (rob_f,$rob) or die "could not open $rob : $!\n";
66
67print "[ time     ] ","depth"," ","address "," ","function\n";
68
69while (<rob_f>) 
70{
71    if (/(\d+) inst OK - \@([0-9a-f]{8})/) 
72    {
73        my $addr        = hex $2;
74        my $time        = sprintf "%-8d",$1;
75        my $print_addr  = sprintf "%-8x",$addr;
76
77        if (exists $calls{$addr}) 
78        { 
79            my $print_depth = sprintf "%-5d",$depth;
80            $depth = $depth + 1;
81
82            #print "[ $time ] ",$print_depth," ",$print_addr," ",$TAB1x@pile,"[1;32m$calls{$addr}[0m\n";
83            print "[ $time ] ",$print_depth," ",$print_addr," ",$TAB1 x(@pile-1),$TAB2,"  $calls{$addr}\n";
84            push(@pile,$addr);
85        }
86
87        while (@pile and ($addr < $pile[-1] or $addr >= $end{$pile[-1]})) 
88        {
89            $depth = $depth - 1;
90            my $print_depth = sprintf "%-5d",$depth;
91
92            my $end=pop(@pile);
93            #print "[ $time ] ",$print_depth," ","        "," ",$TAB2x@pile,"[0;31m$calls{$end}[0m\n";
94            print "[ $time ] ",$print_depth," ","        "," ",$TAB1 x@pile,"  $calls{$end}\n";
95        }
96    }
97}
98close rob_f;
Note: See TracBrowser for help on using the repository browser.