Friday, October 19, 2012

Floating Point

Floating point describes a method of representing real numbers in a way that can support a wide range of values. 
Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent
The base for the scaling is normally 2, 10 or 16. 
The typical number that can be represented exactly is of the form: 

Significant digits × base exponent

Examples: 2.3005 × 10 5 , -6.134 × 10 -5 , etc...


In binary form:  ±1.xxxxxxx2 × 2yyyy 
  (where x consist of only 0s and 1s and y consist of any real number)

 To show or insert a number with floating point, you must insert function float or double instead of integer.

Floating Point Standard

  • Floating point is defined by IEEE Standard 754-1985
  • Developed in response to divergence of representation of very large/small numbers
  • Portability issues for scientific code 
  • Now almost universally adopted 
  • Two representations
    • Single precision (32-bit data)
    • Double precision (64-bit data) 
     

 IEEE Floating Point Format

(32 bits) single : 8 bits                                 single : 23 bits
(64 bits)  double : 11 bits                              double : 52bits


x=(-1) s×(1+fraction) × 2 (Exponent - Bias)

where s = Sign binary (0 = postitive, 1 = negative)

For normalized significand,x,  {1.0≤|x|<2.0}


significand = significant digits
  • Always have a leading pre-binary-point 1 bit, so no need to represent its explicity (a.k.a. hidden bit)
  • means: actual bits= (23+1 bits)  single, (52+1 bits) double

 Exponent 

  • represents both postive & negative numbers
  • Bias is added to the actual exponent to get the stored exponent
  • Exponents of -127 (all 0s) and +128 (all 1s) are reserved for special numbers.  
 


Sign
Exponent
Fraction
Bias
Single Precision
1 [31]
8 [30-23]
23 [22-00]
127
Double Precision
1 [63]
11 [62-52]
52 [51-00]
1023
 

Range of Single & Double Precision




Binary
Decimal
Single
± 1  × 2127
1.2 ± 1038
Double
± 1 × 21023
3.4 ± 10308









Thursday, October 18, 2012

Arithmetic Logic Unit (ALU)

PICmicro MCUs contain an 8-bit ALU and an 8-bit working register.
The ALU is a general purpose arithmetic and logical unit.
It performs arithmetic and Boolean functions between the data in the working register and any register file.
 
Figure : Operation of the ALU and working register
 
 
 
 
The ALU is 8-bits wide and is capable of addition, subtraction, shift and logical operations.
Unless otherwise mentioned, arithmetic operations are two's complement in nature.
In two-operand instructions, typically one operand is the working register (W register).
The other operand is a file register or an immediate constant.
In single operand instructions, the operand is either the W register or a file register.
The working register is an 8-bit working register used for ALU operations.
It is not an addressable register.
Depending on the instruction executed, the ALU may affect the values of the Carry (C), Digit
Carry (DC), and Zero (Z) bits in the STATUS register.
The C and DC bits operate as a borrow bit and a digit borrow out bit, respectively, in subtraction.



Wednesday, October 17, 2012

Sum-Of-Products & Product-Of-Sums

A Boolean algebra is the combination of variables and operators. 
Typically, it has one or more inputs to produce an output in the range of 0 or 1. 
The compliment of a variable is shown by a bar over a letter.

 

Comparison


SOP
POS
Steps:  1. Combination of input 
                 values that produces 1s
             2. ANDed the input values
                 together
             3. ORed the values
Steps:  1. Convert input values that 
                produce 0s into equivalent 
                variables
             2. ORed the input values 
                 together
             3. ANDed the values.
Used when more 0s produced in output function
Used when more 1s produced in output function
Expression : F = (A’BC)+(AB’C)+(ABC’)
Expression : F = (A’+B+C)(A+B’+C)
                               (A+B+C’)


Example


INPUTS
OUTPUTS
A
B
F
G
0
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1




Sum-of-product
F = (A’ B) + (A B’)
G = (A B)

Product-of-sum
F = (A + B) (A + B)
C = (A + B)
(A + B) (A + B)