Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Phil Carmody <carmody@cpd.ntc.nokia.com>
To: axp-list@redhat.com
Subject: Re: PC164SX system building questions
Date: Thu, 22 Apr 1999 12:33:14 +0100	[thread overview]
Message-ID: <199904221133.MAA28360@mvagusta> (raw)
In-Reply-To: <3.0.6.32.19990421173916.00c6c3d0@pop.mcit.com> (Ralph.Green@wcom.com)

>>>>> "Ralph" == Ralph Green, <Ralph.Green@wcom.com> writes:
Ralph> Isamu,
Ralph>  You are pretty close.
Ralph>    To error correct n bits, you need
Ralph>      (log(any base)  n  / log (same base) 2) + 1


log[base x] (a) / log[base x] (b) == log[base b] a

Typical notation for log[base 2] is log2 or lg 
('log' being base 10, 'ln' being natural (base 'e') logarithm)


Ralph>   To correct 8 bits needs:   (.903 / .301) + 1  or 4 bits
Ralph>   To correct 64 bits needs:   (1.806 / .301) + 1  or 7 bits

Ralph>   Your simm requirements depend on how the chipset decodes and error correct.  If it were to error correct on a byte basis, a 64 bit SIMM would need 8 times 12 bits or 96 bits to do ECC.  If it corrects on a 64 bit word basis, you need 64 + 7 or 71 bits.  Since parity dimms actually provide enough bits to do real single bit error correction on a word basis, that is currently done.
Ralph>  If I assume log means log to the base 2, then your statement is almost true.  Just add 1 more to get the number of needed bits.


Hoorah, someone who's not afraid to put content above presentation!
(i.e. long lines - let the viewer decide when to wrap)


Anyway, some explanation for the +1 in Ralphs formula may be of interest to
those who haven't seen it before. Because it's not always +1...


To be able to correct 1 bit error in a word of for example 4 bits, one
needs to detect the following situations:
a) no error
b) error in bit 0, error in bit 1, error in bit 2, error in bit 3,
c) error in extra error-correcting bit A, error in extra bit B, ....
(numbering/lettering completely arbitrary)
But we as yet don't know how many extra bits we need.

To handle cases (a) and (b) we need enough bits for 1+4 = 5 values, 
i.e. 3 extra bits. ( = [ log2(1+wordwidth) ] rounded up )
Therefore (c) will have 3 cases.
Therefore the total number of cases (1+4+3 = 8) still fits in the 3 bits.

So in this case, it is +1.

However, take a 2 bit word:
(a)+(b) gives 3 case. so 2 extra bits would be our first guess.
but this would give (c) 2 cases, so the total becomes 5 which will not fit
in 2 bits.
So 3 are required
but log2(2) = 1
so +1 doesn't work (is too low) in these pathological cases

The formula is probably more along the lines of

Extra bits required = log2(bitwidth + 1 + log2(bitwidth+1) ) rounded up

This works for these pathological cases <4. (it also works for 0 - erk).

As bitwidth increases, 
log2(bitwidth+1) << bitwidth   (is much less than)
and 
Extra bits = log2(bitwidth + relatively small number) rounded up 
           = log2(bitwidth) + tiny number             rounded up

And Ralphs formula (as mine) holds true.
_Unless_ the relatively small number causes the sum to just pop over a
power of two; thus the log will increase from just less than an integer
to just over an integer; and the rounded value will jump by one.
This will only happen at word widths just less than a power of 2.
(e.g. 7-bit)

Look at the behaviour using the following Perl script. 
(Ralph - you weren't explicit about your rounding, normal interpretation
would indicate that if you need 3.0001 bits, then you actually need 4, but
your formula is more correct (only 36 fails in 256 cases) when rounding
down.)

Anyway it's all academic, as you'll typically only see powers of 2 widths
most of the time.

(Any questions feel free to ask me on or off channel)

Cheerio,
Phil


#!/usr/bin/perl -w

# Note - log() is the natural logarithm in Perl

my $i=1;
while($i<=256)
{
    # OK, this was the formula quoted 
    # (though you don't say how to round)
    my $ralphup = log($i)/log(2) + 1;
    my $ralphdown = int($ralphup);
    if($ralphup > $ralphdown) { $ralphup = $ralphdown+1; }

    # OK, this is my formula
    my $phil = log(1 + $i + (log($i+1)/log(2)))/log(2);
    if($phil> int($phil)) { $phil = int($phil)+1; }


    my $a = 1;
    my $b = log($i)/log(2);
    if($b > int($b)) { $b = int($b) + 1; }

    # uncomment the following line for more verbose output
#    print "$i : Ralph=$ralphdown|$ralphup  Phil=$phil\n";
    my ($oldc,$c) = (0,0);
    do
    { 
        $oldc = $c;
        $c = log($a + $i + $oldc)/log(2);
        if($c > int($c)) { $c = int($c) + 1; }
        # uncomment the following line for more verbose output
#        print("    $a+$i+$oldc bits needs $c extra\n");
    } while($oldc != $c);
    print "$i bits  => $c", 
          ($c!=$ralphdown)?" (Ralph Down $ralphdown)":"",
          ($c!=$ralphup)?" (Ralph Up $ralphup)":"",
          ($c!=$phil)?" (Phil $phil)":"",
          "\n";
    ++$i;
}
    
  


  parent reply	other threads:[~1999-04-22 11:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-21 18:35 PC164SX system building questions Eric Brown
1999-04-21 18:51 ` Eric Dittman
1999-04-21 19:20   ` Chris Price
1999-04-21 19:30     ` Isamu
1999-04-21 22:39       ` Ralph Green, Jr.
1999-04-22  0:12         ` Uncle George
1999-04-22 11:33         ` Phil Carmody [this message]
1999-04-21 19:32     ` Brian Rerecich
1999-04-21 19:41       ` Chris Price
1999-04-21 19:48         ` Brian Rerecich
1999-04-21 20:04           ` Chris Price
1999-04-21 19:28             ` Wes Bauske
1999-04-21 20:35               ` Chris Price
1999-04-21 19:06 ` Jurgen Kramer
1999-04-21 19:09 ` Jeff.Lessem
1999-04-21 23:32 ` Peter Petrakis
1999-04-22  5:06 ` norvierk
1999-04-22  6:49 ` Helge Kreutzmann
1999-04-22  7:04 ` krebs
  -- strict thread matches above, loose matches on Subject: below --
1999-04-21 19:22 Hoover, Tony
1999-04-21 23:49 Marek Dohojda
1999-04-22  0:03 ` Peter Petrakis
1999-04-22  0:20 Marek Dohojda
1999-04-22 14:47 Ken Hansen
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox