Set Less Than (slt) Function
[Pages:11]Set Less Than (slt) Function
? slt function is defined as: 000 ... 001 if A < B, i.e. if A ? B < 0
A slt B = 000 ... 000 if A B, i.e. if A ? B 0
? Thus, each 1-bit ALU should have an additional input (called "Less"), that will provide results for slt function. This input has value 0 for all but 1-bit ALU for the least significant bit.
? For the least significant bit Less value should be sign of A ? B
g. babic
Presentation F
14
32-bit ALU With 5 Functions
B i n v e r t
O p e r a t i o n C a r r y I n
B in ve rt
1-bit
a
ALU1-ALU30
b
0
1
L e s s
0 1
R e s u l t 2
3
a 0
C a r r y I n
b 0
A L U 0
L e s s
C a rryO u t
a 1
C a r r y I n
b 1
A L U 1
0
L e s s
C a rryO u t
a
1-bit ALU31 the most significant bit b
L e s s
=0
Bin vert
C a r r y O u t O p er ation
C a r r y I n
0
1
R e s u lt
0
+
2
1
Overflo w de tec tio n
3 S e t
Carry Out
O ve rflow
a 2
C a r r y I n
b 2
A L U 2
0
L e s s
C a rryO u t
C a rry In
a 3 1
C a r r y I n
b 3 1
A L U 3 1
0
L e s s
O p era tio n R esult0
R esult1
R esult2
R esult31 S e t
O v e rflo w Carry Out
slt function: Operation = 3 Binvert =1
1
32-bit ALU with 5 Functions and Zero
Binvert
Function
and or add subtract slt
Control lines
Binvert (1 line)
0
Operation (2 lines)
00
0
01
0
10
1
10
1
11
g. babic
Presentation F
Carry Out
32-bit ALU with 6 Functions
A nor B = A and B Binvert
Figure B.5.10 (Top)
Function and or add
subtract slt nor
g. babic
Ainvert 0 0 0 0 0 1
Binvert 0 0 0 1 1 1
Operation 00 01 10 10 11 00
Figure B.5.12 + Carry Out + Binvert
Carry Out
17
2
32-bit ALU Elaboration
? We have (so far) designed an ALU for most (integer) arithmetic and logic functions required by the core MIPS ISA
? 32-bit ALU with 6 functions omits support for:
? shift instructions
? XOR logic instruction
? integer multiply and divide instructions.
? Shift instructions:
? It would be possible to widen 1-bit ALU multiplexer to include 1-bit shift left and/or 1-bit shift right.
? Hardware designers created the circuit called a barrel shifter, which can shift from 1 to 31 bits in less time than it takes to add two 32-bit numbers. Thus, shifting is normally done outside the ALU.
? Integer multiply/divide is also usually done outside the ALU.
? We will next consider integer multiplication
g. babic
Presentation F
18
Multiplication
? Multiplication is more complicated than addition:
? accomplished via shifting and addition
? More time and more area required
? We shall look at 3 hardware design versions based on an elementary school algorithm
? Example of unsigned multiplication:
5-bit multiplicand 5-bit multiplier
100012 = 1710 100112 = 1910
10001
10001
00000
00000
10001 .
1010000112 = 32310
? But, this algorithm is very impractical to implement in hardware
g. babic
Presentation F
19
Reading Assignment: 3.4
3
Multiplication : Improved Algorithm
? The multiplication can be done with intermediate additions.
? The same example:
multiplicand multiplier
intermediate product add since multiplier bit=1 intermediate product shift multiplicand and add since multiplier bit=1 intermediate product shift multiplicand and no addition since multiplier bit=0 shift multiplicand and no addition since multiplier bit=0 shift multiplicand and add multiplier since bit=1
final result
10001 10011 0000000000
10001 0000010001
10001 0000110011
10001 _ 0101000011
g. babic
Presentation F
20
Multiplication Hardware: 1st Version
S t a r t
M ultiplicand
Shift left
64 bits
Multiplier0 = 1
1. Test M u l t i p l i e r 0
Multiplier0 = 0
1a. Add multiplicand to product and place the result in Product register
64-bit ALU
P r o d u c t 64 bits
W rite
Figure 3.5
M ultiplier Shift right
32 bits
Control test
g. babic
Presentation F
2. Shift the Multiplicand register left 1 bit
3. Shift the Multiplier register right 1 bit
No: < 32 repetitions 32nd repetition?
Yes: 32 repetitions D o n e
Figure 3.6
21
4
Multiplication Hardware: 2nd Version
M ultiplicand 32 bits
32-bit A LU
P r o d u c t
Shift rig ht W rite
64 b its
M ultiplier Sh ift rig ht
32 bits
Control test
S t a r t
Multiplier0 = 1
1. Test M u l t i p l i e r 0
Multiplier0 = 0
1a. Add multiplicand to the left half of the product and place the result in the left half of the Product register
2. Shift the Product register right 1 bit 3. Shift the Multiplier register right 1 bit
No: < 32 repetitions 32nd repetition?
Yes: 32 repetitions D o n e
g. babic
Presentation F
22
Multiplication Hardware: 3rd Version
M u ltip lic a n d 3 2 b its
3 2 - b it A L U
P rod uc t
S h ift rig h t W rite
6 4 b its
Figure 3.7
g. babic
S t a r t
Product0 = 1
1. Test P r o d u c t 0
Product0 = 0
1a. Add multiplicand to the left half of the product and place the result in the left half of the Product register
C o n tro l te s t
2. Shift the Product register right 1 bit
No: < 32 repetitions 32nd repetition?
Yes: 32 repetitions D o n e
Presentation F
23
5
Real Numbers
? Representing real numbers
? 3.1415925610 ? 3,155,76010 ? 315.57610 x 104
? Scientific notation:
? Single digit to the left of digital point: ? 3.1557610 x 106
? Normalized scientific notation:
? No leading zeros: 1.010 x 10-9, but not 0.110 x 10-8
? Similar for binary:
? 001011012 = 1.0 x 25 or 1.0 x 2101 ? normalized notation
g. babic
Reading Assignment: 3.6
Presentation F
24
Real Numbers
? Conversion from real binary to real decimal
? 1101.10112 = ? 13.687510 since: 11012 = 23 + 22 + 20 = 1310 and
0.10112 = 2-1 + 2-3 + 2-4 = 0.5 + 0.125 + 0.0625 = 0.687510
? Conversion from real decimal to real binary:
+927.4510 = + 1110011111.01 1100 1100 1100 ..... 927/2 = 463 + LSB 0.45 2 = 0.9 + 0 MSB
463/2 = 231 +
0.9 2 = 0.8 + 1
231/2 = 115 +
0.8 2 = 0.6 + 1
115/2 = 57 +
0.6 2 = 0.2 + 1
57/2 = 28 +
0.2 2 = 0.4 + 0
28/2 = 14 + 0
0.4 2 = 0.8 + 0
14/2 = 7 + 0
0.8 2 = 0.6 + 1
7/2 = 3 +
0.6 2 = 0.2 + 1
3/2 = 1 +
0.2 2 = 0.4 + 0
1/2 = 0 +
0.4 2 = 0.8 + 0 ......
g. babic
Presentation F
25
6
Floating Point Number Formats
? The term floating point number refers to representation of real binary numbers in computers.
? IEEE 754 standard defines standards for floating point representations
? Single precision:
31 30
23 22
0
s
E
Fraction
? Double precision:
63 62
52 51
32
s
E
Fraction
31
0
Fraction
g. babic
Presentation F
26
Converting to Floating Point
1. Normalize binary real number i.e. put it into the normalized form: (-1)s 1.Fraction * 2Exp
-1101.10112 = (-1)1 1.1011011 * 23
+1110011111.011100 = (-1)0 1.110011111011100 * 29
2. Load fields of single or double precision format with values from normalized form, but with the adjustment for E field.
E = Exp + 12710 = Exp + 011111112 for single precision E = Exp + 102310 = Exp + 011111111112 for double precision
? E is called a biased exponent - (-1)s 1.Fraction * 2(Exp-Bias)
g. babic
Presentation F
27
7
Floating Point: Example 1
? Find single and double precision of ?13.687510
Normalized form: (-1)1 1.1011011 23
? single precision: E = 112 + 011111112 = 100000102 |1|10000010|10110110000000000000000|
? double precision E = 112 + 011111111112 = 100000000102 |1|10000000010|10110110000000000000| |00000000000000000000000000000000|
g. babic
Presentation F
28
Floating Point: Example 2
? Find single and double precision of +927.4510
Normalized form: (-1)0 1.110011111011100 * 29 ? single precision
E = 10012 + 011111112 = 100010002 |0|10001000|11001111101110011001100|1100... truncation |0|10001000|11001111101110011001100| rounding |0|10001000|11001111101110011001101|
? double precision E = 10012 + 011111111112 = 10000001000 |0|10000001000|11001111101110011001| |10011001100110011001100110011001|1001100...
truncation |10011001100110011001100110011001| rounding |10011001100110011001100110011010|
g. babic
Presentation F
29
8
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- figurative language meaning is often more than just a
- academic vocabulary with more than one meaning
- commonly confused words then vs than
- the mips info sheet department of computer science
- spelling common words that sound alike
- set less than slt function
- p b a p a and b p a p b a or p b a p a and b p a
- than or then k5 learning
- verilog operators
Related searches
- understanding greater than less than symbols
- greater than less than worksheets
- explain less than and more than symbols
- greater than less than equal to
- greater than less than calculator
- less than greater than equations
- greater than less than worksheets pdf
- greater than or less than meanings
- greater than but less than excel formula
- greater than less than synonyms
- greater than or less than sign
- greater than less than symbols