User:Megan Yu/Sandbox: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Megan Yu
(Created page with "Arithmetic Logic Unit Arithmetic Logic Unit (ALU) is the component of the CPU circuit which does the arithmetic calculations and Boolean comparisons. The ALU is a fundamental co...")
 
No edit summary
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
Arithmetic Logic Unit
{{AccountNotLive}}
Arithmetic Logic Unit (ALU) is the component of the CPU circuit which does the arithmetic calculations and Boolean comparisons.  The ALU is a fundamental component of a microprocessor and controls basic operations such as maintaining timers to more complex operations of calculation like complex math.
== Arithmetic Logic Unit ==


Arithmetic Logic Unit (ALU) is the component of the [[CPU]] which does the [[arithmetic]] calculations and [[Boolean]] comparisons.  The ALU is a fundamental component of a [[microprocessor]] and controls basic operations such as maintaining timers to more complex operations of calculation like complex math.


Numerical System
{{Image|http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Build/Figs/alu.png|right|250px|Schematic symbol (block diagram) of a 32-bit ALU [NB 2]}}
 
'''Numerical System'''


----
----


The numerical system is the format of representation the ALU uses to represent data.  The system used in the ALU must match the numerical system used in the rest of the microprocessor (i.e. binary, decimal, hexadecimal, etc.).  That is, if an ALU uses binary, then the rest of the microprocessor must also use binary to represent information. Most ALUs use the two’s complement binary number representation, but some older models used one’s complement or sign-magnitude format.   
The numerical system is the format of representation the ALU uses to represent data.  The system used in the ALU must match the numerical system used in the rest of the microprocessor (i.e. [[binary]], [[decimal]], [[hexadecimal]], etc.).  That is, if an ALU uses binary, then the rest of the microprocessor must also use binary to represent information. Most ALUs use the [[two’s complement]] binary number representation, but some older models used [[one’s complement]] or [[sign-magnitude format]].   


The one’s complement or two’s complement system allows the ALU to represent negative numbers.  In ALU’s, a number’s complement is determined by the numerical system used; for example, in two’s complement, the binary number is negated and one is added[NB 4].  By using the complement, the ALU does not need a separate subtraction unit; instead, the ALU adds the negated number to perform subtraction.
The one’s complement or two’s complement system allows the ALU to represent negative numbers.  In ALU’s, a number’s complement is determined by the numerical system used; for example, in two’s complement, the binary number is negated and one is added[NB 4].  By using the complement, the ALU does not need a separate subtraction unit; instead, the ALU adds the negated number to perform subtraction.


Inputs and Outputs
'''Inputs and Outputs'''


----
----


