A3 A2 A1 A0 Sum4 Sum3 Sum2 Sum1 Sum

Similar documents
LAB #3: ADDERS and COMPARATORS using 3 types of Verilog Modeling

A3 A2 A1 A0 Sum4 Sum3 Sum2 Sum1 Sum

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 09 MULTIPLEXERS

PART 1. Simplification Using Boolean Algebra

structure syntax different levels of abstraction

Here is a list of lecture objectives. They are provided for you to reflect on what you are supposed to learn, rather than an introduction to this

1. Boolean algebra. [6] 2. Constructing a circuit. [4] 3. Number representation [4] 4. Adders [4] 5. ALU [2] 6. Software [4]

Summary. Boolean Addition

Lab Manual for COE 203: Digital Design Lab

Experiment 3: Logic Simplification

ECE 152A LABORATORY 2

Overview. Multiplexor. cs281: Introduction to Computer Systems Lab02 Basic Combinational Circuits: The Mux and the Adder

(Refer Slide Time 6:48)

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

Combinational Circuits Digital Logic (Materials taken primarily from:

Last Name Student Number. Last Name Student Number

Boolean Algebra and Logic Gates

Boolean Algebra. BME208 Logic Circuits Yalçın İŞLER

Computer Organization and Levels of Abstraction

Programmable Logic Design Techniques I

EECS 140 Laboratory Exercise 5 Prime Number Recognition

Experiment 4 Boolean Functions Implementation

CPEN 230L: Introduction to Digital Logic Laboratory Lab #6: Verilog and ModelSim

Experiment 9: Binary Arithmetic Circuits. In-Lab Procedure and Report (30 points)

DIGITAL CIRCUIT LOGIC UNIT 9: MULTIPLEXERS, DECODERS, AND PROGRAMMABLE LOGIC DEVICES

(Refer Slide Time 3:31)

ECE 270 Lab Verification / Evaluation Form. Experiment 1

NAND. Grade (10) Instructor. Logic Design 1 / 13

A B A+B

Software Engineering 2DA4. Slides 2: Introduction to Logic Circuits

1. Mark the correct statement(s)

Elec 326: Digital Logic Design

EET 1131 Lab #7 Arithmetic Circuits

1 Discussion. 2 Pre-Lab

CPLD Experiment 4. XOR and XNOR Gates with Applications

The QR code here provides a shortcut to go to the course webpage.

Physics 364, Fall 2014, reading due your answers to by 11pm on Sunday

ECSE-323 Digital System Design. Lab #1 Using the Altera Quartus II Software Fall 2008

CENG 241 Digital Design 1

Logic Gates and Boolean Algebra ENT263

Digital Circuits. Page 1 of 5. I. Before coming to lab. II. Learning Objectives. III. Materials

QUESTION BANK FOR TEST

R10. II B. Tech I Semester, Supplementary Examinations, May

Physics 364, Fall 2012, reading due your answers to before the end of Wednesday s lab.

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

Lecture (05) Boolean Algebra and Logic Gates

Experiment 8 Introduction to VHDL

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

EECS150, Fall 2004, Midterm 1, Prof. Culler. Problem 1 (15 points) 1.a. Circle the gate-level circuits that DO NOT implement a Boolean AND function.

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

ENEE245 Digital Circuits and Systems Lab Manual

Exp#8: Designing a Programmable Sequence Detector

CHAPTER 9 MULTIPLEXERS, DECODERS, AND PROGRAMMABLE LOGIC DEVICES

Programmable logic technology

Tutorial: ISE 12.2 and the Spartan3e Board v August 2010

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

ENEL 353: Digital Circuits Midterm Examination

ENEE245 Digital Circuits and Systems Lab Manual

Boolean Logic CS.352.F12

EE 231 Fall Lab 1: Introduction to Verilog HDL and Altera IDE

Computer Organization and Levels of Abstraction

Good Evening! Welcome!

Read this before starting!

Introduction to Verilog. Mitch Trope EECS 240 Spring 2004

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

Assignment (3-6) Boolean Algebra and Logic Simplification - General Questions

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

Topics. Midterm Finish Chapter 7

Follow-up question: now, comment on what each of these acronyms actually means, going beyond a mere recitation of the definition.

IT 201 Digital System Design Module II Notes

Introduction. Why Use HDL? Simulation output. Explanation

Lecture 8: Combinational Verilog. CSE 370, Autumn 2007 Benjamin Ylvisaker. Where We Are. Last lecture: Minimization with K!maps

SCHEMATIC DESIGN IN QUARTUS

Introduction to Programmable Logic Devices (Class 7.2 2/28/2013)

ANADOLU UNIVERSITY DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EEM Digital Systems II

Hardware Design Environments. Dr. Mahdi Abbasi Computer Engineering Department Bu-Ali Sina University

University of Florida EEL 3701 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering Revision 0 12-Jun-16

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

CARLETON UNIVERSITY. Laboratory 2.0

CPLD Software Tutorial FOR ALTERA MAX+PLUS II

Copyright 2011 R.S.R. Electronics, Inc. All rights reserved. 04/11. Ver. 1.0web

ESE 150 Lab 07: Digital Logic

Fundamentals of Digital System Design ECE 3700, CPSC 3700

Boolean Analysis of Logic Circuits

that system. weighted value associated with it. numbers. a number. the absence of a signal. MECH 1500 Quiz 2 Review Name: Class: Date:

EEL 4783: Hardware/Software Co-design with FPGAs

PINE TRAINING ACADEMY

CONTENTS CHAPTER 1: NUMBER SYSTEM. Foreword...(vii) Preface... (ix) Acknowledgement... (xi) About the Author...(xxiii)

9/10/2016. The Dual Form Swaps 0/1 and AND/OR. ECE 120: Introduction to Computing. Every Boolean Expression Has a Dual Form

E85: Digital Design and Computer Engineering Lab 2: FPGA Tools and Combinatorial Logic Design

Basic circuit analysis and design. Circuit analysis. Write algebraic expressions or make a truth table

Pre-Laboratory #Boolean Expressions ECE 332

Evolution of Implementation Technologies. ECE 4211/5211 Rapid Prototyping with FPGAs. Gate Array Technology (IBM s) Programmable Logic

Lab 1: Introduction to Verilog HDL and the Xilinx ISE

Digital Logic Design (3)

Programmable Logic Devices

Review. EECS Components and Design Techniques for Digital Systems. Lec 05 Boolean Logic 9/4-04. Seq. Circuit Behavior. Outline.

COS 116 The Computational Universe Laboratory 8: Digital Logic II

Experiment 3. Digital Circuit Prototyping Using FPGAs

LSN 6 Programmable Logic Devices

Transcription:

LAB #3: ADDERS and COMPARATORS using 3 types of Verilog Modeling LAB OBJECTIVES 1. Practice designing more combinational logic circuits 2. More experience with equations and the use of K-maps and Boolean Algebra 3. Practice designing combinational logic circuits with NAND gates 4. Expanded use of programmable logic devices, Complex Programmable Logic Device (CPLD) or the Field Programmable Gate Array (FPGA) 5. More advance uses of Verilog (Data Flow and Behavioral) 6. Exted use of the Integrated Design Environment LAB PROCEDURE PART 1 - Design (create truth table, use K-maps to find equations, and create a circuit schematic diagram) for: A four-bit adder that accepts any 4-bit input and adds a 4-bit binary constant to the input. The output needs five bits. For example (see example Truth Table for adding constant 0101), if the input was 0111 and the constant is 0101 the output should be 01100. (Note: for your constant check the assignment sheet or assigned by your lab instructor) You should have five equations for the five outputs of the adder. Call them sum4, sum3, sum2, sum1, and sum0. Using only one package of: 74LS00 {NAND}, one 74LS04 {NOT}, one 74LS08 {AND} and one 74LS32 {OR} (and your creativity), design a circuit for sum0, sum1, sum2, sum 3 and sum4, however, by this time you may be running out of available gates. Remember to use DeMorgan s theorems and sharing of circuits between outputs. Remember there are 4 gates available in each package of the NAND, AND, and OR Integrated Circuit (IC), and 6 gates in the INVERTER IC. That s a total of 18 gates that are available for you to use. Wire your circuit carefully in MultiSim. You do not want to make mistakes. If you do make a wiring error, it will take time to find it. This is part of the debugging process. Test your circuit by changing the inputs (the switch input values). Your output should ADD your constant to the four inputs. Record the outputs in a truth table for your lab report. There are 16 possible combinations of inputs. Also include a complete schematic with Reference Designators (U# s) and with the IC pin #s. (1,3,5,7,9,B,D,F) Example Truth Table for adding constant of 0101 Input Number Adder Output A3 A2 A1 A0 Sum4 Sum3 Sum2 Sum1 Sum0 0 1 1 1 0 1 1 0 0 PART 2 - Use your five equations for the ADDER circuit from Lab2 part 1 and write a Data Flow model description in Verilog HDL. Be sure you have 5 equations. If you did not do 5 equations in part 1, then you need to derive them for this part. You should write the Verilog files ahead of the. Bring *.v files to Lab class and compile and download your Verilog solution to the CPLD/FPGA board. Test your adder for all possible combinations. If your adder is doing something, but not working properly, you will need to check your truth table, equations, your K-mapping, any Boolean Algebra and DeMorgan s that you used, and the Verilog file, your IDE procedure and possibly the CPLD/FPGA board. It s important to perform your troubleshooting techniques efficiently and methodically. FAQ - What does doing something mean? Good question! If your outputs are stuck low, or stuck high, or some are stuck low and some are stuck high, then your CPLD/FPGA is not doing anything. If the outputs change in some mysterious fashion, but not correctly as you change inputs, we say the CPLD/FPGA is at least doing something. When the outputs of a PLD appear to be doing something, you can assume that the PLD has at least been programmed (or what we called "downloaded"). Since PLDs have non-volatile memory that is they keep what was downloaded last, you may be observing what someone downloaded earlier in the day. Or if your code was downloaded successfully, you may have problems with your equations. Many times, miss assigning pin numbers for switches and LED s causes problems as well. Page 1

PART 3 - Design a full 4-bit adder that adds any 4 bits to any 4 bits. The two 4-bit numbers shall be interpreted as unsigned. Call the 2 numbers A and B. The Function will be A plus B. The number A has four bits called a3, a2, a1 and a0. The number B has four bits called b3, b2, b1 and b0. The adder shall have five outputs called S4 {or CO for Carry Out}, S3 {Sum 3}, S2 {Sum 2}, S1 {Sum 1}, S0 {Sum 0}. Don't do a truth table, but in your lab report discuss how many rows there would be in the truth table if you had to do one. Design tools such as Verilog will "design" functional units like adders for you! Examine the Verilog addition example at the of this lab and modify it to make it a full 4-bit adder. The Verilog used in the addition example is done using Behavior modeling. You should use the same style. Compile, download, and test your design on the CPLD or FPGA board. Connect your two sets of 4 inputs to switches (total of 8 switches). Connect the 5 Sum outputs to LEDs. Ask your instructor to tell you which specific switches and LEDs for you to assign your I/O to. Off-Line - Maybe you noticed schematics while paging through the textbook, or other logic design texts. Years ago designers did all their work using schematics. They moved from drafting tables to drafting software (like Multisim, ORCAD, AUTOCAD, etc.). Today for complex designs few companies use schematics, even computergenerated schematics. Now Hardware Descriptive Languages are used like Verilog and VHDL. However, schematic capture still is important. For one thing some design engineers still think in terms of schematics instead of equations (this includes the authors of logic design textbooks). Schematics can be very helpful in high-level, advanced logic design where many modules are interconnected together. Page 2

PART 4 - Design of Comparator Using Gates: Purpose: To design a simple combinational circuit, i.e., 2-bit comparator, and to gain insight into IC chip minimization instead of gate minimization in implementing the combinational circuit. Procedure: Design a 4-input, 3-circuit that compared two 2-bit unsigned numbers. You can call these numbers a1 a0 and b1 b0. So here a1 is the most significant bit of input A, and a0 is the least significant bit of input A. This circuit should have 3 outputs, which indicate whether A > B, A = B or A < B. You can label these outputs G (which means a1 a0 > b1 b0, where G stands for greater), E (which means a1 a0 + b1 b0), and L (which means a1 a0 < b1 b0). This is called a comparator circuit, because it compares the binary number a1 a0 with the binary number b1 b0. The outputs should be connected to LED indicator circuits. Note that an output of 1 means that the condition being tested by that output is true, which should turn the LED on, while an output of 0 means the condition being tested is false, which should turn the LED off. Start this problem with a truth table that describes the problem. Try to minimize the number of integrated circuit packages needed. One way is with K-maps. You may be able to further minimize the number of gates by thinking about what these outputs really mean, in English. Think about the relationship between the three outputs. The minimize number of chips needed is about 5. You may get graded down for using more gates than needed. Use only NAND gates (74LS00, 74LS10, 74 LS20). Draw a circuit diagram, making sure to include pin numbers, reference designators, and a parts list. Connect switches to your inputs. Connect the three outputs to the three LED indicators circuits from lab A on your own breadboard. Draw gates to look gates in circuit diagrams, not like boxes with pins. Construct and test the circuit in MultiSim. Demonstrate this circuit to your lab instructor. module comparator (a0,a1,b0,b1,g,e,l); input a0,a1,b0,b1; output G,E,L; reg G,E,L; always@(a0 or a1 or b0 or b1) L<={a1,a0}<{b1,b0}; // less than // greater than if ({a1,a0}>{b1,b0}) G<= 1; else G<= 0; // equivalent to G={a1,a0}>{b1,b0}; E<={a1,a0}=={b1,b0}; //logical equality module Page 3

PART 5 - Design an unsigned 3-bit comparator such that A is compared to B. Inputs: A three bits (a2, a1, a0) Outputs: E A equal to B B three bits (b2, b1, b0) L A less than B G A greater than B E, L, and G are each one bit Example: if A = 010 and B = 100, then the outputs would be: E=1, L=0 and G=1 {if active low outputs} Write this problem statement in the form of a truth table. There will be 6 columns for inputs and 3 columns for outputs. You could use K-maps to simplify the equations for E, L and G. How many variables would this K-map have? With Verilog you could skip the K-maps and design a solution based on a truth table and all the input possibilities. The "if-then-else if" Verilog construct would have 64 entries. A "case" construct would have 64 entries as well. Pick one or the other and design a Verilog solution. What kind of modeling technique is this called? With a good text editor you can copy, paste and edit changes rather quickly. Compile, download and test your "truth table" type of solution. Include your truth table, your Verilog source listing, and the segment of the report file that included the equations actually built by ISE in your lab report. Next after doing the above unsigned comparator, design your comparator to interpret the A and B numbers as SIGNED in twos complement format. PART 6 - While the solution for Part 5 was better than doing a six variable K-map, it still was a lengthy design solution (lots of lines of Verilog code). You would suspect that Verilog is better than this! Verilog has the following "logical" operators: = = equality, > greater than, < less than, >= greater than or equal, =< less than or equal to, and!= inequality. Be adventuresome and redesign a solution to the comparator problem by using the relational operators. Compile, download, and test your design. Again, include the segment of the report file that included the equations actually built by ISE using this style of Verilog. Compare the equations with part 5 and comment about any differences in the equations using the two techniques done in each part. Add a signal called U/S (Unsigned/Signed). When the signal is High (Unsigned mode), the Comparator interprets the numbers as Unsigned numbers. When the signal is Low (Signed Mode), the Comparator interprets the numbers as signed numbers. Page 4

PART 7 Special Design: Design a logic system that has eight inputs and two LED outputs. Use your eight pin dip switches as inputs. LED #1 is ON when two switches are LOW next to each other. (note: three switches in a row that are low would be considered two groups of two switches low next to each other) LED #2 is ON whenever the least significant switch is not HIGH, AND there are groups of 3 switches in a row that are set HIGH. Example1: if switches were set 0101 0101 then LEDs #1 & #2 would be OFF Example2: if switches were set 0111 0000 then LEDs #1 & #2 would be ON Example3: if switches were set 0110 1110 then LEDs #1 is OFF and #2 is ON Example4: if switches were set 1110 0011 then LEDs #1 is ON and #2 is OFF Design your solution in Verilog, program your device, and demo your solution to your instructor. Page 5

EXAMPLES of Verilog HDL module simple_2 (a,b,c,d,f1,f2,f3); input a,b,c,d; output f1,f2,f3; assign f1 = (a & ~b) (~a & b); // f1 = a xor b assign f2 = (c & ~d) (~c & d); // f2 = c xor d assign f3 = (f1 & ~f2) (~f1 & f2); // f3 = f1 xor f2 module A two-bit adder: module adder(a1,a0,b1,b0,c_in,c_out,s1,s0); input a1,a0,b1,b0,c_in; output c_out,s1,s0; assign {c_out,s1,s0}={a1,a0}+{b1,b0}+c_in; module Example of Verilog CASE statement use: module case_1 (a,b,c,f1,f2); input a,b,c; output f1,f2; reg f1,f2; always@( a or b or c ) case ({a,b,c}) 0 : 1 : f1<=0; f2<=1; 2 : f1<=0; f2<=1; 3 : 4 : f1<=1; f2<=0; 5 : f1<=1; f2<=1; 6 : f1<=1; f2<=1; 7 : f1<=1; f2<=0; default: case module Page 6

Example of Verilog IF, ELSE IF statement use: module ifthen_1 (a,b,c,f1,f2); input a,b,c; output f1,f2; reg f1,f2; always@(a or b or c ) if (a==0 && b==0 && c==0 ) else if (a==0 && b==0 && c==1 ) f1<=0; f2<=1; else if (a==0 && b==1 && c==0 ) f1<=0; f2<=1; else if (a==0 && b==1 && c==1 ) else if (a==1 && b==0 && c==0 ) f1<=1; f2<=0; else if (a==1 && b==0 && c==1 ) f1<=1; f2<=1; else if (a==1 && b==1 && c==0) f1<=1; f2<=1; else if (a==1 && b==1 && c==1 ) f1<=1; f2<=0; module module adder(a0,a1,b0,b1,c_in,s0,s1,c_out); input a0,a1,b0,b1,c_in; output s0,s1,c_out; assign {c_out,s1,s0}={a1,a0}+{b1,b0}+c_in; module input [3:0] a; output [2:0] f; reg [2:0] f; always@(a) if (a==0) else if (a==1) else if (a==2) else if (a==3) else if (a==4) else if (a==5) else if (a==6) else if (a==7) else if (a==8) module f<=3'b000; f<=3'b011; f<=3'b011; f<=3'b000; f<=3'b101; f<=3'b110; f<=3'b110; f<=3'b101; f<=3'b101; else if (a==9) f<=3'b110; else if (a==10) f<=3'b110; else if (a==11) f<=3'b101; else if (a==12) f<=3'b000; else if (a==13) f<=3'b011; else if (a==14) f<=3'b011; else f<=3'b000; module comparator (a0,a1,b0,b1,g,e,l); input a0,a1,b0,b1; output G,E,L; reg G,E,L; always@(a0 or a1 or b0 or b1) L<={a1,a0}<{b1,b0}; // less than // greater than if ({a1,a0}>{b1,b0}) G<= 1; else G<= 0; // equivalent to G={a1,a0}>{b1,b0}; E<={a1,a0}=={b1,b0}; //logical equality module module ifthen_2 (a,f); Page 7

Dahlquist EEE64 4-Bit Adder Lab Student Constant Number Name 1 1 De Sousa,Miguel 2 2 Diaz,Jeromy John 3 3 Downey,Vincent Antenor 4 4 Fleenor,Roger A 5 5 Funakoshi,Matthew Keats 6 6 Green,Benjamin Deuble 7 7 Huynh,Jordan T 8 9 Jiang,Jiazhi 9 10 Le,Thien 10 11 McFerran,Amy Chantel 11 12 Rarick,Nicholas James 12 1 Rosario,Ralph 13 2 Vang,Richard K 14 3 Yee Yang,Chie Hong 15 4 16 5 17 6 18 7 19 9 20 10 21 11 Constant Number to use for Adder

Lab 3 Adders and Comparators Demo List Part Number Requirements Completed Part 1 Adder with constant Truth Table: Showing work of Boolean expressions with constant provided Multisim: Using AND, NAND, OR, and NOT create adder design Part 2 Adder with constant continued Part 3 Full 4-Bit Adder Part 4 Comparator using gates Verilog: Using dataflow modeling verify design on FPGA Verilog: Design a full adder with 8 inputs and 5 outputs, and test on FPGA. Truth Table and Work Multisim: Using only NAND gates (74LS00, 74LS10, 74LS20) Verilog: Use Behavioral modeling, and test on FPGA. Part 5 (Do, but no demo required) Part 6 Signed and Unsigned Comparator in one module Part 7 Special Design Verilog: Any Method Verilog: Using Behavioral modeling Note 1: When saying Breadboard referring to building the device physically on the breadboard with all components Note 2: When saying Verilog referring to testing the code on your FPGA (Hardware)