1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.

Slides:



Advertisements
Similar presentations
L23 – Adder Architectures. Adders  Carry Lookahead adder  Carry select adder (staged)  Carry Multiplexed Adder  Ref: text Unit 15 9/2/2012 – ECE 3561.
Advertisements

Kuliah Rangkaian Digital Kuliah 7: Unit Aritmatika
LECTURE 4: The VHDL N-bit Adder
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6.
ECE 331 – Digital System Design
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Lecture 8 Arithmetic Logic Circuits
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448.
ECE 331 – Digital System Design
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
CSET 4650 Field Programmable Logic Devices Dan Solarek VHDL Behavioral & Structural.
L23 – Arithmetic Logic Units. Arithmetic Logic Units (ALU)  Modern ALU design  ALU is heart of datapath  Ref: text Unit 15 9/2/2012 – ECE 3561 Lect.
AND Gate: A Logic circuit whose output is logic ‘1’ if and only if all of its inputs are logic ‘1’.
George Mason University Modeling of Arithmetic Circuits ECE 545 Lecture 7.
Digital Arithmetic and Arithmetic Circuits
VHDL TUTORIAL Preetha Thulasiraman ECE 223 Winter 2007.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
ENG241 Digital Design Week #4 Combinational Logic Design.
L26 – Datapath ALU implementation
Reconfigurable Computing - VHDL John Morris Chung-Ang University The University of Auckland.
CWRU EECS 317 EECS 317 Computer Design LECTURE 1: The VHDL Adder Instructor: Francis G. Wolff Case Western Reserve University.
Basic Overview of VHDL Matthew Murach Slides Available at:
1 ECE 545 – Introduction to VHDL Dataflow Modeling of Combinational Logic Simple Testbenches ECE 656. Lecture 2.
Reconfigurable Computing - VHDL John Morris Computer Science/ Electrical and Computer Engineering The University of Auckland Iolanthe racing off Fremantle,
HARDWARE DESCRIPTION LANGUAGE (HDL). What is HDL? A type of programming language for sampling and modeling of electronic & logic circuit designs It can.
ECE 331 – Digital System Design Multiplexers and Demultiplexers (Lecture #13)
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
CEC 220 Digital Circuit Design More VHDL Fri, February 27 CEC 220 Digital Circuit Design Slide 1 of 15.
Digital System Projects
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VHDL Coding for Synthesis ECE 448 Lecture 12.
Addition, Subtraction, Logic Operations and ALU Design
CEC 220 Digital Circuit Design
Number Representation and Arithmetic Circuits
President UniversityErwin SitompulDigital Systems 7/1 Lecture 7 Digital Systems Dr.-Ing. Erwin Sitompul President University
Explain Half Adder and Full Adder with Truth Table.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
An Introduction to V.H.D.L.. Need of a Compiler… main( ) { int x=10,y=20,z; z = x + y ; printf ( “ %d “, z ); getch( ) ; } What’s That ? Give me only.
REGISTER TRANSFER AND MICROOPERATIONS
Combinational logic circuit
Combinational Circuits
Basic Language Concepts
REGISTER TRANSFER AND MICROOPERATIONS
ENG2410 Digital Design “Combinational Logic Design”
Chap 7. Register Transfers and Datapaths
Instructor: Tor Aamodt
ENG6530 Reconfigurable Computing Systems
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
ECE/CS 552: Arithmetic and Logic
ECE 331 – Digital System Design
HDL Programming Fundamentals
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
CSE Winter 2001 – Arithmetic Unit - 1
VHDL VHSIC Hardware Description Language VHSIC
Arithmetic Circuits (Part I) Randy H
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
VHDL (VHSIC Hardware Description Language)
Chapter 5 – Number Representation and Arithmetic Circuits
By: A. H. Abdul Hafez CAO, by Dr. A.H. Abdul Hafez, CE Dept. HKU
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
Data Flow Description of Combinational-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
Data Flow Description of Combinational-Circuit Building Blocks
Digital Logic with VHDL
Presentation transcript:

1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design

2 Outline Introduction to the ALU Addition Subtraction It’s too much my circuits hurt

3 Introduction to ALU The ALU performs all the data manipulations adding subtracting shifting comparing... It requires a hardware device that accepts multiple data words and a set of commands as input and produces a data word and flag signals as output ALU

4 Possible ALU Structure A high level architecture for an ALU looks like: AB Arithmetic Logic Shift MUX C CC Control command TOPICS: VHDL Arithmetic Logic Shift ALU

5 VHDL Implementation A structural implementation would require a schematic and a data flow implementation would require a set of equations A behavioral implementation would only require the specifications ALU 8 bit data - A, B, C A subset of the possible ALU operations - add, and, xor, shift left, shift right, transfer, increment, decrement

6 ALU Specifications These are the operations of the ALU: ALU S2 S1 S0 Operation C = Atransfer A to C C = A + 1increment A C = A + B add C = A - 1 decrement A C = A and B AND C = A xor B XOR C = A sr1 shift right by C = A sl1 shift left by 1 ALU A B S C CC

7 ALU Entity The entity is a list of the inputs and outputs ALU Entity alu1 is port ( A, B : in std_logic_vector (7 downto 0); S : in std_logic_vector(2 downto 0); C : out std_logic_vector(7 downto 0); CC : out std_logic_vector(3 downto 0)); end alu1; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; To perform arithmetic operations: ALU A B S C CC

8 ALU Architecture One approach to a behavioral model is to use a case statement in a process block ALU A A L L S S.. M M M M C architecture behav of ALU1 is ALU: process (S,A,B) variable Ao : unsigned(7 downto 0); variable Lo, So : std_logic_vector (7 downto 0); begin ALU AB S For arithmetic operations A A.. Ar: case S(2 downto 0) is when “000” => Ao := unsigned(A); when “001” => Ao := unsigned(A) + 1; when “010” => Ao := unsigned(A) + unsigned(B); when “011” => Ao := unsigned(A) - 1; when others => Ao := (others => ‘X’); end case Ar;

9 Architecture (continued) ALU AB S A A.. L L S S Sr: case S(2 downto 0) is when “110” => So := ‘0’ & A(7 downto 1); when “111” => So := A(6 downto 0) &’0’; when others => So := (others =>‘X’); end case Sr; MUXr: if (S(2) = ‘0’) then C <= conv_std_logic_vector(Ao(7 downto 0),8) ; else if (S(1) = ‘0’) then C <= Lo; else C <= So; end if; end if MUXr; end process ALU; end architecture behav; M M M M C Lr: case S(2 downto 0) is when “100” => Lo := A and B; when “101” => Lo := A xor B; when others => Lo := (others =>‘X’); end case Lr; Variable assignment Built in function

10 ALU Run Enter the code in a VHDL complier (take CC out of the entity), compile, and simulate: ALU Sum of (hex) ADD Command Code

11 Hardware ALU Look at the individual operations Addition Subtraction Multiplication Division Logic/Shift Operations Implement each in hardware and MUX the outputs ALU

12 Binary Addition The ALU adds binary numbers bit by bit: ALU addition X Y Hence, a hardware adder must have 3 inputs and 2 outputs: Single Bit Adder xixi yiyi cici sisi c i+1 Carry Sum

13 4-Bit Adder A four bit adder can be constructed from four single bit adders: ALU addition Single Bit Adder x4x4 y4y4 s4s4 Single Bit Adder x3x3 y3y3 s3s3 Single Bit Adder x2x2 y2y2 s2s2 c0c0 Single Bit Adder x1x1 y1y1 s1s1 c4c4 Start with 4 single bit adders Then ripple the carry lines down the structure

14 VHDL Implementation PROCESS PROCESS: Define the full adder as a component and connect four of the components in the architecture ALU addition Entity library ieee; use ieee.std_logic_1164.all; entity four_add is port ( A, B: in std_logic_vector (3 downto 0); Cin : in std_logic; S : out std_logic_vector (3 downto 0); Cout : out std_logic); end four_add;

15 Architecture ALU addition architecture struc of four_add is component full_add port (A, B, Cin : in std_logic; S, Cout : out std_logic); end component; signal C1, C2, C3 : std_logic; begin g1: full_add port map (A(0), B(0), Cin, S(0), C1); g2: full_add port map (A(1), B(1), C1, S(1), C2); g3: full_add port map (A(2), B(2), C2, S(2),C3); g4: full_add port map (A(3), B(3), C3, S(3), Cout); end struc;

16 Speed One problem with our 4-bit adder is that it is slow: ALU addition Single Bit Adder x4x4 y4y4 s4s4 Single Bit Adder x3x3 y3y3 s3s3 Single Bit Adder x2x2 y2y2 s2s2 c0c0 Single Bit Adder x1x1 y1y1 s1s1 c4c4 20 nsec Time 0 20 nsec 40 nsec 60 nsec 80 nsec Carry Lookahead or redundant hardware adders are used to provide faster addition

17 Extended Addition Question: Early microcomputers were only 8 bit machines. How could you add 16 or 32 bit integers? On 16 bit machines how do you add 32 bit integers? Intel solution: ADC dest, source Usage rules are the same as for ADD dest = dest + source + carry flag Example AX = 1000h, BX = 20, CF = 1 ADC AX, BX ; ALU addition

18 Subtraction There are three methods of signed addition based on the representation of negative numbers ALU addition subtraction Sign-Magnitude One’s Complement Two’s Complement

19 Sign-Magnitude Representation: the MSB is a sign bit (0 for +, 1 for -) Example: is +5 and is -3 Addition Rule: If the sign bits are the same, add the magnitudes. If the sign bits are different, subtract the smaller magnitude from the larger and determine the new sign bit ALU addition subtraction

20 One’s Complement Representation: negative numbers are formed by complementing each bit of the positive sign-magnitude representation Example: is + 6 and is - 3 Addition Rule: (see next slide) ALU addition subtraction

21 1’s Complement Subtraction RULE: add bit by bit add the high order carry to the result EXAMPLEs ALU addition subtraction Add the carry 1

22 Two’s Complement Representation: negative numbers are formed by complementing every bit and adding 1 EXAMPLE: is +8 and is -8 Addition Rule: add bit by bit ALU addition subtraction

23 Example Two’s Complement Addition ALU addition subtraction (ignore the carry) Overflow Overflow: if the signs are different ignore the carry out but if the signs are the same and the result has a different sign then an overflow condition exists

24 Extended Subtraction SBB - subtract with borrow SBB destination, source destination = destination - source – CF Usage: just like ADC AX = 1000h, BX = 20, CF = 1 SBB AX, BX ; ALU addition subtraction