L23 – Arithmetic Logic Units Arithmetic Logic Units (ALU) Modern ALU design ALU is heart of datapath Ref: text Unit 15 9/2/2012 – ECE.
Download ReportTranscript L23 – Arithmetic Logic Units Arithmetic Logic Units (ALU) Modern ALU design ALU is heart of datapath Ref: text Unit 15 9/2/2012 – ECE.
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 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 2 Design of ALUs and Data Paths Objective: Design a General Purpose Data Path such as the datapath found in a typical computer. A Data Path Contains: Registers – general purpose, special purpose Execution Units capable of multiple functions Have completed design of a dual ported register set. Objective: Design ALU and integrate with registers. 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 3 ALU Operations (integer ALU) Add (A+B) Add with Carry (A+B+Cin) Subtract (A-B) Subtract with Borrow (A-B-Cin) [Subract reverse (B-A)] [Subract reverse with Borrow (B-A-Cin)] Negative A (-A) Negative B (-B) Increment A (A+1) Increment B (B+1) Decrement A (A-1) Decrement B (B-1) Logical AND Logical OR Logical XOR 1/8/2012 - L3 Data Path Design Not A Not B A B Multiply Step or Multiply Divide Step or Divide Mask Conditional AND/OR (uses Mask) Shift Zero Copyright 2006 - Joanne DeGroat, ECE, OSU 4 A High Level Design From Hayes textbook on architecture. 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 5 The AMD 2901 Bit Slice ALU 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 6 The Architecture 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 7 Arithmetic Logic Circuits The Brute Force Approach A more modern approach 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 8 Arithmetic Logic Circuits A B The Brute Force Approach Simple and straightfoward AB AB AB A Cout FA Cin Function N to 1 Mux A more modern approach 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 9 Arithmetic Logic Circuits A B The Brute Force Approach AB AB AB A Cout FA Cin Function N to 1 Mux A A more modern approach A Logic Unit Where the logic unit and the adder unit are optimized 1/8/2012 - L3 Data Path Design B S Copyright 2006 - Joanne DeGroat, ECE, OSU B Arithmetic Unit 2 to 1 Mux 10 A Generic Function Unit To Design – multifunction unit for logic operations Desire a generic functional unit that can perform 4-to-1 many functions G0 Mux G1 G2 G3 G (A,B) A B A 4-to-1 mux will perform all basic logic functions of 2 inputs – truth table input on data inputs and function variable go to selects. 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 11 Low level VLSI implementation At the implementation level the CMOS design can be done with transmission gates Very important for VLSI implementation Implementation has a total Of 16 transistors. A A’ B B’ G0 G1 G(A,B G2 G3 Could also use NAND NOR implementation. 1/8/2012 - L3 Data Path Design Copyright 2006 - Joanne DeGroat, ECE, OSU 12 Low level implementation An implementation in pass gates (CMOS) When the control signal is a ‘1’ the value will be transmitted across the T gate Otherwise it is an open switch – i.e. high z 1/8/2012 - L3 Data Path Design A A’ B’ B G0 G1 G(A,B G2 G3 A B A’ B’ G(A,B) AB A+B AxorB 0 0 1 1 G0 0 0 0 0 1 1 0 G1 0 1 1 1 0 0 1 G2 0 1 1 1 1 0 0 G3 1 1 0 Copyright 2006 - Joanne DeGroat, ECE, OSU 13 On FPGAs Can use the direct logic equation R <= (G0 AND NOT S1 AND NOT (G1 AND NOT S1 AND (G2 AND S1 AND NOT (G3 AND S1 AND S0) OR S0) OR S0) OR S0); And synthesize from this equation Create a component for use in designs. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 14 The HDL code LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.all; ENTITY mux4to1 IS PORT (G3,G2,G1,G0,S1,S0 : in std_logic; R : OUT std_logic); END mux4to1; ARCHITECTURE one OF mux4to1 IS BEGIN R <= (G0 AND NOT S1 AND NOT S0) OR (G1 AND NOT S1 AND S0) OR (G2 AND S1 AND NOT S0) OR (G3 AND S1 AND S0); END one; 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 15 And Quartis results Synthesis gives 7 pins 1 LUT RTL viewer results 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 16 Logic functions summary 0000 1000 1110 0110 1001 0111 0001 1100 0011 1010 0101 1111 9/2/2012 – ECE 3561 Lect 9 zero AND OR XOR XNOR NAND NOR NOT A A NOT B B one Copyright 2012 - Joanne DeGroat, ECE, OSU 17 Now - the arithmetic unit Typically integer add/subtract 2’s complement Can be simple – A ripple carry adder Could also be a carry lookahead Start with a simple ripple carry adder 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 18 Do component based design Full adder Sum = a XOR b XOR c Carry = ab + ac + bc Create the HDL code and synthesize 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 19 The HDL code – full adder LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.all; ENTITY full_add IS PORT (A,B,Cin : IN std_logic; Sum,Cout : OUT std_logic); END full_add; ARCHITECTURE one OF full_add IS BEGIN Sum <= A XOR B XOR Cin; Cout <= (A AND B) OR (A AND Cin) OR (B AND Cin); END one; 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 20 A multi-bit adder - structural LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.all; ENTITY add8 IS PORT (A,B : IN std_logic_vector (7 downto 0); Cin : IN std_logic; Cout : OUT std_logic; Sum : OUT std_logic_vector (7 downto 0)); END add8; ARCHITECTURE one OF add8 IS COMPONENT full_add IS PORT (A,B,Cin : IN std_logic; Sum,Cout : OUT std_logic); END COMPONENT; FOR all : full_add USE ENTITY work.full_add(one); SIGNAL ic : std_logic_vector (6 downto 0); BEGIN a0 : full_add PORT MAP (A(0),B(0),Cin,Sum(0),ic(0)); a1 : full_add PORT MAP (A(1),B(1),ic(0),Sum(1),ic(1)); a2 : full_add PORT MAP (A(2),B(2),ic(1),Sum(2),ic(2)); a3 : full_add PORT MAP (A(3),B(3),ic(2),Sum(3),ic(3)); a4 : full_add PORT MAP (A(4),B(4),ic(3),Sum(4),ic(4)); a5 : full_add PORT MAP (A(5),B(5),ic(4),Sum(5),ic(5)); a6 : full_add PORT MAP (A(6),B(6),ic(5),Sum(6),ic(6)); a7 : full_add PORT MAP (A(7),B(7),ic(6),Sum(7),Cout); END one; 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 21 Synthesis results Synthesis gives 26 pins – (a, b, sum, cin, cout) 13 combinational LUTs 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 22 A second architecture LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.all; ENTITY add8a2 IS PORT (A,B : IN std_logic_vector (7 downto 0); Cin : IN std_logic; Cout : OUT std_logic; Sum : OUT std_logic_vector (7 downto 0)); END add8a2; ARCHITECTURE one OF add8a2 IS SIGNAL ic : std_logic_vector (8 downto 0); BEGIN ic(0) <= Cin; Sum <= A XOR B XOR ic(7 downto 0); ic(8 downto 1) <= (A AND B) OR (A AND ic(7 downto 0)) OR (B AND ic(7 downto 0)); Cout <= ic(8); END one; 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 23 The results now Resources -26 pins -12 LUTs This is a carry lookahead implementation 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 24 Lecture summary The adder was a simple ripple carry adder. Other Architectures Carry Lookahead Carry select Carry multiplexed 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU 25