Numbering Systems. Number Representations Part 1

Similar documents
Modeling Registers and Counters

Modeling Latches and Flip-flops

COMBINATIONAL CIRCUITS

2011, The McGraw-Hill Companies, Inc. Chapter 3

Chapter 1: Digital Systems and Binary Numbers

The string of digits in the binary number system represents the quantity

Lab 1: Full Adder 0.0

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

CSI 333 Lecture 1 Number Systems

VHDL Test Bench Tutorial

EE360: Digital Design I Course Syllabus

ECE232: Hardware Organization and Design. Part 3: Verilog Tutorial. Basic Verilog

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Binary Adders: Half Adders and Full Adders

Sistemas Digitais I LESI - 2º ano

Xilinx ISE. <Release Version: 10.1i> Tutorial. Department of Electrical and Computer Engineering State University of New York New Paltz

Multiplexers Two Types + Verilog

Useful Number Systems

Lab 17: Building a 4-Digit 7-Segment LED Decoder

earlier in the semester: The Full adder above adds two bits and the output is at the end. So if we do this eight times, we would have an 8-bit adder.

CSE140 Homework #7 - Solution

Life Cycle of a Memory Request. Ring Example: 2 requests for lock 17

Verilog - Representation of Number Literals

Lecture 2. Binary and Hexadecimal Numbers

INTRODUCTION TO DIGITAL SYSTEMS. IMPLEMENTATION: MODULES (ICs) AND NETWORKS IMPLEMENTATION OF ALGORITHMS IN HARDWARE

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

Design Example: Counters. Design Example: Counters. 3-Bit Binary Counter. 3-Bit Binary Counter. Other useful counters:

Let s put together a Manual Processor

Section 1.4 Place Value Systems of Numeration in Other Bases

United States Naval Academy Electrical and Computer Engineering Department. EC262 Exam 1

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Gates, Plexers, Decoders, Registers, Addition and Comparison

BINARY CODED DECIMAL: B.C.D.

EXPERIMENT 4. Parallel Adders, Subtractors, and Complementors

An Integer Square Root Algorithm

Technical Aspects of Creating and Assessing a Learning Environment in Digital Electronics for High School Students

FORDHAM UNIVERSITY CISC Dept. of Computer and Info. Science Spring, Lab 2. The Full-Adder

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Counters and Decoders

EXPERIMENT 8. Flip-Flops and Sequential Circuits

Copyright Peter R. Rony All rights reserved.

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Lecture 11: Number Systems

Upon completion of unit 1.1, students will be able to

E158 Intro to CMOS VLSI Design. Alarm Clock

A Verilog HDL Test Bench Primer Application Note

Karnaugh Maps & Combinational Logic Design. ECE 152A Winter 2012

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

CHAPTER 3 Boolean Algebra and Digital Logic

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

Digital Fundamentals. Lab 8 Asynchronous Counter Applications

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Solution for Homework 2

2011, The McGraw-Hill Companies, Inc. Chapter 5

Digital Electronics Detailed Outline

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

DM Segment Decoder/Driver/Latch with Constant Current Source Outputs

CPEN Digital Logic Design Binary Systems

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

LFSR BASED COUNTERS AVINASH AJANE, B.E. A technical report submitted to the Graduate School. in partial fulfillment of the requirements

(Refer Slide Time: 00:01:16 min)

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

Verification & Design Techniques Used in a Graduate Level VHDL Course

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Decimal Number (base 10) Binary Number (base 2)

More Verilog. 8-bit Register with Synchronous Reset. Shift Register Example. N-bit Register with Asynchronous Reset.

Systems I: Computer Organization and Architecture

LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters

DEPARTMENT OF INFORMATION TECHNLOGY

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

RUTGERS UNIVERSITY Department of Electrical and Computer Engineering 14:332:233 DIGITAL LOGIC DESIGN LABORATORY

Digital Circuit Design Using Xilinx ISE Tools

