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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [sw/] [utils/] [hex2mif8.pl] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
#!/usr/bin/perl
2
 
3
@data = ();
4
 
5
# Intel HEX format interpreter
6
while(<>) {
7
  if (m/\:([A-F0-9]{2})([A-F0-9]{4})([A-F0-9]{2})([A-F0-9]+)([A-F0-9]{2})/) {
8
    $vec = $4;
9
    $len = hex $1;
10
    $rec_type = $3;
11
    $byte_addr = (hex $2);
12
    if ($len > 0) {
13
      for (my($i)=0; $i < $len*2; $i+=2) {
14
        $data[$byte_addr++] = hex substr($vec, $i, 2);
15
      }
16
    }
17
  }
18
}
19
 
20
use Shell;
21
#Execute a command which parses the System.map file and determines the address
22
#of the boot code, and thus the total size of it that will be loaded from the
23
#SPI flash.
24
$code_size_cmd = "tail -n 1 System.map | sed 's/:.*//g' | sed 's/^[ ]*//'";
25
$code_size = hex(qx{ $code_size_cmd });
26
 
27
#The following doesn't want to play for some reason; unrolling...
28
#for(my($j)=0; $j < 4; $j++){
29
#    $size_bytes[$j] = $code_size & (hex(ff)<<($j*2)) / (hex(1)<<($j*2));
30
#}
31
 
32
$size_bytes[0] = $code_size & hex(ff) / hex(1);
33
$size_bytes[1] = ($code_size & hex(ff00)) / hex(100);
34
$size_bytes[2] = ($code_size & hex(ff0000)) / hex(10000);
35
$size_bytes[3] = ($code_size & hex(ff000000)) / hex(1000000);
36
#printf("//SPI Flash ROM data, byte per line. First word is length of ROM\n");
37
#for(my($j)=0; $j < 4; $j++){
38
#    printf("%2.2x\n",$size_bytes[3-$j]);
39
#}
40
$i =0;
41
print("WIDTH=8;\n");
42
print("DEPTH=".($#data + 1).";\n");
43
print("ADDRESS_RADIX = HEX;\n");
44
print("DATA_RADIX = HEX;\n");
45
print("\n");
46
print("CONTENT BEGIN\n");
47
while($i <= $#data) {
48
    printf ("\t%02x : %2.2x;\n", $i, $data[$i]);
49
    $i+=1;
50
}
51
print("END;\n");

powered by: WebSVN 2.1.0

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