Testing All-X in RAM
Safety Manual for MPC5777M, Rev. 1.1
NXP Semiconductors  81
6 Testing All-X in RAM
6.1 Candidate address for testing All-X issue
This section describes a Perl script which can be used for finding a candidate address for testing All-X in 
the RAMs. Some examples of usage of the script are provided.
#--- start Perl script ---:
: # -*- perl -*-
eval 'exec perl -w -S $0 ${1+"$@"}'
if 0;
use strict;
my $base = hex($ARGV[0]);
my $num_to_find = ($#ARGV > 0) ? $ARGV[1] : 1;
my $all0_found = 0;
my $all1_found = 0;
my $guesses = 0;
my $addr = $base;
my $ecc;
my $bit_count;
printf "RAM base address = 0x%08x\n", $base;
printf "  All 0s - Addresses with two bits set in the address ECC contribution:\n";
while(($guesses < 131072) && ($all0_found < $num_to_find)) {
$ecc = get_ecc($addr, 0, 0);
$bit_count = count_ones($ecc);
if($bit_count == 2) {
$all0_found++;
printf "    (%d) addr = 0x%08x, addr_ecc = 0x%02x\n", $all0_found, $addr, $ecc;
}
$addr += 8;
$guesses++;
}
printf "\n  All 1s - Addresses with two bits cleared in the address ECC contribution:\n";
$addr = $base;
while(($guesses < 131072) && ($all1_found < $num_to_find)) {
$ecc = get_ecc($addr, 0xffffffff, 0xffffffff);
$bit_count = count_zeroes($ecc);
if($bit_count == 2) {
$all1_found++;
printf "    (%d) addr = 0x%08x, addr_ecc = 0x%02x\n", $all1_found, $addr, $ecc;
}
$addr += 8;
$guesses++;
}
sub count_ones {
my $string = sprintf("%08b", shift);
my $count = 0;
my $i;
for($i=0; $i<8; $i++) {
if(substr($string, $i, 1) eq "1") {
$count++;