Chapter 4: Computer Codes

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann

SIM-PL: Software for teaching computer hardware at secondary schools in the Netherlands

3. Convert a number from one number system to another

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

Computer Science 281 Binary and Hexadecimal Review

Implementation of Modified Booth Algorithm (Radix 4) and its Comparison with Booth Algorithm (Radix-2)

Asynchronous Counters. Asynchronous Counters

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Finite State Machine Design A Vending Machine

RAPID PROTOTYPING OF DIGITAL SYSTEMS Second Edition

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Gates, Circuits, and Boolean Algebra

Combinational Logic Design

Take-Home Exercise. z y x. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

Fundamentals of Digital Electronics

Figure 8-1 Four Possible Results of Adding Two Bits

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Gray Code Generator and Decoder by Carsten Kristiansen Napier University. November 2004

Flip-Flops, Registers, Counters, and a Simple Processor

Transcription:

Lab Workbook Introduction Verilog HDL modeling language allows numbers being represented in several radix systems. The underlying circuit processes the number in binary, however, input into and output from such circuits is typically done using decimal numbers. In this lab you will learn various representations and methods for converting numbers from one representation into another. Please refer to the Vivado tutorial on how to use the Vivado tool for creating projects and verifying digital circuits. Objectives After completing this lab, you will be able to: Define a number in various radix Design combinatorial circuits capable of converting data represented in one radix into another Design combinatorial circuits to perform simple addition operation Learn a technique to improver addition speed Number Representations Part 1 In Verilog HDL a signal can have the following four basic values: i. 0 : logic-0 or false ii. 1 : logic-1 or true iii. x : unknown iv: z : high-impedance (tri-state) A z value at the input of a gate or in expression is usually interpreted as an x. In general, Verilog HDL is case-sensitive, but when the values are represented they are case-insensitive. There are three types of constants in Verilog HDL: (i) integer, (ii) real, and (iii) string. An underscore character (_) can be used in an integer or real constant to improve readability. It cannot appear as the first or last character. Integer numbers can be written in (i) simple decimal or (ii) base format. An integer in simple decimal form is specified as a sequence of digits with an optional + or a -. For example, 15-32 where 15 can be represented in binary as 01111 in 5-bit format and -32 can be represented in binary as 100000 in 6-bit format. The simple format representation may result in 32-bit hardware. A number can be represented in the base format with syntax: [size] 'base value where the size specifies the number of bits, base is one of o or O (for octal), b or B (for binary), d or D (for decimal), h or H (for hexadecimal), and value is a sequence of digits which are valid for the specified base. The value must be unsigned. For example, wire [4:0] 5'O37 reg [3:0] 4'B1x_01 wire [3:0] 4'd-4 wire [11:0] 7'Hx 5-bit octal representation 4-bit binary illegal, value cannot be negative 7-bit x extended to xxxxxxx If the size specified is larger than the value for the specified constant, the number is padded to the left with 0 s except for the case where the left most bit is x or z then the padding is done with x or z. If the size specified is smaller than the extra leftmost bits are ignored. If the size is not specified then it will use 32-bit data. www.xilinx.com/university Nexys4 2-1

