Lab Assignment 1. Developing and Using Testbenches

Similar documents
Lab Assignment 2. Implementing Combinational and Sequential Logic in VHDL

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

Advanced Computer Architecture-CS501

Number System. Introduction. Decimal Numbers

World Inside a Computer is Binary

Microcomputers. Outline. Number Systems and Digital Logic Review

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

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

Lab 3 Sequential Logic for Synthesis. FPGA Design Flow.

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

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

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

ECE 545 Fall 2013 Final Exam

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

Tutorial: Pattern Wizard

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

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

CHW 261: Logic Design

Digital Fundamentals

Lab 3 Finite State Machines Automated Teller Machine

Number representations


Arithmetic Operations

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

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

Computer Organization

Real Digital Problem Set #6

TEACHING COMPUTER ARCHITECTURE THROUGH DESIGN PRACTICE. Guoping Wang 1. INTRODUCTION

CS 101: Computer Programming and Utilization

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

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

Least Common Multiple (LCM)

ECE 545 Fall 2010 Exam 1

EXPERIMENT NUMBER 11 REGISTERED ALU DESIGN

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

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

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

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

Assignment 01 Computer Architecture Lab ECSE

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Chapter 4. The Processor

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

ENE 334 Microprocessors

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

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

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

IA Digital Electronics - Supervision I

CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

Chapter 3: part 3 Binary Subtraction

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

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

Lab 3 Finite State Machines Movie Ticket Dispensing Machine

Digital Fundamentals

Binary Arithmetic. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T.

Let s put together a Manual Processor

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Chapter 1 Review of Number Systems

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

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

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

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

2. Define Instruction Set Architecture. What are its two main characteristics? Be precise!

Chapter 7 Central Processor Unit (S08CPUV2)

EE 2700 Project 2 Microprocessor Design

COMP2611: Computer Organization. Data Representation

Lab 2: Multipliers 6.175: Constructive Computer Architecture Fall 2014

REGISTER TRANSFER LANGUAGE

Digital Design (VIMIAA01) Introduction to the Verilog HDL

Contents. Appendix D Verilog Summary Page 1 of 16

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

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

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

Basic Arithmetic (adding and subtracting)

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

CPE300: Digital System Architecture and Design

Unsigned Binary Integers

Unsigned Binary Integers

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

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

UPY14602-DIGITAL ELECTRONICS AND MICROPROCESSORS Lesson Plan

EE 109 Unit 6 Binary Arithmetic

Chapter 4. The Processor Designing the datapath

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

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

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Inf2C - Computer Systems Lecture 2 Data Representation

UNIT-III REGISTER TRANSFER LANGUAGE AND DESIGN OF CONTROL UNIT

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

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

EE292: Fundamentals of ECE

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

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 3 DLD P VIDYA SAGAR

VERILOG 2: LANGUAGE BASICS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

LAB 9 The Performance of MIPS

Transcription:

Lab Assignment 1 Developing and Using Testbenches Task 1 Develop a testbench in VHDL to test and verify the operation of an ALU (Arithmetic Logic Unit), specified using Fig. 1 and Tables 1 and 2. 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. Your task is to develop a testbench that comprehensively tests the described above circuit for agreement with the specification.

Use this testbench to verify the correctness of two post-synthesis simulation models (black boxes): alu_comb_synthesis_1.vhd and alu_comb_synthesis_2.vhd. One of these models is correct and the other contains at least 10 errors. Please find out which model is correct and which contains errors. Please assume that the discrepancies with the specification may have for example the following forms: a. Performed operation does not match its opcode. b. The result of the operation is incorrect for a subset of operand values. c. Values of flags are incorrect. Swapping opcodes of two operations is a special case of a., and should be counted as two discrepancies. Tasks & Deliverables: 1. Write a testbench capable of verifying the operation of the provided models. 2. Determine which model is correct and which contains discrepancies compared to the specification 3. Write a short report describing all discrepancies and test vectors capable of detecting them. 4. Submit the VHDL code for the testbench and the simulation output obtained by applying your testbench. Task 2 Develop a testbench for the sequential ALU (ALU_SEQ), specified using Fig. 2 and Table 3. RESET CLK I LOAD SEL_IN ALU_SEQ R Z Cout V F_active X_bin_pal SEL_OUT RUN X_prime N OP 4 Fig. 2 Interface 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 RUN 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 You are provided with two post-synthesis simulation models (black boxes): alu_seq_synthesis_1.vhd and alu_seq_synthesis_2.vhd One of these models is correct and the other contains at least 12 errors. Tasks & Deliverables: 1. Write a testbench capable of verifying the operation of the provided models. 2. Determine which model is correct and which contains discrepancies compared to the specification. 3. Write a short report describing all discrepancies and test vectors capable of detecting them.

4. Submit the VHDL code for the testbench and the simulation output obtained by applying your testbench. Task 3 (tested during demonstration): Be prepared to demonstrate the operation of all your testbenches using Xilinx ISim. You may be tested on your level of understanding 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 Xilinx ISim. Deliverables: 1. Behavioral VHDL code of all testbenches 2. Outputs from all simulations in the form of PDF files. 3. A short report regarding errors discovered in the given models. Important Dates Hands-on Session and Introduction to the Experiment Demonstration and Deliverables Due Monday Section Wednesday Section Thursday Section 01/26/2015 01/2/2015 01/29/2015 02/04/2015 (extended) 02/04/2015 02/05/2015