Least Common Multiple (LCM)

Similar documents
Finite State Machine with Datapath

Digitaalsüsteemide disain

9 Multiplication and Division

361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division

COMPUTER ARITHMETIC (Part 1)

COMP 303 Computer Architecture Lecture 6

Divide: Paper & Pencil

Organisasi Sistem Komputer

Chapter 5 : Computer Arithmetic

EECS150 - Digital Design Lecture 13 - Combinational Logic & Arithmetic Circuits Part 3

Figure 1: Verilog used to generate divider

CPS 104 Computer Organization and Programming

Rational numbers as decimals and as integer fractions

ECE260: Fundamentals of Computer Engineering

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

EECE-4740/5740 Advanced VHDL and FPGA Design Lecture 4. Cristinel Ababei Dept. of Electrical and Computer Engr. Marquette University

carry in carry 1101 carry carry

More complicated than addition. Let's look at 3 versions based on grade school algorithm (multiplicand) More time and more area

3 Designing Digital Systems with Algorithmic State Machine Charts

EITF35: Introduction to Structured VLSI Design

VHDL: RTL Synthesis Basics. 1 of 59

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Chapter 5: Computer Arithmetic. In this chapter you will learn about:

Learning Objectives. Binary over Decimal. In this chapter you will learn about:

An instruction set processor consist of two important units: Data Processing Unit (DataPath) Program Control Unit

The Need of Datapath or Register Transfer Logic. Number 1 Number 2 Number 3 Number 4. Numbers from 1 to million. Register

Number Systems and Computer Arithmetic

Verilog for High Performance

Tailoring the 32-Bit ALU to MIPS

MCPU - A Minimal 8Bit CPU in a 32 Macrocell CPLD.

Lab Assignment 1. Developing and Using Testbenches

Digital Design (VIMIAA01) Introduction to the Verilog HDL

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

Lecture 8: Addition, Multiplication & Division

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

Chapter 5: Computer Arithmetic

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

Used to perform operations many times. See previous Parallel to Serial Example

Register Transfer Level in Verilog: Part I

COMPUTER ORGANIZATION AND. Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

EITF35 - Introduction to Structured VLSI Design (Fall ) 7. Assignment 3 - Arithmetic Logic Unit (ALU)

HDL Design Cube. Synthesis and VHDL

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Timing for Ripple Carry Adder

Review of Last lecture. Review ALU Design. Designing a Multiplier Shifter Design Review. Booth s algorithm. Today s Outline

TSEA44 - Design for FPGAs

VHDL for Synthesis. Course Description. Course Duration. Goals

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade

Binary Adders. Ripple-Carry Adder

Fast Arithmetic. Philipp Koehn. 19 October 2016

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

Sequential Circuit Design: Principle

ECE 551: Digital System *

Contents. Chapter 9 Datapaths Page 1 of 28

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

RTL Design (Using ASM/SM Chart)

Module 2: Computer Arithmetic

Iterative Division Techniques COMPUTER ARITHMETIC: Lecture Notes # 6. University of Illinois at Chicago

Register Transfer Methodology II

Outline. Register Transfer Methodology II. 1. One shot pulse generator. Refined block diagram of FSMD

Floating Point Arithmetic

Numbering systems. Dr Abu Arqoub

Hardware Description Languages M E 2202 Tutorial Sheet

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26)

Register Transfer and Micro-operations

Inf2C - Computer Systems Lecture Processor Design Single Cycle

ECE 4514 Digital Design II. Spring Lecture 15: FSM-based Control

VHDL And Synthesis Review

University of Illinois at Chicago. Lecture Notes # 13

MIPS Integer ALU Requirements

FPGA for Software Engineers

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

McGill University Faculty of Engineering FINAL EXAMINATION Fall 2007 (DEC 2007)

DESCRIPTION OF DIGITAL CIRCUITS USING VHDL

CHAPTER - 2 : DESIGN OF ARITHMETIC CIRCUITS

CPE300: Digital System Architecture and Design

Chapter 3: Arithmetic for Computers

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

Sequential Logic - Module 5

Computer Organisation CS303

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Digital Design Using Digilent FPGA Boards -- Verilog / Active-HDL Edition

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

Control and Datapath 8

Sequential Circuit Design: Principle

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

Double Precision Floating Point Core VHDL

XPLANATION: FPGA 101. The Basics of. by Adam Taylor Principal Engineer EADS Astrium FPGA Mathematics

ECE 341 Midterm Exam

Block diagram view. Datapath = functional units + registers

CT 229. Java Syntax 26/09/2006 CT229

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Lab Assignment 2. Implementing Combinational and Sequential Logic in VHDL

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

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

VLSI Based 16 Bit ALU with Interfacing Circuit

Digital Design with SystemVerilog

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Transcription:

Least Common Multiple (LCM) Task: Implement an LCM algorithm that is able to handle any combination of 8-bit (sign bit included) numbers. Use two's complement format to represent negative values. Provide the circuit with an interface for repetitive data input (using buttons and switches) and result output (using LEDs). The design should be developed in accordance with the same methodology as described in the example below: prepare the flowchart of the algorithm that is based on the selected LCM computation method prepare GSA and state transition table for the control part of the design develop a suitable datapath Verify and implement the design on FPGA development board. Greatest Common Divisor Example The greatest common divisor of two non-zero integers is the largest positive integer that divides both numbers without remainder. One way to compute GCD is to use Euclidean algorithm. The flowchart of Euclidean algorithm is presented on Figure. For this example it is assumed that input operands are unsigned 8-bit numbers and none of them is zero. GCD circuit includes a control unit (FSM), which is complemented with a datapath. On this stage the datapath consists of two registers (RG and RG2), multiplexers for selecting the source of data to be stored in these registers and comparator logic. The remainder computation is treated as black box. As most of the basic FPGAs do not feature any dedicated logic for performing division, it must be synthesized separately. A simple division algorithm is presented on Figure 2. At each step it checks whether divisor, which is multiplied by corresponding power of two (starting from the maximum possible), fits into dividend. If it doesn t, then the dividend is

restored. BEGIN START RG := OP; RG2 := OP2; RG = RG2 RG < RG2 RG := RG2; RG2 := RG; Remainder Computation Remainder = READY := ; ANSW := RG2; END Figure : GCD Algorithm Register RG is loaded with dividend, while register RG2 with divisor. At first the divisor is normalized. As the quotient is of no interest, its computation is omitted from the algorithm. After the final run, RG should contain the remainder, while divisor in RG2 is

back to normal. te, that RG is a 9-bit registers, as it should include a sign bit as well. Remainder computation algorithm invokes additional elements in the datapath: Arithmetic Logic Unit (ALU) and up/down counter. ALU is, in a sense, a custom block, its functionality is design specific. For this particular algorithm ALU should handle addition, subtraction and right/left shift operations, as well as comparison. The block scheme of the complete datapath is presented on Figure 3. Remainder Computation RG2(7) = L(RG2.); C := C + ; RG := RG - RG2; RG(8) = RG := RG + RG2; C = R(.RG2); C := C - ; Figure 2: Remainder Computation Algorithm Elements of the datapath are controlled via eleven (Y-Y) signals a control word. Y, Y and Y2 are enable signals for the registers (RG and RG2) and the counter. Y3 signal

selects the counting direction. Y7-Y4 control the multiplexers, which feed data to registers RG and RG2. Y8 and Y9 select the ALU operation (addition, subtraction or right/left shift). Y enables the ANSW output, when the result is ready. The control unit gets feedback from datapath via six (X6-X) signals. X indicates whether the content of RG equals the content of RG2. X2 signals whether the value stored in RG is greater than the value of RG2. X3 is the most significant bit of RG2. X4 is the sign bit of RG. Signals X5 and X6 indicate when content of counter and RG equal zero. OP y5 y4 y x4 x6 RG y9 y8 ALU x x2 OP2 RG2 y7 y6 y x3 Counter y3 y2 x5 DATA PATH UNIT y ANSW Figure 3: Datapath Of GCD Circuit At this stage it is possible to represent the control unit by means of graph-scheme of algorithm (GSA). In this GSA the computational statements (actions of ALU and counter) are replaced with the corresponding control signals (Y-s) and the conditions - with binary conditions signals (X-s). Simultaneously executed statements are grouped into common blocks. The resultant GSA is presented on Figure 4. It can be synthesized as either Moore or Mealy FSM to form a control unit for the GCD circuit.

BEGIN x y7 y5 y y x x2 y6 y4 y y x3 y9 y2 y y8 y x4 y x5 y9 y8 y3 y2 y x6 y END Figure 4: GSA Of GCD Algoritm VHDL descriptions of the main components of the datapath are provided in Listing, Listing 2 and Listing 3. Signals reg and counter_value infer registers during synthesis, as they are assigned a value inside an edge sensitive if statement. This makes the else path

excessive, as the storage element should hold the data unchanged in any other case. Both registers are write-protected with enable signals, so they could store data only when it is required. Counter's activity is also protected with enable signal. te, that example register and example counter are fully synchronous. Their control signals are not present in the sensitivity list, because such circuits should react to the rising edge of the clock signal only. Listing : VHDL Description of ALU process (OP, OP2, op_sel) begin case op_sel is when "" => result <= OP + OP2; when "" => result <= OP - OP2; when "" => result <= OP2(7 downto )&''; when "" => result <= ''&OP2(8 downto ); when others => result <= (others => ''); end case; if OP = OP2 then equal <= ''; else equal <= ''; if OP < OP2 then greater <= ''; else greater <= ''; end process; The counter should definitely be implemented as a signal (not a variable), because its value must be available to other processes. ALU is a purely combinational circuit, thus it reacts to the change on any of its inputs.

Listing 2: VHDL Description of Register process (clk) begin if clk'event and clk = '' then if reg_en = '' then reg <= reg_input; end process; Listing 3: VHDL Description of Up/Down Counter process (clk) begin if clk'event and clk = '' then if counter_en = '' then if count_direction = '' then counter_value <= counter_value - ; else counter_value <= counter_value + ; end process; To check zero equality of a register, its content can be NORed bitwise. The condition becomes High only when all bits of the register are Low. VHDL description of a zero equality check for a 4-bit register is presented in Listing 4. Listing 4: Zero Equality Check for a 4-bit Register reg_zero <= not (reg(3) or reg(2) or reg() or reg() );