analysis
[email protected]
ANALYSIS
1. if there's an LS10 in the code and you are testing the
resolution of the LS10 in your test and failing testcases
based on the resolution, you can rest assured that there
is something wrong with your test, because there is
nothing wrong with the compiler.
2. i have a philosophical problem with testing the accuracy
of the compiler. i don't think we should be doing it.
i just spoke with ken about this, and he agrees that
we only should be testing the resolution of a variable
if it is specially mentioned in the requirement.
we need to be aware of the resolution of a variable
to help us determine its boundary values, but let's
not waste time testing the accuracy of the compiler
by seeing how close to the resolution we can get
to the boundary conditions.
go ahead, live life dangerously: add 1.0+
3. let's remember what we are doing here: we are trying
to get 100% PFD TCA (cover all if-then branches) and
test every PFD requirement listed in the DSS.
if we are spending time doing something that does not
specifically contribute to this goal, i think we
should re-examine it. that includes ANY task.
if you can think of any activity that falls in this
catagory, please let me know immediately!
FLOATS
The following concerns the use of 29050 floating point numbers in
tests. This is not a thorough set of instructions on how to verify or
set floating point numbers. I am only offering some suggestions to
help understand how the 29050 floating point numbers work.
From the AM29050 Microprocessor User's Manual, a floating point
value is defined to be the following:
3 2 2 2 1 1
1 8 4 0 6 2 8 4 0
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
s|< bexp >|<------- frac ------------>|
bit 31: sign bit
bits 23-30: bexp (the exponent of the floating point number)
bits 0-22: frac
The above represents a floating point number using the calculation
fpnumber = (-1)**s * 1.frac * 2**(bexp-127) (from the 29050
User's Manual)
This calculation isn't really all that bad. Some examples:
Given the HEX representation, calculate the decimal:
----------------------------------------------------
example: 16#4780 5a3c#
2#0100 0111 1000 1000 0101 1010 0011 1100#
from the above:
s = 0
bexp = 2#1000 1111#
= 16#8F#
= 143
frac = 2#000 1000 0101 1010 0011 1100#
= 16#085a3c#
= 547388 / 2**23
= 0.065253734
fpnumber = (-1)**s * 1.frac * 2**(bexp-127)
= (-1)**0 * 1.065253734 * 2**(143-127)
= 69812.46875
other examples:
fpnumber sign bit bexp frac
----------------------------------------------
a) 65536 0 143 0
b) 32768 0 142 0
c) 1024 0 136 0
a) fpnumber = (-1)**0 * 1.0000 * 2**(143-127)
= 1 * 1.0000 * 2**16
= 2**16
= 65536
Given the decimal number, calculate the HEX:
-------------------------------------------------------------------
example: fpnumber = 67502.56934
Determine bexp:
bexp is determined by finding the value of 2**x which is less
than or equal to the floating point number from above. This
can be found by truncating the log(base 2) of fpnumber.
bexp is then the resulting number + 127 (see the 29050
user's manual).
x = TRUNC(LOG(base 2) 67502.56934)
= 16
NOTE: You can obtain the same number (16) by dividing fpnumber
by 2 successively until the result is 1.yyyy. The number
of times you divide by 2 is x above.
bexp = 127+16
= 143
= 16#8f#
= 2#1000 1111#
Determine the fractional part:
The fractional part of the floating point number is determined
by dividing fpnumber by 2**x from above.
fractional part = 67502.56934 / 2**16
= 1.030007467
"frac" in the floating point number (see the 29050 user's
manual) is determined by subtracting 1 from the above result.
frac = 0.030007467
"frac" is represented in 23 bits. All of the 23 bits set would
represent a number that is one significant bit less than one.
So, to determine the actual hex representation of "frac", it
is necessary to multiply the result by 2**23 bits.
frac = 0.030007467 * 2**23
= 251720.8777
since you can't represent a fraction of a bit, round the
result:
frac = 251721
= 16#3d749#
= 2#0011 1101 0111 0100 1001#
The "frac" part of the floating point number is represented by
23 bits in memory. The above number only contains 20 bits. We
must add some extra bits to to front of the number in order to get
the 23 bit "frac" part of the floating point number:
frac = 2# 000 0011 1101 0111 0100 1001#
Now we need to represent the entire floating point number. From
before, we have "bexp" and "frac". Since the floating point
number is positive, "s" = 0. Putting them all together:
"s" = 0
"bexp" = 2#1000 1111#
"frac" = 2#0011 1101 0111 0100 1001#
fp in memory = "s" & "bexp" & "frac"
= 2#0# & 2#1000 1111# & 2#000 0011 1101 0111 0100 1001#
= 2#0100 0111 1000 0011 1101 0111 0100 1001#
= 16#4783 d749#
back