A basic arithmetic logic unit has an adder unit and control inputs.
{{Image|http://www.cse.ohio-state.edu/~teodores/download/teaching/cse675.au08/Cse675.02.F.ALUDesign_part2.pdf|right|250px|An example table of logical commands that can be sent to the ALU}}
The adder unit performs the mathematical and Boolean operations.  The adder can be a half adder, but is usually a full adder.   
 
A basic arithmetic logic unit has an [[adder]] unit and control inputs.
 
The adder unit performs the mathematical and Boolean operations.  The adder can be a [[half adder]], but is usually a [[full adder]].   


A half adder has two inputs and has two outputs.  Two numbers are inputted into a half adder and the sum and the carry bit are outputted. The carry-bit represents overflow and should be connected to a carry-in bit, but the half adder does not have the capacity for a carry-in bit.  Because half adders lack a carry-in bit, half adders cannot be used compositely.   
A half adder has two inputs and has two outputs.  Two numbers are inputted into a half adder and the sum and the carry bit are outputted. The carry-bit represents overflow and should be connected to a carry-in bit, but the half adder does not have the capacity for a carry-in bit.  Because half adders lack a carry-in bit, half adders cannot be used compositely.   


A full adder includes a carry-in bit and a carry-out bit[NB 6]. The carry-in bit can be thought of as the carry over in basic addition (i.e. in 9+2, base ten can carry a maximum value of 9 in each index, so there is overflow in position 100 and one is carried over to the ten’s position, 101).   
A full adder includes a carry-in bit and a carry-out bit[NB 6]. The carry-in bit can be thought of as the carry over in basic addition (i.e. in 9+2, base ten can carry a maximum value of 9 in each index, so there is overflow in position 10<sup>0</sup> and one is carried over to the ten’s position, 10<sup>1</sup>).   


The ALU cannot generate any control commands.  Other components of the CPU create and send commands to the ALU.  The ALU reads these commands into its command inputs. The input instruction comes in the form of bits. The ALU processes these bits and, using logic gates, determines the operation the ALU will perform.
The ALU cannot generate any control commands.  Other components of the CPU create and send commands to the ALU.  The ALU reads these commands into its command inputs. The input instruction comes in the form of bits. The ALU processes these bits and, using logic gates, determines the operation the ALU will perform.
Line 26: Line 32:
The ALU outputs include status bits and the data output.  These outputs can be stored in the CPU’s stack memory.
The ALU outputs include status bits and the data output.  These outputs can be stored in the CPU’s stack memory.


Operations
'''Operations'''


----
----
{{Image|http://library.thinkquest.org/25111/1bitalu.gif|right|250px|An example ALU schematic showing circuit components instead of a block diagram[NB 5]}}


'''Simple Operations'''
'''Simple Operations'''
Most ALUs can perform simple operations such as bitwise logic operations (AND, NOT, OR, XOR), bit-shifting operations, and integer arithmetic operations (addition and subtraction).
 
Most ALUs can perform simple operations such as [[bitwise logic operations]] ([[AND]], [[NOT]], [[OR]], [[XOR]]), bit-shifting operations, and integer arithmetic operations ([[addition]] and [[subtraction]]).
 
A fundamental ALU only reads and writes one bit, but these units can be cascaded to facilitate operations[NB 1].   
A fundamental ALU only reads and writes one bit, but these units can be cascaded to facilitate operations[NB 1].   


'''Complex Operations'''
'''Complex Operations'''
Complex operations can be performed by ALU but require modification of basic ALUs and can be time consuming and expensive to implement.  Processor speed, size, and part complexity are limiting factors.
Complex operations can be performed by ALU but require modification of basic ALUs and can be time consuming and expensive to implement.  Processor speed, size, and part complexity are limiting factors.


Integer multiplication and division can be implemented on ALUs[NB 3].  These operations are variations of addition functions.  Other complex operations can also be implemented. These
Integer [[multiplication]] and [[division]] can be implemented on ALUs[NB 3].  These operations are variations of addition functions.  Other complex operations can also be implemented. These
operations include but are not limited to square roots and cosine.
operations include but are not limited to square roots and cosine.




Related Units
'''Related Units'''


----
----


The floating-point unit (FPU) is performs operations using floating-point numbers.  A floating-point number is any number that requires a decimal point to represent it.  Prior to the invention of FPUs, earlier computers had to use a slow process of integer execution units to perform floating point operations.  Some earlier computer models had a second chip called a math coprocessor that was dedicated to performing floating point calculations.  Most modern computers also include a FPU in addition to an ALU.
The [[floating-point unit]] (FPU) is performs operations using floating-point numbers.  A floating-point number is any number that requires a decimal point to represent it.  Prior to the invention of FPUs, earlier computers had to use a slow process of integer execution units to perform floating point operations.  Some earlier computer models had a second chip called a math coprocessor that was dedicated to performing floating point calculations.  Most modern computers also include a FPU in addition to an ALU.


See Also
'''See Also'''


----
----


• CPU
• CPU
• Control Unit
• Control Unit
• Bitwise logic
• Bitwise logic
• Adder (electronics)
• Adder (electronics)
• Two’s complement
• Two’s complement
• Stacks
• Stacks


Notes
'''Notes'''


----
----


1. A 1-bit ALU can create a more conventional 8-bit ALU, the 1-bit unit needs to be repeated eight times with the Carry-Out linked to the Carry-In of the next ALU each time.
1. A 1-bit ALU can create a more conventional 8-bit ALU, the 1-bit unit needs to be repeated eight times with the Carry-Out linked to the Carry-In of the next ALU each time.
2. The diagram is an example of 32 one-bit ALUs cascaded together.  SRC1 and SRC2 are the data inputs bits for two numbers, C is the control input, ST is the carry out bits, and DST is the output bits.   
2. The diagram is an example of 32 one-bit ALUs cascaded together.  SRC1 and SRC2 are the data inputs bits for two numbers, C is the control input, ST is the carry out bits, and DST is the output bits.   
3. Multiplication and division are accomplished by shifting and addition.
3. Multiplication and division are accomplished by shifting and addition.
4. Two’s complement takes the original positive value and flips the bits (if the value of a bit was 0 it is now 1 and vice versa) and then adds 1 to the new number.  The most significant bit indicates the number’s sign.  For example, 00001111 represents 15 in base two, the signed value of -15 is represented as 11110001.
4. Two’s complement takes the original positive value and flips the bits (if the value of a bit was 0 it is now 1 and vice versa) and then adds 1 to the new number.  The most significant bit indicates the number’s sign.  For example, 00001111 represents 15 in base two, the signed value of -15 is represented as 11110001.
5. The circuit uses basic logic gates (AND, OR, NOT, XOR) to compose three components: 1) a Logical Unit; 2) a Decoder; and 3) a Full Adder.
5. The circuit uses basic logic gates (AND, OR, NOT, XOR) to compose three components: 1) a Logical Unit; 2) a Decoder; and 3) a Full Adder.
6. The carry-in bit is an input while the carry-out bit is an output.  If two one-bit ALUs were cascaded, the carry-out bit from the first one-bit ALU would be connected to the carry-in bit of the second one-bit ALU.
6. The carry-in bit is an input while the carry-out bit is an output.  If two one-bit ALUs were cascaded, the carry-out bit from the first one-bit ALU would be connected to the carry-in bit of the second one-bit ALU.


