Lab 5: Arithmetic Logic Unit (ALU)

Similar documents
Lab 4: Arithmetic Logic Unit (ALU)

ECEN 468 Advanced Logic Design

Chap 6 - Introduction to HDL (b)

Arithmetic Operators There are two types of operators: binary and unary Binary operators:

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

ECE Digital System Design & Synthesis Exercise 1 - Logic Values, Data Types & Operators - With Answers

Introduction to Digital VLSI Design מבוא לתכנון VLSI ספרתי

9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?

Course Topics - Outline

JAVA OPERATORS GENERAL

Operators in C. Staff Incharge: S.Sasirekha

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Chapter 3: Dataflow Modeling

Computer Architecture and Organization: L04: Micro-operations

Verilog Dataflow Modeling

EE 231 Fall EE 231 Lab 3

Department of Computer Science

Design Using Verilog

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Introduction to the 9S12 Microcontroller

Operators & Expressions

EE 3170 Microcontroller Applications

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

Logic Design: Part 2

Arithmetic Operators. Portability: Printing Numbers

EE 3170 Microcontroller Applications

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

Operators in java Operator operands.

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

Prof. Navrati Saxena TA: Rochak Sachan

Digital Design with FPGAs. By Neeraj Kulkarni

Ryerson Polytechnic University Department of Electrical Engineering COE328 Digital Systems. (2 Weeks) FORMAL REPORT - 30 Marks Due Date: Week 13

Lecture 3 Tao Wang 1

CT 229. Java Syntax 26/09/2006 CT229

Verilog HDL:Digital Design and Modeling. Chapter 4. Expressions

RUBY OPERATORS. Ruby Arithmetic Operators: Ruby Comparison Operators:

Register Transfer and Micro-operations

C expressions. (Reek, Ch. 5) 1 CS 3090: Safety Critical Programming in C

Informatics Ingeniería en Electrónica y Automática Industrial

Lecture #2: Verilog HDL

CS 64 Week 1 Lecture 1. Kyle Dewey

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Unit 3. Operators. School of Science and Technology INTRODUCTION

More Programming Constructs -- Introduction

IT T35 Digital system desigm y - ii /s - iii

MC9S12 Address Space

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Expression and Operator

Unit-2 (Operators) ANAND KR.SRIVASTAVA

ECE 4514 Digital Design II. Spring Lecture 7: Dataflow Modeling

EE 231 Fall EE 231 Lab 3. Decoders and Multiplexers. Figure 1: 7-Segment Display. Memory: where the program is stored.

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

REGISTER TRANSFER LANGUAGE

The Arithmetic Operators

COMP Primitive and Class Types. Yi Hong May 14, 2015

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9


Register Transfer Language and Microoperations (Part 2)

Introduction to Embedded Microcomputer Systems Lecture 6.1

Advanced Computer Architecture-CS501

Digital Design (VIMIAA01) Introduction to the Verilog HDL

To design a 4-bit ALU To experimentally check the operation of the ALU

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

BUILDING BLOCKS OF A BASIC MICROPROCESSOR. Part 1 PowerPoint Format of Lecture 3 of Book

Experiment 7 Arithmetic Circuits Design and Implementation

Introduction to Verilog

For Example: P: LOAD 5 R0. The command given here is used to load a data 5 to the register R0.

Infix to Postfix Conversion

register:a group of binary cells suitable for holding binary information flip-flops + gates

Arithmetic Operations

a, b sum module add32 sum vector bus sum[31:0] sum[0] sum[31]. sum[7:0] sum sum overflow module add32_carry assign

Arithmetic Circuits. Design of Digital Circuits 2014 Srdjan Capkun Frank K. Gürkaynak.

538 Lecture Notes Week 2

Operators. Java operators are classified into three categories:

Verilog Coding Guideline

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Computer Organisation CS303

Lab 3: Standard Combinational Components

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop

Chapter 4 Arithmetic Functions

Digital Design with SystemVerilog

Divide: Paper & Pencil

carry in carry 1101 carry carry

Combinational Logic II

Lec-6-HW-3-ALUarithmetic-SOLN

LAB K Basic Verilog Programming

C/C++ Programming Lecture 7 Name:

ECE 353 Lab 3 (Verilog Design Approach)

COMPUTER ARITHMETIC (Part 1)

VARIABLES & ASSIGNMENTS

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

Arithmetic and Logic Blocks

yamin/

Chapter 4. Operations on Data

Under-Graduate Project Logic Design with Behavioral Models

ISA 563 : Fundamentals of Systems Programming

Transcription:

