Lab Assignment 2. Implementing Combinational and Sequential Logic in VHDL

Similar documents
Lab Assignment 1. Developing and Using Testbenches

Lab 2 Implementing Combinational Logic in VHDL. Advanced Testbenches.

CDA 4253 FPGA System Design VHDL Testbench Development. Hao Zheng Comp. Sci & Eng USF

ELCT 501: Digital System Design

Lab 3 Sequential Logic for Synthesis. FPGA Design Flow.

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

Lab 3 Finite State Machines Movie Ticket Dispensing Machine

ECE 545 Fall 2013 Final Exam

ECE 545 Fall 2010 Exam 1

Midterm Exam ECE 448 Spring 2019 Wednesday, March 6 15 points

Microcomputers. Outline. Number Systems and Digital Logic Review

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Advanced Computer Architecture-CS501

OUTLINE SYSTEM-ON-CHIP DESIGN. GETTING STARTED WITH VHDL September 3, 2018 GAJSKI S Y-CHART (1983) TOP-DOWN DESIGN (1)

Number System. Introduction. Decimal Numbers

World Inside a Computer is Binary

BINARY SYSTEM. Binary system is used in digital systems because it is:

Midterm Exam ECE 448 Spring 2014 Monday, March 3 (15 points)

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

Lab 3 Finite State Machines Automated Teller Machine

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

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

Hardware description languages

Lab 3: Standard Combinational Components

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B DIGITAL SYSTEMS II Fall 1999

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

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

EE 8351 Digital Logic Circuits Ms.J.Jayaudhaya, ASP/EEE

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

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


EGC221: Digital Logic Lab

Lab #1. Topics. 3. Introduction to Verilog 2/8/ Programmable logic. 2. Design Flow. 3. Verilog --- A Hardware Description Language

EXPERIMENT NUMBER 11 REGISTERED ALU DESIGN

Lab 6 Using PicoBlaze. Fast Sorting.

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

REGISTER TRANSFER LANGUAGE

The functional block diagram of 8085A is shown in fig.4.1.

Tutorial: Pattern Wizard

EITF35 - Introduction to Structured VLSI Design (Fall 2017) Course projects

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Digital Fundamentals

Contents. Appendix D Verilog Summary Page 1 of 16

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Verilog Behavioral Modeling

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

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

Let s put together a Manual Processor

Verilog Dataflow Modeling

EE 109 Unit 6 Binary Arithmetic

*Instruction Matters: Purdue Academic Course Transformation. Introduction to Digital System Design. Module 4 Arithmetic and Computer Logic Circuits

ECE 545 Fall 2014 Midterm Exam

Arithmetic Operations

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

IA Digital Electronics - Supervision I

ECE 353 Lab 3 (Verilog Design Approach)

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Introduction to Verilog/System Verilog

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Final Exam Solution Sunday, December 15, 10:05-12:05 PM

Co-processor Math Processor. Richa Upadhyay Prabhu. NMIMS s MPSTME February 9, 2016

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

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers Implementation

Schematic design. Gate level design. 0 EDA (Electronic Design Assistance) 0 Classical design. 0 Computer based language

Am2901 Completion and Integration with Am9080a

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

CAD4 The ALU Fall 2009 Assignment. Description

Verilog Design Principles

Chapter 3: Dataflow Modeling

CS 101: Computer Programming and Utilization

Objectives. After completing this module, you will be able to:

Microcomputer Architecture and Programming

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

ECE 545 Lecture 5. Data Flow Modeling in VHDL. George Mason University

1. Draw general diagram of computer showing different logical components (3)

N-input EX-NOR gate. N-output inverter. N-input NOR gate

Spiral 1 / Unit 4 Verilog HDL. Digital Circuit Design Steps. Digital Circuit Design OVERVIEW. Mark Redekopp. Description. Verification.

ECE 331: N0. Professor Andrew Mason Michigan State University. Opening Remarks

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

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

Note that none of the above MAY be a VALID ANSWER.

CPE300: Digital System Architecture and Design

CHW 261: Logic Design

Unsigned Binary Integers

Unsigned Binary Integers

Chapter 4. Operations on Data

Digital Fundamentals

Chapter 3 Part 2 Combinational Logic Design

Digital Design (VIMIAA01) Introduction to the Verilog HDL

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

VHDL for Synthesis. Course Description. Course Duration. Goals

Chapter 7 Central Processor Unit (S08CPUV2)

LAB 1: Combinational Logic: Designing and Simulation of Arithmetic Logic Unit ALU using VHDL

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

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

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Transcription:

Lab Assignment 2 Implementing Combinational and Sequential Logic in VHDL Task 1 Draw a detailed block diagram of the ALU (Arithmetic Logic Unit), specified using Fig. 1 and Tables 1 and 2. Then develop a dataflow VHDL description of the ALU. Also, debug and verify your code using the respective testbench developed in Lab 1. The ALU performs 16 different operations, including Logic Operations Arithmetic Operations Shifts and Rotations BCD (Binary Coded Decimal) to binary conversion. A B Cin OPCODE 4 ALU Y X Z Cout V F_active X_bin_pal X_prime N Fig. 1 Interface of ALU.

