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 16

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

Line No. Rev Author Line
1 15 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
if( $opt_x ) {
12
  if( $opt_d ) {
13 16 qaztronic
#     print "Creating Xilinx image with memory depth $opt_d.";
14 15 qaztronic
  } else {
15
    die "Memory depth not inputted. Use -d option!!!\n";
16
  }
17 16 qaztronic
}
18 15 qaztronic
 
19
$memory_address = 0;
20
 
21
if( $opt_s == 32 ) {
22
  while ( read( BIN_FILE, $buf, 4 ) ) {
23
    $out = unpack( "H8", $buf);
24
 
25
    if( $opt_x ) {
26
            print "$out\n";
27
          } else {
28
            printf( "\@%08x\n", $memory_address );
29
            print "$out\n\n";
30
          }
31
 
32
    $memory_address++;
33
  }
34
} elsif( $opt_s == 16 ) {
35
  while ( read( BIN_FILE, $buf, 2 ) ) {
36
    $out = unpack( "H4", $buf);
37
 
38
    if( $opt_x ) {
39
            print "$out\n";
40
          } else {
41
            printf( "\@%08x\n", $memory_address );
42
            print "$out\n\n";
43
    }
44
 
45
    $memory_address++;
46
  }
47
} elsif( $opt_s == 8 ) {
48
  while ( read( BIN_FILE, $buf, 1 ) ) {
49
    $out = unpack( "H2", $buf);
50
 
51
    if( $opt_x ) {
52
            print "$out\n";
53
          } else {
54
            printf( "\@%08x\n", $memory_address );
55
            print "$out\n\n";
56
    }
57
 
58
    $memory_address++;
59
  }
60
} else {
61
    print "ERROR! $opt_s is invalad option for -s\n";
62
}
63
 
64
if( $opt_x ) {
65
        for ( $memory_depth = $opt_d ;$memory_depth > $memory_address; $memory_address++ ) {
66
          print "0\n";
67
        }
68
}
69
 
70
 
71
 

powered by: WebSVN 2.1.0

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