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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_3_beta/] [sw/] [vec2dump.pl] - Blame information for rev 292

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 47 arniml
#!/usr/bin/perl -w
2
#
3
# ############################################################################
4
#
5
# vec2dump.pl
6
#
7
# $Id: vec2dump.pl,v 1.1 2004-04-09 19:16:00 arniml Exp $
8
#
9
# Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
10
#
11
# All rights reserved
12
#
13
#  This program is free software; you can redistribute it and/or modify
14
#  it under the terms of the GNU General Public License as published by
15
#  the Free Software Foundation; either version 2 of the License, or
16
#  (at your option) any later version. See also the file COPYING which
17
#  came with this application.
18
#
19
#  This program is distributed in the hope that it will be useful,
20
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
#  GNU General Public License for more details.
23
#
24
#  You should have received a copy of the GNU General Public License
25
#  along with this program; if not, write to the Free Software
26
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
#
28
# ############################################################################
29
#
30
# Purpose:
31
# ========
32
#
33
# Converts a vector file into the dump format for dump_compare.
34
#
35
# A vector stream is read from STDIN and the resulting dump is written
36
# to STDOUT.
37
#
38
 
39
 
40
use strict;
41
 
42
 
43
sub bin2hex {
44
    my $string = shift;
45
    my ($bit, $hex);
46
 
47
    $hex = 0;
48
    foreach $bit (split(//, $string)) {
49
        $hex <<= 1;
50
        $hex |= $bit;
51
    }
52
 
53
    return(sprintf("%02X", $hex));
54
}
55
 
56
sub hex8 {
57
    my $uint = shift;
58
 
59
    if ($uint =~ /^b(.+)$/) {
60
        return(bin2hex($1));
61
    } else {
62
        return('??');
63
    }
64
}
65
 
66
sub hex16 {
67
    my $uint = shift;
68
 
69
    if ($uint =~ /^b(.+)(........)$/) {
70
        return(bin2hex($1).bin2hex($2));
71
    } else {
72
        return('????');
73
    }
74
}
75
 
76
sub dump_ram {
77
    my $ram = shift;
78
    my $elem;
79
 
80
    foreach $elem (@{$ram}) {
81
        print($elem.' ');
82
    }
83
}
84
 
85
 
86
my (@signals, %index, @vector);
87
my $i;
88
my $value;
89
my $line;
90
my $istrobe;
91
my @ram;
92
 
93
 
94
# initialize RAM
95
for ($i = 0; $i < 256; $i++) {
96
    $ram[$i] = '00';
97
}
98
 
99
 
100
# scan for signal names
101
while (<STDIN>) {
102
    if (/^(\S+):/) {
103
        chomp($_);
104
        @signals = split(/ +/);
105
 
106
        # remove time information
107
        shift(@signals);
108
        last;
109
    }
110
}
111
 
112
# build index
113
for ($i = 0; $i < scalar(@signals); $i++) {
114
    # strip off hierarchical path
115
    $signals[$i] =~ s/.*\.//;
116
    $index{$signals[$i]} = $i;
117
}
118
 
119
$istrobe = 0;
120
# read vectors
121
while (<STDIN>) {
122
    if (/^\d+> /) {
123
        chop($_);
124
        @vector = split(/ +/);
125
 
126
        # remove time information
127
        shift(@vector);
128
 
129
        # process write operation to RAM
130
        if ($vector[$index{'we_tmp'}] eq '1') {
131
            $ram[hex(hex8($vector[$index{'address_tmp[7:0]'}]))] = hex8($vector[$index{'data_tmp[7:0]'}]);
132
        }
133
 
134
        # find falling instruction strobe
135
        if ($istrobe == 0) {
136
            $istrobe = $vector[0];
137
            next;
138
        } else {
139
            $istrobe = $vector[0];
140
            if ($vector[0] == 0) {
141
                # falling edge detected
142
            } else {
143
                next;
144
            }
145
        }
146
 
147
        # process each signal
148
        for ($i = 1; $i < scalar(@vector); $i++) {
149
            $_    = $signals[$i];
150
            $line = '';
151
 
152
          SWITCH: {
153
              if (/^program_counter/) { print(hex16($vector[$i]).' '); last; }
154
              if (/^accumulator/)     { print(hex8($vector[$i]).' ');  last; }
155
              if (/^sp/)              { print(hex8($vector[$i]).' ');  last; }
156
              if (/^psw/)             { print(hex8($vector[$i]).' ');  last; }
157
              if (/^bus/)             { print(hex8($vector[$i]).' ');  last; }
158
              if (/^f1/)              { print($vector[$i].' ');        last; }
159
              if (/^p1/)              { print(hex8($vector[$i]).' ');  last; }
160
              if (/^p2/)              { print(hex8($vector[$i]).' ');  last; }
161
              if (/^mb/)              { print($vector[$i].' ');        last; }
162
              if (/^we_tmp/)          { dump_ram(\@ram);               last; }
163
          }
164
        }
165
        print("\n");
166
    }
167
}

powered by: WebSVN 2.1.0

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