Lab 5: Arithmetic Logic Unit (ALU) September 29, 2009 Contents 1 Prelab 4 2 Lab 4 3 Supplementary Material 6 3.1 Verilog................................................. 6 3.1.1 Parameters.......................................... 6 3.1.2 Operators........................................... 6 3.1.3 8-bit Adder.......................................... 7 The heart of every computer is an Arithmetic Logic Unit (ALU). This is the part of the computer which performs arithmetic operations on numbers, e.g. addition, subtraction, etc. In this lab you will use the Verilog language to implement an ALU having 10 functions. Use of the case structure will make this job easy. The ALU that you will build (see Figure 1) will perform 10 functions on 8-bit inputs (see Table 1). Please make sure you use the same variable name as the ones used in this lab. Don t make your own. The ALU will generate an 8-bit result (result), a one bit carry (C), and a one bit zero-bit (Z). To select which of the 10 functions to implement you will use ALU CTL as the selection lines. 1

[7 : 0] DATA Z ALU C [7 : 0] ACCA [7 : 0] result [? : 0] ALU CTL Figure 1: ALU block diagram 2

Table 1: ALU Functions ALU CTL Mnemonic Load ADDA SUBA ANDA ORAA COMA INCA LSRA LSLA ASRA Description (load DATA into result) DATA => result C is a don t care (add DATA to ACCA) ACCA +DATA => result C is carry from addition (subtract DATA from ACCA) ACCA DATA => result C is borrow from subtraction (logical AND DATA with ACCA) ACCA&DATA => result C is a don t care (logical OR DATA with ACCA) ACCA DATA => result C is a don t care (complement of ACCA) ACCA => result 1 => C (increment ACCA by 1) ACCA + 1 => result C is a don t care (logical shift right of ACCA) Shift all bits of ACCA one place to the right: 0 => results[7], ACCA[7 : 1] result[6 : 0], ACCA[0] => C (logical shift left of ACCA) Shift all bits of ACCA one place to the left: 0 => results[0], ACCA[6 : 0] result[7 : 1], ACCA[7] => C (Arithmetic shift right of ACCA) Shift all bits of ACCA one place to the right: ACCA[0] => results[7],acca[7 : 1] result[6 : 0],ACCA[0] => C 3

1 Prelab 1. Fill out Table 1. 2. Write a Verilog program to implement the ALU. 2 Lab 1. Design the ALU using Verilog. (Make sure you deal with any unused bit combinations of the ALU CTL lines). 2. Simulate the ALU and test different combinations of DATA and ACCA. 3. Program your ALU code into your CPLD. 4. Create another program that will call your ALU module. In this module read external inputs for ACCA and DATA as well as the ALU CTR. Output your results on two 7-segment displays (Pinout of the MAX II micro board is shown in Figure 2). 4

Figure 2: I/O map of prototyping areas 5

3 Supplementary Material 3.1 Verilog 3.1.1 Parameters Parameters are constants and not variables. parameter num = 8; 3.1.2 Operators?:Construct assign y = sel?a:b; If sel is true, then y is assigned a, else it is assigned b. Concatenations In Verilog it is possible to concatenate bits using { }. {a, b, c, a, b, c} is equivalent to {2{a, b, c}} Comparison Operators assign y = a>b?a:b; assign y to a if a>b and assign it to b otherwise. Table 2 shows a list of comparison operators. for == and! = the result is x, if either operand contains an x or z. Logical Operators Table 3 shows a list of logical operators. Evaluation is performed left to right. x if any of the operands has unknown x bits. Binary Arithmetic Operators Table 4 shows a list of arithmetic operators. 6

Table 2: Comparison Operators > greater than < less than >= greater than or equal to <= less than or equal to == equality === equality including x and z! = inequality! == inequality including x and z Table 3: Logical Operators! logical negation && logical AND logical OR Unary Arithmetic Operators Table 5 shows a list of unary arithmetic operators. Bitwise Operators Table 6 shows a list of bitwise operators. Unary Reduction Operators Table 7 shows a list of unary reduction operators. They produce a single bit result by applying the operator to all of the pits of the operand. Shift Operators Table 8 shows a list of shift operators. Left operand is shifted by the number of bit positions given by the right operand. Zeros are used to fill vacated bit positions. Operator Precedence Rule Table 9 shows a list operator precedence rules. 3.1.3 8-bit Adder Program 1 shows how to implement an 8-bit adder. 7

Table 4: Arithmetic Operators + addition subtraction multiplication / division (truncates any fractional part) % equality Table 5: Unary Arithmetic Operators Change the sign of the operand Table 6: Bitwise Operators Bitwise negation & Bitwise AND Bitwise OR & Bitwise NAND Bitwise OR or Equivalence Table 7: Unary Reduction Operators Bitwise negation & Bitwise AND Bitwise OR & Bitwise NAND Bitwise OR or Equivalence Program 1 An example of an 8-bit adder. wire [7:0] sum, a, b; wire cin,cout; assign {cout,sum} = a+b+cin; Table 8: Shift Operators << left shift >> right shift 8

Table 9: Precedence Rules!, Highest Precedence,/,% +, <<,>> <,<=,>,>= ==,! =,===,! == &, &&? : Lowest Precedence 9