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.

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;
Arithmetic Logic Unit (ALU)
Gray Code Converters Discussion D9.1 Example 16.
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)
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
Decoders and Encoders Lecture L4.2. Decoders and Encoders Binary Decoders Binary Encoders Priority Encoders.
Logic Design Fundamentals - 3 Discussion D3.2. Logic Design Fundamentals - 3 Basic Gates Basic Combinational Circuits Basic Sequential 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 =
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
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.
Lab 2 4-Bit Adder Digilent Spartan 3 Board Lecture L2.3.
For Multiplication of Signed Numbers
Division Lecture L6.3. Division
The FC16 Forth Core Lab 7 Module F4.1. Lab 7 Hex OpcodeNameFunction 0000NOP No operation 0001DUP Duplicate T and push data stack. N
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
7-Segment Displays Digilent Spartan 3 Board Discussion DS-4.2.
Introduction to VHDL Multiplexers Discussion D1.1.
Multiplication and Division Lab 9. Multiplication 13 x = 8Fh 1101 x
Division Discussion D11.3. Division
Binary-to-BCD Converter
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Sequential Multiplication Lecture L6.4. Multiplication 13 x = 8Fh 1101 x
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.
Binary-to-BCD Converter
A.7 Concurrent Assignment Statements Used to assign a value to a signal in an architecture body. Four types of concurrent assignment statements –Simple.
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.
CS/EE 3700 : Fundamentals of Digital System Design
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.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
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
Comparators Discussion DS-3.1.
Mano and Kime Sections 7-6 – 7-8
Getting Started with Vivado
مدار های ترکیبی دیکدر لامپ های هفت قسمتی یکی از دیکدر هایی که اغلب به کار برده می شود،دیکدر 4 به 7 برای تبدیل کد bcd به کد هفت بیتی برای لامپ های seven.
Binary-to-BCD Converter
A Greatest Common Divisor (GCD) Processor
Chapter 5 – Number Representation and Arithmetic Circuits
Fibonacci Sequence Lecture L4.1 Lab 3.
Multiplication Discussion 11.1.
4-Input Gates VHDL for Loops
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
Digital Logic with VHDL
(Simple Testbenches & Arithmetic Operations)
Presentation transcript:

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

-- An ALU library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.std_logic_unsigned.all; entity alu is generic(width:positive); port ( a: in STD_LOGIC_VECTOR (width-1 downto 0); b: in STD_LOGIC_VECTOR (width-1 downto 0); alusel: in STD_LOGIC_VECTOR (2 downto 0); y: out STD_LOGIC_VECTOR (width-1 downto 0); status: out STD_LOGIC_VECTOR (3 downto 0) ); end alu; alu.vhd

architecture alu_arch of alu is begin alu1: process(a,b,alusel) variable AVector: STD_LOGIC_VECTOR (width downto 0); variable BVector: STD_LOGIC_VECTOR (width downto 0); variable yVector: STD_LOGIC_VECTOR (width downto 0); variable Z, C: STD_LOGIC; variable yv: STD_LOGIC_VECTOR (width-1 downto 0); begin AVector := '0' & a; BVector := '0' & b; AVector := '0' & a; status <= "0000"; Z := '0'; C := '0'; alu.vhd (cont.)

case alusel is when "000" =>-- a yv := a; when "001" =>-- a + b yVector := AVector + BVector; yv := yVector(width-1 downto 0); C := yVector(width);-- carry flag status(0) <= C;-- carry flag status(1) <= C xor a(width-1) xor b(width-1) xor yv(width-1); -- overflow alu.vhd (cont.)

Overflow C i A i B i S i C i+1 Overflow = status(1) = C xor C(width-1) = C xor a(width-1) xor b(width-1) xor yv(width-1); C i = A i xor B i xor S i

when "010" =>-- a - b yVector := AVector - BVector; yv := yVector(width-1 downto 0); C := yVector(width);-- carry flag status(0) <= C;-- carry flag status(1) <= C xor a(width-1) xor b(width-1) xor yv(width-1); -- overflow when "011" =>-- b - a yVector := BVector - AVector; yv := yVector(width-1 downto 0); C := yVector(width);-- carry flag status(0) <= C;-- carry flag status(1) <= C xor a(width-1) xor b(width-1) xor yv(width-1); -- overflow alu.vhd (cont.)

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

Z := '0'; for i in 0 to width-1 loop Z := Z or yv(i);-- Z = '0' if all yv(i) = '0' end loop; status(2) <= not Z;-- zero flag status(3) <= yv(width-1);-- negative flag y <= yv; end process alu1; end alu_arch; alu.vhd (cont.)