Lab Workbook 1-1. Define a 4-bit number in the model and display it on the right most 7- segment display. 1-1-1. Open Vivado and create a blank project called lab2_1_1. 1-1-2. Create and add the Verilog module that defines a 4-bit number in binary format and displays the same on the right most 7-segment display. You may use the model developed in 4-2 of Lab 1 assuming that the number you define will be between 0 and 9. 1-1-3. Create and add the XDC file to the project. 1-1-4. Synthesize and implement the design. 1-1-5. Generate the bitstream, download it into the Nexys4 board, and verify the functionality. Binary Codes Part 2 Although most processors compute data in binary form, the input-output is generally done in some coded form. Normally, we exchange information in decimal. Hence decimal numbers must be coded in terms of binary representations. In the simplest form of binary code, each decimal digit is replaced by its binary equivalent. This representation is called Binary Coded Decimal (BCD) or 8-4-2-1 (to indicate weight of each bit position). Because there are only ten decimal digits, 1010 through 1111 are not valid BCD. Table below shows some of the widely used binary codes for decimal digits. These codes are designed and used for communication reliability and error detection. Decimal Digits BCD (8-4-2-1) 6-3-1-1 Excess-3 2-out-of-5 Gray code 0 0000 0000 0011 00011 0000 1 0001 0001 0100 00101 0001 2 0010 0011 0101 00110 0011 3 0011 0100 0110 01001 0010 4 0100 0101 0111 01010 0110 5 0101 0111 1000 01100 1110 6 0110 1000 1001 10001 1010 7 0111 1001 1010 10010 1011 8 1000 1011 1011 10100 1001 9 1001 1100 1100 11000 1000 2-1. Output 4-bit binary input onto one LED (most significant bit) and the right most 7-segment display (least significant digit) after converting them into two-digit decimal equivalent (BCD). Use only dataflow modeling. Design a circuit that converts a 4-bit binary number v into its 2-digit decimal equivalent, z and m. Since valid input range is between 0 and 15, the most significant digit can be displayed using one LED. Table below shows the required output values. A block diagram of the design is given in figure below. It includes a comparator that checks when the value of v is greater than 9, and uses the output of this comparator in the control of the 7-segment displays. Hint: The m3 would be zero whenever V is greater than binary 1001. Nexys4 2-2 www.xilinx.com/university

Lab Workbook v[3:0] z m[3:0] 0000 0 0000 0001 0 0001 0010 0 0010 0011 0 0011 0100 0 0100 0101 0 0101 0110 0 0110 0111 0 0111 1000 0 1000 1001 0 1001 1010 1 0000 1011 1 0001 1100 1 0010 1101 1 0011 1110 1 0100 1111 1 0101 2-1-1. Open Vivado and create a blank project called lab2_2_1. 2-1-2. Create and add the Verilog module (name it as lab2_2_1_parta) with v[3:0] input, and z and m[3:0] output. Create and add Verilog modules to perform comparator_dataflow, lab2_circuita_dataflow functionality using the dataflow constructs, instantiate mux_2to1 (of Lab 1) and connect them as shown in the above figure. www.xilinx.com/university Nexys4 2-3

Lab Workbook 2-1-3. Add the provided testbench (lab2_2_1_parta_tb.v) to the project. 2-1-4. Simulate (behavioral simulation) the design for 200 ns and verify the design works. 2-1-5. Extend the design by creating the top-level module (lab2_2_1) to have bcdto7segment_dataflow decoder (that you developed in Lab 1) and provide one 7-bit output seg0 instead of m. 2-1-6. Create and add the XDC file to the project. Assign v input to SW3-SW0, z to LED0, and seg0 to SEG0 (the right most 7-segment display). 2-1-7. Synthesize and implement the design. 2-1-8. Generate the bitstream, download it into the Nexys4 board, and verify the functionality. 2-2. Model a 2-out-of-5 binary code and display a 4-bit binary coded decimal input number onto five LEDs. Use dataflow modeling. 2-2-1. Open Vivado and create a blank project called lab2_2_2. 2-2-2. Create and add a hierarchical design with 4-bit input (x[3:0]) and 5-bit output(y[4:0]). Use dataflow modeling statements only. 2-2-3. Create and add the XDC file to the project. Assign SW3 -SW0 to x and LED4 to LED0 to y. 2-2-4. Synthesize and implement the design. 2-2-5. Generate the bitstream, download it into the Nexys4 board, and verify the functionality. Performing Addition Part 3 When two one-bit numbers are added, they may produce two bits output. For example, 1 + 1 = 10 (all in binary). When you add three one- bit numbers the result will still be two bits, e.g. 1 + 1 + 1 = 11. This simple operation can be viewed as adding two bits with carry in from the lower significant operation, resulting into sum and carry out- the left bit is carry out and the right bit is sum. Figure below shows a 4- bit adder. Since the carry is rippled from least significant bit position (cin) to the most significant position (cout), such adder is called ripple carry adder. 3-1. Create a 4-bit ripple carry adder using dataflow modeling. Nexys4 2-4 www.xilinx.com/university