Table 1. Meaning and width of inputs and outputs Name Mode Width Meaning A IN Input A B IN Input B Cin IN 1 Carry In OPCODE IN 4 Operation Code X OUT Output or Least Significant Byte of Output Y OUT Most Significant Byte of Output or Zero Z OUT 1 Zero Flag Cout OUT 1 Carry out Flag V OUT 1 Overflow Flag F_active OUT 1 Logical OR of Z, Cout and V X_bin_pal OUT 1 Flag set to high when the output X is a binary palindromic number (numbers that remain the same when binary digits are reversed) X_prime OUT 1 Flag set to high when the output X is a prime number N OUT 1 Flag set to high when the output X is a negative number Each operation performed by ALU has a specific OPCODE as shown in the table below. Z, Cout, V, N are one-bit flags. They are either affected by a given operation (which means that they are set to 1 or 0 depending on the result of a given operation) or unaffected, as summarized in Table 2. The affected flag is denoted by, and unaffected by. In the combinational version of the circuit (ALU in Task 1), represents 0, as all outputs must be fully determined for each set of inputs. In the sequential version of the circuit (ALU_SEQ in Task 2), represents no change compared to the value of a given flag determined as a result the previous operation. The general rules are summarized below: All operations affect the zero flag, Z. This flag is set if the result of the operation is zero, and is cleared otherwise.

On top of that: Unsigned addition and subtraction affect the carry out flag, Cout. Cout is set when the result is out of range for -bit unsigned numbers, i.e., either smaller than 0, or greater than 255, and is cleared otherwise. Signed addition and subtraction affect the overflow flag, V. V is set when the result is out of range for -bit signed numbers (in the two s complement representation), i.e., either smaller than -12, or greater than 127, and is cleared otherwise. Signed and unsigned multiplications don t affect either Cout or V flags. The result can always be represented using 16 bits stored in registers Y:X (with Y representing most significant bits, and X representing least significant bits of the result). Rotation with carry affects Cout. The carry flag, Cout, is changed to the value of the bit rotated to Cout. Shift operations affect Cout. The carry flag, Cout, is changed to the value of the bit shifted out of the input. BCD to binary conversion affects Cout. Cout is set if the most significant byte of the result, Y, is different than zero, and is cleared otherwise. X_prime and X_bin_pal are affected by every operation, and depend only on the value of X. X_prime indicates whether X is prime when treated as an -bit unsigned number, X_bin_pal indicates whether X is a binary palindromic number. N is affected only by the signed addition/subtraction/multiplication and by arithmetic and logic shifts. For these operations, it should be set to the MSB of the result, either MSB of X or MSB of Y:X, depending on the operation. For the logic shift right, N=0, based on the definition of the operation and the definition of the flag. N should be cleared for all the remaining operations. If the output Y is not affected by a given operation, it is set to 0 for the combinational version of the circuit (ALU in Task 1),, and remains unchanged for the sequential version of the circuit (ALU_SEQ in Task 2).

Table 2. The meaning of operations performed by ALU for each OPCODE. OPCODE OPERATION FORMULA Z Cout V X_bin_pal X_prime N 0000 AND X = A AND B 0 0001 OR X = A OR B 0 0010 XOR X = A XOR B 0 0011 XNOR X = A XNOR B 0 0100 Unsigned (Cout:X) = 0 Addition A + B 0101 Signed Addition X = A + B 0110 Unsigned Addition with Carry 0111 Signed Multiplication 1000 Unsigned Multiplication 1001 Unsigned Subtraction (Cout:X) = A + B + Cin 0 (Y:X) = A * B (Y:X) = A * B 0 X = A - B 0 1010 Rotation Left X = A <<< 1 0 1011 Rotation Left (Cout:X) = (Cin:A) 0 with Carry <<< 1 1100 Logic Shift Right X = A >> 1 0 1101 Arithmetic Shift X = A >> 1 Right 1110 Logic Shift Left X = A << 1 1111 BCD to Binary Conversion (Y:X) = BCD2BIN(B:A) The notation used in the table is as follows: (Y:X) denotes the concatenation of Y and X, with the most significant part stored in Y, and the least significant part stored in X. means that a given flag is affected, means that a given flag is unaffected (cleared for ALU, and left unchanged for ALU_SEQ). A <<< 1 = rotation of A left by one position. A << 1 = shift of A left by one position. A >> 1 = shift of A right by one position.

