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 15

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

powered by: WebSVN 2.1.0

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