Lab Workbook 3-1-1. Open Vivado and create a blank project called lab2_3_1. 3-1-2. Create and add the Verilog module named fulladder_dataflow with three inputs (a, b, cin) and two outputs (s and cout) using dataflow modeling. All inputs and outputs should be one-bit wide. 3-1-3. Add the provided testbench (fulladder_dataflow_tb.v) to the project. 3-1-4. Simulate the design for 80 ns and verify that the design works 3-1-5. Create and add the Verilog module (called rca_dataflow) to the project with three inputs (a, b, cin) and two outputs (cout and s) instantiating full adder (FA) four times and connecting them as necessary. The a, b, and s should be a 4-bit vector and cin and cout should each be one-bit wide. 3-1-6. Create and add the XDC file, assigning a to SW7-SW4, b to SW3-SW0, s to LED3-LED0, cin to SW15, and cout to LED15. 3-1-7. Synthesize and implement the design. 3-1-8. Generate the bitstream, download it into the Nexys4 board, and verify the functionality. 3-2. Modify the design of 3-1 by treating the 4-bit input as BCD, performing addition, generating result in BCD, and displaying it on LED0 and right most 7-segment display. Use switches to input two 4-bit BCD input and SW15 for carry-in. Reuse models developed in 2-1 and 3-1 as needed. Use dataflow modeling. 3-2-1. Open Vivado and create a blank project called lab2_3_2. 3-2-2. Modify the project of 3-1 as necessary to perform the required function and outputting the result on LED0 and the right most 7-segment display. 3-2-3. Modify the XDC file 3-2-4. Synthesize and implement the design. 3-2-5. Generate the bitstream, download it into the Nexys4 board, and verify the functionality. Improving Addition Speed Part 4 The ripple-carry adders take a longer time to compute when two large numbers (e.g. 8, 16, 32 bits) are added. To reduce the computation time, another structure, called carry-lookahead adders (see figure below), can be used. It works by creating two signals (P and G) for each bit position, based on whether a carry is propagated through a less significant bit position (at least one input is a '1'), generated in that bit position (both inputs are '1'), or killed in that bit position (both inputs are '0'). After P and G are generated the carries for every bit position are created. www.xilinx.com/university Nexys4 2-5

Lab Workbook Where P i = A i + B i and G i = A i B i. Within Carry Look Ahead unit, C i+1 = G i + P i C i. The speed-up is achieved through the fact that C i being generated at the same time irrespective of i th position. 4-1. Create a carry-look ahead adder circuit by modifying the project of 3-1 and using dataflow modeling. 4-1-1. Open Vivado and open the project you had created in 3-1. 4-1-2. Modify the project of 3-1 as necessary to perform the addition of two four-bit numbers using the carry look-ahead structure and outputting the result on the LEDs. Provide carry-in through SW15. Hint: You will need to modify FA to output Pi and Gi, and then create and add another module CLA to perform the carry look ahead function (takes c 0 and p i g i (i=0 to 3) and outputs c 4 and p g and g g. 4-1-3. Modify the XDC file to provide input b through SW3-SW0, a through SW7-SW4, cin through SW15. Output cout through LED15 and sum through LED3-LED0. 4-1-4. Synthesize and implement the design. 4-1-5. Generate the bitstream, download it into the Nexys4 board, and verify the functionality. Conclusion In this lab, you learned how to define numbers in various radix systems. You also designed various number conversion circuits using dataflow modeling. You also learned a technique of improving addition speed. Nexys4 2-6 www.xilinx.com/university