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

Subversion Repositories or1200_soc

[/] [or1200_soc/] [trunk/] [sw/] [perl/] [bin2readmemh.pl] - Diff between revs 16 and 22

Only display areas with differences | Details | Blame | View Log

Rev 16 Rev 22
#!/usr/bin/perl
#!/usr/bin/perl
#
#
#
#
 
 
use Getopt::Std;
use Getopt::Std;
 
 
getopt( 'fsdx' );
getopt( 'fsdx' );
 
 
open( BIN_FILE, $opt_f ) or die "Can't open $opt_f!!!\n";
open( BIN_FILE, $opt_f ) or die "Can't open $opt_f!!!\n";
 
 
if( $opt_x ) {
if( $opt_x ) {
  if( $opt_d ) {
  if( $opt_d ) {
#     print "Creating Xilinx image with memory depth $opt_d.";
#     print "Creating Xilinx image with memory depth $opt_d.";
  } else {
  } else {
    die "Memory depth not inputted. Use -d option!!!\n";
    die "Memory depth not inputted. Use -d option!!!\n";
  }
  }
}
}
 
 
$memory_address = 0;
$memory_address = 0;
 
 
if( $opt_s == 32 ) {
if( $opt_s == 32 ) {
  while ( read( BIN_FILE, $buf, 4 ) ) {
  while ( read( BIN_FILE, $buf, 4 ) ) {
    $out = unpack( "H8", $buf);
    $out = unpack( "H8", $buf);
 
 
    if( $opt_x ) {
    if( $opt_x ) {
            print "$out\n";
            print "$out\n";
          } else {
          } else {
            printf( "\@%08x\n", $memory_address );
            printf( "\@%08x\n", $memory_address );
            print "$out\n\n";
            print "$out\n\n";
          }
          }
 
 
    $memory_address++;
    $memory_address++;
  }
  }
} elsif( $opt_s == 16 ) {
} elsif( $opt_s == 16 ) {
  while ( read( BIN_FILE, $buf, 2 ) ) {
  while ( read( BIN_FILE, $buf, 2 ) ) {
    $out = unpack( "H4", $buf);
    $out = unpack( "H4", $buf);
 
 
    if( $opt_x ) {
    if( $opt_x ) {
            print "$out\n";
            print "$out\n";
          } else {
          } else {
            printf( "\@%08x\n", $memory_address );
            printf( "\@%08x\n", $memory_address );
            print "$out\n\n";
            print "$out\n\n";
    }
    }
 
 
    $memory_address++;
    $memory_address++;
  }
  }
} elsif( $opt_s == 8 ) {
} elsif( $opt_s == 8 ) {
  while ( read( BIN_FILE, $buf, 1 ) ) {
  while ( read( BIN_FILE, $buf, 1 ) ) {
    $out = unpack( "H2", $buf);
    $out = unpack( "H2", $buf);
 
 
    if( $opt_x ) {
    if( $opt_x ) {
            print "$out\n";
            print "$out\n";
          } else {
          } else {
            printf( "\@%08x\n", $memory_address );
            printf( "\@%08x\n", $memory_address );
            print "$out\n\n";
            print "$out\n\n";
    }
    }
 
 
    $memory_address++;
    $memory_address++;
  }
  }
} else {
} else {
    print "ERROR! $opt_s is invalad option for -s\n";
    print "ERROR! $opt_s is invalad option for -s\n";
}
}
 
 
if( $opt_x ) {
if( $opt_x ) {
        for ( $memory_depth = $opt_d ;$memory_depth > $memory_address; $memory_address++ ) {
        for ( $memory_depth = $opt_d ;$memory_depth > $memory_address; $memory_address++ ) {
          print "0\n";
          print "0\n";
        }
        }
}
}
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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