References
'''References'''


----
----


1. Arithmetic Logic Units (online source)
1. Arithmetic Logic Units (online source)[http://www.experiencefestival.com/arithmetic_logic_unit]
2. Arithmetic Logic Unit (ALU) Design (online source)
 
3. ALU (online source)
2. Arithmetic Logic Unit (ALU) Design (online source)[http://library.thinkquest.org/25111/alu.shtml]
4. 32-bit ALU with 5 Functions (online source)
 
3. ALU (online source)[http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Build/alu.html]
 
4. 32-bit ALU with 5 Functions (online source)[http://www.cse.ohio-state.edu/~teodores/download/teaching/cse675.au08/Cse675.02.F.ALUDesign_part2.pdf]
 
5. Hwang, Enoch (2006). Digital Logic and Microprocessor Design with VHDL. Thomson. ISBN 0-534-46593-5.
5. Hwang, Enoch (2006). Digital Logic and Microprocessor Design with VHDL. Thomson. ISBN 0-534-46593-5.
6. Floating Point Unit (FPU) (online source)
 
{{Image|Example.jpg|right|250px|Image Caption}}
6. Floating Point Unit (FPU) (online source)[http://www.pcguide.com/ref/cpu/arch/int/compFPU-c.html]

Latest revision as of 04:22, 22 November 2023


The account of this former contributor was not re-activated after the server upgrade of March 2022.


Arithmetic Logic Unit

Arithmetic Logic Unit (ALU) is the component of the CPU which does the arithmetic calculations and Boolean comparisons. The ALU is a fundamental component of a microprocessor and controls basic operations such as maintaining timers to more complex operations of calculation like complex math.

File:Http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Build/Figs/alu.png
Schematic symbol (block diagram) of a 32-bit ALU [NB 2]

Numerical System


The numerical system is the format of representation the ALU uses to represent data. The system used in the ALU must match the numerical system used in the rest of the microprocessor (i.e. binary, decimal, hexadecimal, etc.). That is, if an ALU uses binary, then the rest of the microprocessor must also use binary to represent information. Most ALUs use the two’s complement binary number representation, but some older models used one’s complement or sign-magnitude format.

The one’s complement or two’s complement system allows the ALU to represent negative numbers. In ALU’s, a number’s complement is determined by the numerical system used; for example, in two’s complement, the binary number is negated and one is added[NB 4]. By using the complement, the ALU does not need a separate subtraction unit; instead, the ALU adds the negated number to perform subtraction.

Inputs and Outputs


A basic arithmetic logic unit has an adder unit and control inputs.

The adder unit performs the mathematical and Boolean operations. The adder can be a half adder, but is usually a full adder.

A half adder has two inputs and has two outputs. Two numbers are inputted into a half adder and the sum and the carry bit are outputted. The carry-bit represents overflow and should be connected to a carry-in bit, but the half adder does not have the capacity for a carry-in bit. Because half adders lack a carry-in bit, half adders cannot be used compositely.

A full adder includes a carry-in bit and a carry-out bit[NB 6]. The carry-in bit can be thought of as the carry over in basic addition (i.e. in 9+2, base ten can carry a maximum value of 9 in each index, so there is overflow in position 100 and one is carried over to the ten’s position, 101).

The ALU cannot generate any control commands. Other components of the CPU create and send commands to the ALU. The ALU reads these commands into its command inputs. The input instruction comes in the form of bits. The ALU processes these bits and, using logic gates, determines the operation the ALU will perform.

The ALU outputs include status bits and the data output. These outputs can be stored in the CPU’s stack memory.

Operations


File:Http://library.thinkquest.org/25111/1bitalu.gif
An example ALU schematic showing circuit components instead of a block diagram[NB 5]

Simple Operations

Most ALUs can perform simple operations such as bitwise logic operations (AND, NOT, OR, XOR), bit-shifting operations, and integer arithmetic operations (addition and subtraction).

A fundamental ALU only reads and writes one bit, but these units can be cascaded to facilitate operations[NB 1].

Complex Operations

Complex operations can be performed by ALU but require modification of basic ALUs and can be time consuming and expensive to implement. Processor speed, size, and part complexity are limiting factors.

Integer multiplication and division can be implemented on ALUs[NB 3]. These operations are variations of addition functions. Other complex operations can also be implemented. These operations include but are not limited to square roots and cosine.


Related Units


The floating-point unit (FPU) is performs operations using floating-point numbers. A floating-point number is any number that requires a decimal point to represent it. Prior to the invention of FPUs, earlier computers had to use a slow process of integer execution units to perform floating point operations. Some earlier computer models had a second chip called a math coprocessor that was dedicated to performing floating point calculations. Most modern computers also include a FPU in addition to an ALU.

See Also


• CPU

• Control Unit

• Bitwise logic

• Adder (electronics)

• Two’s complement

• Stacks

Notes


1. A 1-bit ALU can create a more conventional 8-bit ALU, the 1-bit unit needs to be repeated eight times with the Carry-Out linked to the Carry-In of the next ALU each time.

2. The diagram is an example of 32 one-bit ALUs cascaded together. SRC1 and SRC2 are the data inputs bits for two numbers, C is the control input, ST is the carry out bits, and DST is the output bits.

3. Multiplication and division are accomplished by shifting and addition.

4. Two’s complement takes the original positive value and flips the bits (if the value of a bit was 0 it is now 1 and vice versa) and then adds 1 to the new number. The most significant bit indicates the number’s sign. For example, 00001111 represents 15 in base two, the signed value of -15 is represented as 11110001.

5. The circuit uses basic logic gates (AND, OR, NOT, XOR) to compose three components: 1) a Logical Unit; 2) a Decoder; and 3) a Full Adder.

6. The carry-in bit is an input while the carry-out bit is an output. If two one-bit ALUs were cascaded, the carry-out bit from the first one-bit ALU would be connected to the carry-in bit of the second one-bit ALU.

References


1. Arithmetic Logic Units (online source)[1]

2. Arithmetic Logic Unit (ALU) Design (online source)[2]

3. ALU (online source)[3]

4. 32-bit ALU with 5 Functions (online source)[4]

5. Hwang, Enoch (2006). Digital Logic and Microprocessor Design with VHDL. Thomson. ISBN 0-534-46593-5.

6. Floating Point Unit (FPU) (online source)[5]