Intel HEX Script  Go To Script Pool

# converts Intel HEX to $readmemh format (Contributed by Bill Elliott)

$mem_words = 2048;
$verbose_parse = 0;
@no_entry = ();
$#no_entry = $mem_words;

@mem_data = ();
$#mem_data = $mem_words;

for ($i=0; $i < $mem_words; $i++) {
@no_entry[$i] = 1;
}

while (<>) {
chop;
if (/^:/) {
@char_array = ();
@char_array = split(//,$_);
$array_len = @char_array;
if ($verbose_parse == 1)
{ printf("Line len %d\n",$array_len); } # length of the array
$num_words = hex(join('',@char_array[1],@char_array[2]))/2;
if ($verbose_parse == 1)
{ printf("Num words this line: %d\n", $num_words); }
if ($num_words == 0) {
$fill_value = hex(join('', @char_array[$array_len-2,$array_len-1]));
if ($verbose_parse == 1)
{ printf("fill value is %d\n", $fill_value); }
}
$start_addr = hex(join('',@char_array[3,4,5,6]))/2;
if ($verbose_parse == 1)
{ printf("Starting addr this line: %d\n", $start_addr); }
if (($num_words*2) > ($array_len-11)) {
die "Format error: not enough data";
}
$aix = 9;
for ($i=0; $i < $num_words; $i++) {
$data_val = hex(join('',@char_array[$aix+2,$aix+3,$aix,$aix+1]));
@mem_data[$start_addr] = $data_val;
@no_entry[$start_addr] = 0;
$aix += 4;
$start_addr++;
}
}
else {
die "File format problems";
}
}

for ($i=0; $i < $mem_words; $i++) {
if (@no_entry[$i]) { $out_val = $fill_value + ($fill_value << 8); }
else { $out_val = @mem_data[$i]; }
$out_val &= 0xfff;
printf("@%03X %03X\n",$i, $out_val);
}
 

Other Scripts:

Batch Simulation
Compare Files
Convert
Def2Verilog
Gen XOR Tree
GetValue
IHEX2VHEX
nand tree
Name Instance
OnesCompSum
Preprocessor
Verilog Tag

Verilog Tag2
Verilog2DEF
VHDL2HTML
VRename
XNF2VHDL

 

 

Products:

Undertow Suite
Undertow
Interactive_tool
Optimizing_tool
VeriPower
Power_tool
Toggle_tool
Express_VCT
Personal_VCT
VBIT«
verilog2vhdl™
vhdl2verilogmkt
Script Pool


 

 Company    Products     News    Assistance     Download     Contact Us    Sales

Veritools, Inc.
459 Hamilton Avenue, Suite 200, Palo Alto, California 94301
(650) 462 - 5590 Main    (650) 462 - 5593 Fax
inquiry@veritools.com

For Web site information please email Webmaster