BCD2BIN(B:A) = conversion of a 4-digit decimal value encoded in BCD (binary-coded decimal) to a binary value. The input may vary between 0000 and 9999 (decimal). 4 bits are used to represent each decimal digit in BCD. Task 2 Develop a mixed-style VHDL RTL description of a sequential ALU (Arithmetic Logic Unit), specified using the interface in Fig. 2, the internal block diagram in Fig. 3 and the operation of the circuit explained in Tables 3. In order to do so, you will have to update the block diagram in Fig. 3 and add the controller logic (used to generate all enable signals and select signals). Then, debug and verify your code using the respective testbench developed in Lab 1. RESET CLK I LOAD SEL_IN ALU_SEQ R Z Cout V F_active X_bin_pal SEL_OUT X_prime N OP 4 Fig. 2 Interface of ALU_SEQ.

clk en0 I en1 REG clk REG A B Cin ALU OPCODE 4 OP en_c clk FF en_v en_n clk REG clk REG Cout Z V X_prime X_bin_pal N Y X Cout Z V F_active 1 0 SEL_OUT R Fig. 3 Block Diagram of ALU_SEQ. Table 3. Meaning and width of inputs and outputs Name Mode Width Meaning CLK IN 1 System clock RESET IN 1 Asynchronous reset active high I IN Value of an operand A or B LOAD IN 1 Loading value of input I to one of the internal registers holding A or B (control signal active for one clock period; the action takes place at the rising edge of the clock) SEL_IN IN 1 0: loading register A 1: loading register B OP IN 4 Operation mode IN 1 Writing the result to registers holding X and Y (control signal active for one clock period; the action takes place at the rising edge of the clock) SEL_OUT IN 1 0: R = X 1: R = Y

R OUT Byte of a result Z OUT 1 Zero flag Cout OUT 1 Carry out flag V OUT 1 Overflow flag F_active OUT 1 Logical OR of Z, Cout and V X_bin_pal OUT 1 Flag set to high when the output X is a binary palindromic number (numbers that remain the same when binary digits are reversed) X_prime OUT 1 Flag set to high when the output X is a prime number N OUT 1 Flag set to high when the result is negative Enable signals en_c, en_v, en_z, en_n, en_xp, en_xbp can be calculated based on OPCODE, and Table 2 of the specification. Task 3 (tested during demonstration): Be prepared to demonstrate the operation of all your testbenches using Aldec Active-HDL and Xilinx ISim. You may be tested on your level of undeanding of this simulators, based at least on the following features. Adding signals to the Waveform window. Including signals from lower levels of hierarchy. All options to run Simulation. Introducing Breakpoints and showing the execution of logic before and after Breakpoints in the Waveform window. Measuring time intervals. Dealing with Buses (Expanding and viewing all bits of a signal). Taking a signal and changing Radix to Decimal, Binary and Hexadecimal. Saving the waveforms in Native format of the simulators. Printing output of the simulators to PDF files. Clearing waveforms. In your report, please describe any problems you have encountered while using Aldec Active- HDL and Xilinx ISim. Please also grade each simulator on the scale from 0 to 10, based on your experiences with using it. Shortly, justify your rating.

Bonus Task: Modify your code for the ALU in such a way that it supports variable shifts and rotations, instead of fixed shifts and rotations. Namely, assume that the meaning of the following opcodes has changed compared to Task 1. OPCODE OPERATION FORMULA Z Cout V X_bin_pal X_prime N 1010 Variable X = A <<< B 0 Rotation Left 1011 Variable Rotation (Cout:X) = (Cin:A) 0 Left with Carry <<< B 1100 Variable Logic X = A >> B 0 Shift Right 1101 Variable Arithmetic Shift Right with Rounding 1110 Variable Logic Shift Left X = (A >> B) + A(B-1) X = A << B Notation used in this table is as follows: A <<< B = rotation of A left by the number of positions given by a value of B. A << B = shift of A left by the number of positions given by a value of B. A >> B = shift of A right by the number of positions given by a value of B. X = (A >> B) + A(B-1) = An arithmetic shift by the number of positions given by B followed by a rounding operation, which consists of adding the value of the B-1st bit of A to the result of the shift. Modify your testbench to fully debug and verify your code for the Bonus Task.

Deliverables: 1. Complete block diagram of the ALU from Task 1 and updated block diagram with control logic from Task 2. 2. Dataflow and Mixed-style RTL VHDL code for Task 1 and Task 2 and possibly Bonus Task. 3. Outputs from all simulations proving the correct operation of codes developed in Task 1, Task 2 and possibly bonus task in the form of PDF files. 4. Short report describing the status of your codes for Task 1 and Task 2. Additionally, please describe any problems you have encountered while coding in VHDL or using Active-HDL and ISim. Please grade each simulator on the scale from 0 to 10, based on your experiences with using it. Shortly justify your rating. Hands-on Session and Introduction to the Experiment Important Dates Monday Section Wednesday Section Thursday Section 02/02/2015 02/04/2015 02/05/2015 Deliverables Due 02/11/2015, 4:00pm 02/11/2015, 7:00pm 02/12/2015, 7:00pm Demonstration Due 02/11/2015, 10:00pm 02/11/2015, 10:00pm 02/12/2015, 10:00pm