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

Subversion Repositories or1200_soc

[/] [or1200_soc/] [trunk/] [sw/] [perl/] [bin2readmemh.pl] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 qaztronic
#!/usr/bin/perl
2
#
3
#
4
 
5
use Getopt::Std;
6
 
7
getopt( 'fsdx' );
8
 
9
open( BIN_FILE, $opt_f ) or die "Can't open $opt_f!!!\n";
10
 
11
$memory_address = 0;
12
 
13
if( $opt_s == 32 ) {
14
  while ( read( BIN_FILE, $buf, 4 ) ) {
15
    $out = unpack( "H8", $buf);
16
 
17
    if( $opt_x ) {
18
            print "$out\n";
19
          } else {
20
            printf( "\@%08x\n", $memory_address );
21
            print "$out\n\n";
22
          }
23
 
24
    $memory_address++;
25
  }
26
} elsif( $opt_s == 16 ) {
27
  while ( read( BIN_FILE, $buf, 2 ) ) {
28
    $out = unpack( "H4", $buf);
29
 
30
    if( $opt_x ) {
31
            print "$out\n";
32
          } else {
33
            printf( "\@%08x\n", $memory_address );
34
            print "$out\n\n";
35
    }
36
 
37
    $memory_address++;
38
  }
39
} elsif( $opt_s == 8 ) {
40
  while ( read( BIN_FILE, $buf, 1 ) ) {
41
    $out = unpack( "H2", $buf);
42
 
43
    if( $opt_x ) {
44
            print "$out\n";
45
          } else {
46
            printf( "\@%08x\n", $memory_address );
47
            print "$out\n\n";
48
    }
49
 
50
    $memory_address++;
51
  }
52
} else {
53
    print "ERROR! $opt_s is invalad option for -s\n";
54
}
55
 
56
if( $opt_x ) {
57
        for ( $memory_depth = $opt_d ;$memory_depth > $memory_address; $memory_address++ ) {
58
          print "0\n";
59
        }
60
}
61
 
62
 
63
 
64
# if( $opt_s == 32 ) {
65
#   for ( $memory_depth = $opt_d - 1 ;$memory_depth > $memory_address; $memory_address++ ) {
66
#     
67
#     printf( "\@%08x\n", $memory_address );
68
#     print "0\n\n";
69
#   }
70
# } elsif( $opt_s == 16 ) {
71
#   while ( read( BIN_FILE, $buf, 2 ) ) {
72
#     $out = unpack( "H4", $buf);
73
#     
74
#     printf( "\@%08x\n", $memory_address );
75
#     print "$out\n\n";
76
#     
77
#     $memory_address++;
78
#   }
79
# } elsif( $opt_s == 8 ) {
80
#   while ( read( BIN_FILE, $buf, 1 ) ) {
81
#     $out = unpack( "H2", $buf);
82
#     
83
#     printf( "\@%08x\n", $memory_address );
84
#     print "$out\n\n";
85
#     
86
#     $memory_address++;
87
#   }
88
# } else {
89
#     print "ERROR! $opt_s is invalad option for -s\n";
90
# }
91
 

powered by: WebSVN 2.1.0

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