Lecture # 12 University of Tehran

Slides:



Advertisements
Similar presentations
Kuliah Rangkaian Digital Kuliah 7: Unit Aritmatika
Advertisements

Modular Combinational Logic
Combinational Circuits
Combinational Logic with Verilog Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer.
Introduction So far, we have studied the basic skills of designing combinational and sequential logic using schematic and Verilog-HDL Now, we are going.
Chapter 4 -- Modular Combinational Logic. Decoders.
Combinational Circuits. Analysis Diagram Designing Combinational Circuits In general we have to do following steps: 1. Problem description 2. Input/output.
Comparator.
Lab 10 : Arithmetic Systems : Adder System Layout: Slide #2 Slide #3 Slide #4 Slide #5 Arithmetic Overflow: 2’s Complement Conversions: 8 Bit Adder/Subtractor.
Parallel Adder Recap To add two n-bit numbers together, n full-adders should be cascaded. Each full-adder represents a column in the long addition. The.
ECE 331 – Digital System Design
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Lecture 8 Arithmetic Logic Circuits
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
Building Adders & Sub tractors Dr Ahmed Telba. Introducing adder circuits Adder circuits are essential inside microprocessors as part of the ALU, or arithmetic.
CS 105 Digital Logic Design
Digital Logic Design Lecture # 7 University of Tehran.
Outline Analysis of Combinational Circuits Signed Number Arithmetic
+ CS 325: CS Hardware and Software Organization and Architecture Combinational Circuits 1.
CS1Q Computer Systems Lecture 9 Simon Gay. Lecture 9CS1Q Computer Systems - Simon Gay2 Addition We want to be able to do arithmetic on computers and therefore.
Digital Logic Design Lecture # 3 University of Tehran.
Digital Arithmetic and Arithmetic Circuits
Copyright 1995 by Coherence LTD., all rights reserved (Revised: Oct 97 by Rafi Lohev, Oct 99 by Yair Wiseman, Sep 04 Oren Kapah) IBM י ב מ 10-1 The ALU.
Fall 2004EE 3563 Digital Systems Design EE 3563 Comparators  Comparators determine if two binary inputs are equal  Some will signal greater than/less.
Chapter # 5: Arithmetic Circuits
Chapter 6-1 ALU, Adder and Subtractor
ECE 3110: Introduction to Digital Systems Chapter 6 Combinational Logic Design Practices Adders, subtractors, ALUs.
Lecture # 11 University of Tehran
HCL and ALU תרגול 10. Overview of Logic Design Fundamental Hardware Requirements – Communication: How to get values from one place to another – Computation.
Digital Logic Design Lecture # 9 University of Tehran.
Lecture 9 Topics: –Combinational circuits Basic concepts Examples of typical combinational circuits –Half-adder –Full-adder –Ripple-Carry adder –Decoder.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Lecture 18: Hardware for Arithmetic Today’s topic –Intro to Boolean functions (Continued) –Designing an ALU 1.
Half Adder & Full Adder Patrick Marshall. Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow.
Sep 29, 2004Subtraction (lvk)1 Negative Numbers and Subtraction The adders we designed can add only non-negative numbers – If we can represent negative.
IT253: Computer Organization
Outline MSI Parts as a Decoder Multiplexer Three State Buffer MSI Parts as a Multiplexer Realization of Switching Functions Using Multiplexers.
COMP541 Arithmetic Circuits
Computer Architecture Lecture 16 Fasih ur Rehman.
Logic Design CS221 1 st Term combinational circuits Cairo University Faculty of Computers and Information.
CHAPTER 2 Digital Combinational Logic/Arithmetic Circuits
Verilog hdl – II.
1 Fundamentals of Computer Science Combinational Circuits.
Digital Logic Design Lecture # 15 University of Tehran.
Digital Logic Design Lecture # 6 University of Tehran.
Lecture # 10 University of Tehran
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
Simple ALU  Half adder  Full adder  Constructing 4 bits adder  ALU does several operations  General ALU structure  Timing diagram of adder  Overflow.
President UniversityErwin SitompulDigital Systems 7/1 Lecture 7 Digital Systems Dr.-Ing. Erwin Sitompul President University
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
1 Arithmetic Building Blocks Today: Signed ArithmeticFirst Hour: Signed Arithmetic –Section 5.1 of Katz’s Textbook –In-class Activity #1 Second Hour: Adder.
Combinational Circuits
Negative Numbers and Subtraction
Lecture 2 Supplement Verilog-01
Digital Systems Section 8 Multiplexers. Digital Systems Section 8 Multiplexers.
Combinatorial Logic Design Practices
Topic 3b Computer Arithmetic: ALU Design
Introduction to Verilog
Arithmetic Circuits (Part I) Randy H
Subtraction The arithmetic we did so far was limited to unsigned (positive) integers. Today we’ll consider negative numbers and subtraction. The main problem.
Topic 3b Computer Arithmetic: ALU Design
Digital Systems Section 12 Binary Adders. Digital Systems Section 12 Binary Adders.
COMS 361 Computer Organization
ECE 352 Digital System Fundamentals
Supplement on Verilog adder examples
Combinational Circuits
Presentation transcript:

Lecture # 12 University of Tehran Digital Logic Design Lecture # 12 University of Tehran

