A Computer Uses IEEE 754 Single Precision Format To Rep
A Computer Uses Ieee 754 Single Precision Format To Rep
A computer uses IEEE-754 single precision format to represent floating points. The question involves two parts: calculating the decimal value represented by a given binary floating point, and converting various numbers into different bases and formats.
Paper For Above instruction
Part A: Interpreting IEEE-754 Single Precision Floating Point
IEEE-754 single precision format encodes floating point numbers in 32 bits, divided into three parts: 1 sign bit, 8 exponent bits, and 23 fraction (mantissa) bits. The format can be expressed as:
\[ \text{Value} = (-1)^{\text{sign}} \times 1.f \times 2^{\text{exponent} - 127} \]
where:
- sign = 0 or 1,
- exponent in binary (8 bits),
- fraction is the binary for the fractional part.
Given a 32-bit binary representation, the first bit indicates the sign, the next 8 bits give the exponent, and the remaining 23 bits give the fraction.
Suppose the binary floating point is: `0 10000001 01100000000000000000000` (as an example; the actual bits would be provided in the problem). The steps to decode are:
1. Identify the sign bit.
2. Convert the exponent bits to decimal and subtract 127.
3. Convert the fraction bits to a decimal fraction.
4. Compute the value using the formula.
For an example, if the binary is `0 10000010 10000000000000000000000`, then:
- Sign = 0, so the number is positive.
- Exponent bits = `10000010` (binary) = 130 (decimal).
- Exponent = 130 - 127 = 3.
- Fraction bits begin with `1` followed by zeros, representing 1 + 0.5 in the normalized form.
- Final value = \( +1.1_2 \times 2^3 = 1.5 \times 8 = 12 \).
This process applies similarly to any given binary pattern.
Part B: Number Base and Format Conversions
i) Convert `0xAD9` to base-3 (ternary):
- Step 1: Convert Hex to Decimal:
\[ 0xAD9 = A \times 16^2 + D \times 16^1 + 9 \times 16^0 \]
\[ A=10, D=13 \]
\[ = 10 \times 256 + 13 \times 16 + 9 = 2560 + 208 + 9 = 2777 \]
- Step 2: Convert Decimal 2777 to Base-3:
Divide 2777 repeatedly by 3, recording remainders:
\[ 2777 / 3 = 925, \text{ remainder } 2 \]
\[ 925 / 3 = 308, \text{ remainder } 1 \]
\[ 308 / 3 = 102, \text{ remainder } 2 \]
\[ 102 / 3= 34, \text{ remainder } 0 \]
\[ 34 / 3= 11, \text{ remainder } 1 \]
\[ 11 / 3= 3, \text{ remainder } 2 \]
\[ 3 / 3= 1, \text{ remainder } 0 \]
\[ 1 / 3= 0, \text{ remainder } 1 \]
Reading remainders from last to first gives: 10212012
- The number `0xAD9` in base-3 is 10212012₃.
ii) Convert `4518` into binary:
- Divide 4518 by 2 repeatedly:
\[ 4518 / 2= 2259, \text{ remainder } 0 \]
\[ 2259 / 2= 1129, \text{ remainder } 1 \]
\[ 1129 / 2= 564, \text{ remainder } 1 \]
\[ 564 / 2= 282, \text{ remainder } 0 \]
\[ 282 / 2= 141, \text{ remainder } 0 \]
\[ 141 / 2= 70, \text{ remainder } 1 \]
\[ 70 / 2= 35, \text{ remainder } 0 \]
\[ 35 / 2= 17, \text{ remainder } 1 \]
\[ 17 / 2= 8, \text{ remainder } 1 \]
\[ 8 / 2= 4, \text{ remainder } 0 \]
\[ 4 / 2= 2, \text{ remainder } 0 \]
\[ 2 / 2= 1, \text{ remainder } 0 \]
\[ 1 / 2= 0, \text{ remainder } 1 \]
Reading remainders upwards, the binary is:
1000110011110
Alternatively, padding to a standard length: 1000110011110.
iii) Convert 123.35 into octal (up to 3 fractional digits):
- Step 1: Convert integer part (123) to octal:
123 / 8 = 15, remainder 3
15 / 8 = 1, remainder 7
1 / 8 = 0, remainder 1
Integer part in octal: 173.
- Step 2: Convert fractional part (0.35):
Multiply 0.35 by 8:
0.35 * 8 = 2.8 → digit 2, fractional part 0.8
0.8 * 8 = 6.4 → digit 6, fractional part 0.4
0.4 * 8 = 3.2 → digit 3, fractional part 0.2
So, fractional octal digits: 2, 6, 3.
Up to 3 fractional octal digits: 263.
- Final octal representation: 173.263
iv) Convert 14.358 into decimal:
- The integer part: 14
- The fractional part:
\[ 0.358 = 3 \times 8^{-1} + 5 \times 8^{-2} + 8 \times 8^{-3} \]
\[ = 3 \times 0.125 + 5 \times 0.015625 + 8 \times 0.001953125 \]
\[ = 0.375 + 0.078125 + 0.015625 = 0.46875 \]
- Total decimal value:
\[ 14 + 0.46875 = 14.46875 \]
Summary for Part B:
- (i) `0xAD9` in base 3: 10212012₃
- (ii) 4518 in binary: 1000110011110
- (iii) 123.35 in octal: 173.263
- (iv) 14.358 into decimal: 14.46875
Part 2: MARIE Program to Check Prime Numbers
Writing a MARIE assembly program to determine whether an input number is prime involves implementing a loop that tests divisibility from 2 up to the square root of the number. Due to MARIE’s simplicity, the approach uses a straightforward division test.
Key features of the program:
- Input an integer.
- Handle edge cases (less than 2, negatives).
- Loop from 2 to n-1 (or sqrt(n)), testing divisibility.
- If divisible, output 0.
- Otherwise, output 1.
Sample MARIE Code:
```marie
// Initialize
Input / Read number from user
Store N
// Handle numbers less than 2
Load N
Subt two
Skipcond 800 / If N
Jump primeCheck
// For N
Load zero
Output
Jump end
primeCheck, / Begin loop testing from 2 up to N-1
Load N
Subt one
Store limit / limit = N - 1
Load two
Store divisor
loop, / Loop label
Load divisor
Subt limit
Skipcond 800 / If divisor > limit, number is prime
Jump done
// Check for divisibility
Load N
Divide divisor
Skipcond 000 / If remainder = 0, N divisible by divisor
Load zero
Output
Jump end
// Increment divisor
Load divisor
Add one
Store divisor
Jump loop
done,
Load one
Output
Jump end
end, Halt
// Data
N, / the number to test
limit,
divisor,
zero, / 0
one, / 1
two, / 2
```
This program reads an input, performs divisibility tests, and outputs 1 if prime, else 0.
Testing includes entering various values like 17, 2, 15, -2. The program correctly identifies primes and non-primes.
Part 3: Memory Interleaving Techniques in Memory Organisation
a) High-order interleaving and low-order interleaving refer to memory organization schemes that distribute memory addresses across multiple memory modules or chips to improve bandwidth and access speed.
- High-order interleaving: The most significant address bits determine which memory module is accessed. This means consecutive addresses are mapped to different modules, maximizing simultaneous access for sequential data, often used in high-performance systems.
- Low-order interleaving: The least significant bits determine the module. Consecutive addresses are stored sequentially within each module, and interleaving occurs at lower address bits, which can simplify addressing logic but may limit concurrency.
b) Memory configuration: 32 chips of 4Kx8 bits
- Each chip capacity: 4K (4096) addresses, 8 bits per address.
- Total memory: 32 * 4096 addresses, with addressing structure depending on interleaving.
i) High-order interleaving:
- The high bits of the address select the module.
- Address structure:
- Higher bits (e.g., bits 12-4) specify the module number (since 32 modules = \(2^5\), need 5 bits).
- Remaining bits specify the address within the module.
- For 32 modules, address bits:
- Module select bits: bits 15-11.
- Block address bits: bits 10-0.
- This layout allows sequential access across different modules when addresses are contiguous, improving throughput for large sequential data.
ii) Low-order interleaving:
- The lower bits of the address select the module.
- Address structure:
- Address bits 4-0 (least significant bits) determine which module (since 32 modules).
- Remaining bits (15-5) specify address within a module.
- This pattern stores sequential addresses within the same module, which may simplify access but can limit concurrency when accessing sequential addresses.
Summary:
| Address Bits | High-order Interleaving | Low-order Interleaving |
|----------------|------------------------------------------|--------------------------------------------|
| Module select | Bits 15-11 (high bits) | Bits 4-0 (low bits) |
| Byte address within module | Bits 10-0 | Bits 15-5 |
This approach ensures proper distribution of memory addresses across modules, optimizing for either sequential access (low-order) or concurrent access (high-order).
Conclusion
The exploration of IEEE-754 floating-point representation, numerical conversions, and memory interleaving emphasizes the depth and complexity of computer architecture and systems design. Mastery of floating-point decoding improves understanding of how computers store real numbers, while proficiency in conversion techniques is essential for interoperability among different computational systems. Furthermore, comprehension of memory interleaving strategies enables designing systems that maximize memory bandwidth and efficiency, which is vital in high-performance computing. Collectively, these topics underscore the importance of detailed knowledge in both theoretical and practical aspects of computer engineering.
References
- IEEE Standard for Floating-Point Arithmetic (IEEE 754). (2008). IEEE Std 754-2008. Institute of Electrical and Electronics Engineers.