Arithmetic Logic Unit (ALU)

Slides:



Advertisements
Similar presentations
Quad 2-to-1 and Quad 4-to-1 Multiplexers Discussion D2.4 Example 7.
Advertisements

Arbitrary Waveform Discussion 5.5 Example 34.
Decoders Discussion D9.5 Example 25. Decoders 3-to-8 Decoder decoder38.vhd library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_unsigned.all;
Shifters Discussion D7.1 Example Bit Shifter.
Divider Discussion D7.3 Example 20.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Adder Discussion D6.2 Example 17. s i = c i ^ (a i ^ b i ) c i+1 = a i * b i + c i * (a i ^ b i ) Full Adder (Appendix I)
Top-level VHDL Designs
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
2-to-1 Multiplexer: if Statement Discussion D2.1 Example 4.
Decoders and Encoders Lecture L4.2. Decoders and Encoders Binary Decoders Binary Encoders Priority Encoders.
Introduction to VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T1: Combinational Logic Circuits.
Integer Square Root.
Digilent Spartan 3 Board Lecture L2.2
1 Comparators Discussion D A 1-Bit Comparator The variable Gout is 1 if x > y or if x = y and Gin = 1. The variable Eout is 1 if x = y and Gin =
Structural VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T3: ALU Design.
Introduction to VHDL Multiplexers. Introduction to VHDL VHDL is an acronym for VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.
Arithmetic Logic Unit (ALU) Lecture L7.5 Section 7.5.
Lab 2 4-Bit Adder Digilent Spartan 3 Board Lecture L2.3.
For Multiplication of Signed Numbers
Division Lecture L6.3. Division
4-to-1 Multiplexer: case Statement Discussion D2.3 Example 6.
Logic Design Fundamentals - 2 Lecture L1.2. Logic Design Fundamentals - 2 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
Digilent Spartan 3 Board Discussion D3.3
Decoders and Encoders Sections 3-5, 3-6 Mano & Kime.
Introduction to VHDL Multiplexers Discussion D1.1.
Division Discussion D11.3. Division
Binary-to-BCD Converter
7-Segment Displays VHDL Tutorial R. E. Haskell and D. M. Hanna T4: Xilinx LogiBLOX.
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Arithmetic Logic Unit (ALU) Discussion D4.6. ALU N = negative flag (N=1 if y(n)=0 Z = zero flag (Z = 1 if Y = 0) V = overflow flag C = carry flag.
Binary-to-BCD Converter
4-Bit Binary-to-BCD Converter: case Statement
Shift Registers Discussion D5.2 Example Bit Shift Register qs(3) qs(2) qs(1) qs(0) if rising_edge(CLK) then for i in 0 to 2 loop s(i) := s(i+1);
1 Comparators: Procedures Discussion D9.2 Example 22.
VHDL Examples Subra Ganesan Reference: Professor Haskell’s Notes,
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’.
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
1 Part V: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Binary-to-BCD Converter
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
1 Part I: SYSTEM DESIGN. 2 Packages and Components Functions and Procedures Problem (Design & Implementation) Additional System Designs.
VHDL for Combinational Circuits. VHDL We Know Simple assignment statements –f
ECE 331 – Digital System Design Multiplexers and Demultiplexers (Lecture #13)
2’s Complement 4-Bit Saturator Discussion D2.8 Lab 2.
4-to-1 Multiplexer: Module Instantiation Discussion D2.2 Example 5.
9/9/2006DSD,USIT,GGSIPU1 Concurrent vs Sequential Combinational vs Sequential logic –Combinational logic is that in which the output of the circuit depends.
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Number Representation and Arithmetic Circuits
Lecture 8 Review Combinational Devices –Decoder –Multiplexor (Bhasker p-81) –Shifter –Barrel Shifter (Bhasker p-303)
Multiplier: Functions Discussion D7.2 Example 19.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.
Combinational logic circuit
Describing Combinational Logic Using Processes
Instructor: Tor Aamodt
Comparators Discussion DS-3.1.
Review of Aldec Active HDL Implementing Combinational
Mano and Kime Sections 7-6 – 7-8
Getting Started with Vivado
Binary-to-BCD Converter
VHDL (VHSIC Hardware Description Language)
Concurrent vs Sequential
A Greatest Common Divisor (GCD) Processor
Four Bit Adder Sum A Cin B Cout 10/9/2007 DSD,USIT,GGSIPU.
4-Input Gates VHDL for Loops
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
Digital Logic with VHDL
(Simple Testbenches & Arithmetic Operations)
Presentation transcript:

Arithmetic Logic Unit (ALU) Discussion D7.4 Example 21

ALU nf = negative flag (nf=1 if y(n-1)=1 zf = zero flag (zf = 1 if y = 0) ovf = overflow flag cf = carry flag

alu.vhd -- Example 21: alu library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_unsigned.all; entity alu is port( alusel : in STD_LOGIC_VECTOR(2 downto 0); a : in STD_LOGIC_VECTOR(3 downto 0); b : in STD_LOGIC_VECTOR(3 downto 0); nf : out STD_LOGIC; zf : out STD_LOGIC; cf : out STD_LOGIC; ovf : out STD_LOGIC; y : out STD_LOGIC_VECTOR(3 downto 0) ); end alu;

alu.vhd (cont.) architecture alu of alu is begin process(a,b,alusel) variable temp: STD_LOGIC_VECTOR(4 downto 0); variable yv: STD_LOGIC_VECTOR(3 downto 0); variable cfv, zfv: STD_LOGIC; cf <= '0'; ovf <= '0'; temp := "00000"; zfv := '0';

alu.vhd (cont.) case alusel is when "000" => -- pass yv := a; when "001" => -- a + b temp := ('0' & a) + ('0' & b); yv := temp(3 downto 0); cfv := temp(4); ovf <= yv(3) xor a(3) xor b(3) xor cfv; cf <= cfv;

Overflow Overflow = status(1) = c xor c(N-1) = C xor a(N-1) xor b(N-1) xor yv(N-1); ci ai bi si ci+1 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 ci = ai xor bi xor si

alu.vhd (cont.) when "010" => -- a - b temp := ('0' & a) - ('0' & b); yv := temp(3 downto 0); cfv := temp(4); ovf <= yv(3) xor a(3) xor b(3) xor cfv; cf <= cfv; when "011" => -- b - a temp := ('0' & b) - ('0' & a);

alu.vhd (cont.) when "100" => -- NOT yv := not a; when "101" => -- AND yv := a and b; when "110" => -- OR yv := a or b; when "111" => -- XOR yv := a xor b; when others => yv := a; end case;

alu.vhd (cont.) for i in 0 to 3 loop zfv := zfv or yv(i); -- zfv = '0' if all yv(i) = '0' end loop; y <= yv; zf <= not zfv; nf <= yv(3); end process; end alu;