Outline Adders Subtractor Designing Example Hard wares Using the Standard Packages ALU (Arithmetic Logic Unit) Verilog

Adders Consider the following addition process: Observing this addition as a slice by slice process, we could realize the whole process by realizing one of the slices in hardware, that is by designing a hardware that would add two bits and the carry from the last slice and generate a sum and a carry out. As we saw in the last sessions, this logic would give:

Adders (continued…) And the logic diagram of our design was:

Adders (continued…) As mentioned in the last session if we want to do a 4 bit addition we could simply use four full adders next to each other creating a ripple carry adder:

Adders (continued…) We could use a half adder for the addition of the rightmost bit because this stage’s carry in as always 0. But the fact that using a half adder instead of a full adder for the first bit stage will not give us a considerable amount of extra space must be taken into consideration.

Adders (continued…) Looking at our design it is rather obvious that this design could result in a very big delay time if used for a large number of bits. For instance if each and/or gate had a delay of 5ns this would result in a 40ns delay in a 4 bit ripple carry adder. To solve the above problem, we need a design where each cell can predict its own carry and with a timing overhead for this prediction, our result could be ready in 15ns. This design is named carry look ahead.

Adders (continued…) Another very simple method that can help in increasing speed of our addition and decreasing delay times is to make each cell a little more complex and do the addition 2 bits by 2 bits. In such a case because we still are using 2 level networks the delay on each cell will still be 10ns. We can’t use this method for larger cells than 2 bits at a time because the size of the hardware would make it impractical.

Adders (continued…) 74283: This adder does addition using the carry look ahead method but this isn’t the case when cascading these packages.

Subtractor As we saw before, one of the features of the 2’s complement system was that the addition and subtraction processes were very much the same. We can perform subtraction by simply inverting the bits of one operand and setting the carry in bit of the operation to 1.

Subtractor (continued…) In order to be able to use one package for both addition and subtraction, we can use XOR gates as controllable inverters. These packages have the following structure:

Subtractor (continued…) Let’s now design a structure that can give us the and result of the two inputs or the add/sub result based on a select line.

Subtractor (continued…) As you can see in the last example, four 2-to-1 multiplexers with a common select are used to give us the needed result based on the value of the select line.

Designing Example Hard wares Using the Standard Packages Let’s use the packages we’ve seen so far to design a hardware that converts a 2’s complement number to its equivalent sign and magnitude form. This means that a conversion will take place whenever the MSB is 1 that in when our number is negative (positive numbers need no conversion).

ALU (Arithmetic Logic Unit) An ALU is a component that can do both arithmetic and logic operations on its inputs. It can also have a comparator inside that gives outputs such as overflow flag, zero flag etc as well as its operation results. Note: The adders inside an ALU are usually carry look ahead adders and in order to be able to cascade adders and keep this feature in them, they have outputs that can help in prediction of the next stages carry in bits. These outputs are usually called ‘p’ and ‘g’.

ALU (Arithmetic Logic Unit) (continued…) 74181: In this package, four select lines choose the function performed by the ALU, as shown in the following table. This ALU has ‘g’ and ‘p’ outputs that keeps addition carry look ahead even after cascading.

Verilog Consider the following Verilog code: module max(a, b, z); input [3:0] a, b; output [3:0] z; assign z=(a>b)?a:b; endmodule This kind of description is called data flow description that can be given to a synthesis tool which will give us a hadware realization for it.

Verilog (continued…) The following code is the code for an adder subtractor module: module addsub(a, b, select, cout, sum); input [7:0] a, b; input select; output [7:0] sum; output cout; assign {cout, sum}=select?(a-b):(a+b); endmodule

Verilog (continued…) An adder with overflow detection: module adder(a, b, cin, sum, cout, ov); input [7:0] a, b; input cin; output [7:0] sum; output cout, ov; assign {cout, sum}=a+b+cin; assign ov=a[7]&b[7]&~sum[7] | ~a[7]&~b[7]&sum[7]; endmodule

Verilog (continued…) When writing Verilog code for different problems many a time can occur where writing assign statements using condition expressions can become very complex. In such cases ‘always block’ is used. Pay attention to the following example in the next slide.

Verilog (continued…) Example: module ALU(a, b, s, z); input [7:0] a, b; input [1:0] s; output [7:0] z; reg [7:0] z; always @(a, b, s) begin if (s==0) z=a+b; else if(s=1) z=a-b; else if(s=2) z=a&b; else z=a^b; end endmodule

Verilog (continued…) Note: The list of variables given in parentheses in front of ‘always @’ are called the sensitivity list. As we know a combinational circuit changes its output whenever one of its inputs change, that is the inputs to that circuit are its sensitivity list. This syntax is different for sequential circuits as we will see later on.

Verilog (continued…) An important issue that must be noted here is that when describing a circuit for synthesis (as the examples we saw today) we do not use any timings in our code. This is because the software is going to use certain hardware for the design and thus we are not in a situation to be able to issue any delay times. We use Verilog for two main reasons: Synthesis Modeling for simulation

Verilog (continued…) When using Verilog for synthesis we do not issue delay times (that is it is ignored even if we do). But when modeling for simulation or when we’re using particular packages we know about, we must issue delay times in order for the simulation wave forms to be something near to results we will get in reality.