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

Similar documents
RAPID PROTOTYPING OF DIGITAL SYSTEMS Second Edition

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

Digital Electronics Detailed Outline

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

Learning Digital Systems Design in VHDL by Example in a Junior Course

Understanding Logic Design

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

CONTENTS PREFACE 1 INTRODUCTION 1 2 NUMBER SYSTEMS AND CODES 25. vii

CHAPTER 3 Boolean Algebra and Digital Logic

Binary Adders: Half Adders and Full Adders

EE360: Digital Design I Course Syllabus

SECTION C [short essay] [Not to exceed 120 words, Answer any SIX questions. Each question carries FOUR marks] 6 x 4=24 marks

Counters and Decoders

University of St. Thomas ENGR Digital Design 4 Credit Course Monday, Wednesday, Friday from 1:35 p.m. to 2:40 p.m. Lecture: Room OWS LL54

ANALOG & DIGITAL ELECTRONICS

DEPARTMENT OF INFORMATION TECHNLOGY

EXPERIMENT 8. Flip-Flops and Sequential Circuits

COMBINATIONAL and SEQUENTIAL LOGIC CIRCUITS Hardware implementation and software design

Introduction to Digital Design Using Digilent FPGA Boards Block Diagram / Verilog Examples

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Module 3: Floyd, Digital Fundamental

ASYNCHRONOUS COUNTERS

RAM & ROM Based Digital Design. ECE 152A Winter 2012

Lecture 8: Synchronous Digital Systems

Academic year: 2015/2016 Code: IES s ECTS credits: 6. Field of study: Electronics and Telecommunications Specialty: -

Guru Ghasidas Vishwavidyalaya, Bilaspur (C.G.) Institute of Technology. Electronics & Communication Engineering. B.

BINARY CODED DECIMAL: B.C.D.

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

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

Operating Manual Ver.1.1

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

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

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

COMBINATIONAL CIRCUITS

Let s put together a Manual Processor

CHAPTER 11 LATCHES AND FLIP-FLOPS

Digital Systems. Syllabus 8/18/2010 1

Chapter 7 Memory and Programmable Logic

Digital Systems Design! Lecture 1 - Introduction!!

Read-only memory Implementing logic with ROM Programmable logic devices Implementing logic with PLDs Static hazards

CpE358/CS381. Switching Theory and Logical Design. Class 10

Digital Electronics Part I Combinational and Sequential Logic. Dr. I. J. Wassell

Aims and Objectives. E 3.05 Digital System Design. Course Syllabus. Course Syllabus (1) Programmable Logic

Sequential Circuit Design

Digital Systems Laboratory

Cascaded Counters. Page 1 BYU

1. True or False? A voltage level in the range 0 to 2 volts is interpreted as a binary 1.

Latches, the D Flip-Flop & Counter Design. ECE 152A Winter 2012

Chapter 9 Latches, Flip-Flops, and Timers

Designing Digital Circuits a modern approach. Jonathan Turner

Flip-Flops and Sequential Circuit Design. ECE 152A Winter 2012

Flip-Flops and Sequential Circuit Design

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

Gates, Circuits, and Boolean Algebra

DATA SHEETS DE COMPONENTES DA FAMÍLIA LÓGICA TTL GATES AND INVERTERS POSITIVES NAND GATES AND INVERTERS DESCRIÇÃO

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

Philadelphia University Faculty of Information Technology Department of Computer Science Semester, 2007/2008.

V05: Diploma in Computer Hardware maintenance and Network Technologies (Windows 2000 Server) (32 CP)

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

Basic Logic Gates Richard E. Haskell

Memory Elements. Combinational logic cannot remember

Having read this workbook you should be able to: recognise the arrangement of NAND gates used to form an S-R flip-flop.

Course Requirements & Evaluation Methods

Contemporary Logic Design

ENEE 244 (01**). Spring Homework 5. Due back in class on Friday, April 28.

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

CS311 Lecture: Sequential Circuits

Combinational Logic Design Process

Interfacing To Alphanumeric Displays

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

EE 42/100 Lecture 24: Latches and Flip Flops. Rev B 4/21/2010 (2:04 PM) Prof. Ali M. Niknejad

5 Combinatorial Components. 5.0 Full adder. Full subtractor

Two-level logic using NAND gates

Diploma in Computer Hardware Maintenance and Network Technologies(DCHMNT)

AC : PRACTICAL DESIGN PROJECTS UTILIZING COMPLEX PROGRAMMABLE LOGIC DEVICES (CPLD)

Sistemas Digitais I LESI - 2º ano

Counters. Present State Next State A B A B

DIGITAL TECHNICS II. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute 5. LECTURE: REGISTERS AND RELATED

ELEC2141 DIGITAL CIRCUIT DESIGN

Chapter 8. Sequential Circuits for Registers and Counters

路 論 Chapter 15 System-Level Physical Design

Introduction to CMOS VLSI Design (E158) Lecture 8: Clocking of VLSI Systems

Upon completion of unit 1.1, students will be able to

Chapter 2 Logic Gates and Introduction to Computer Architecture

DIGITAL TECHNICS II. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute. 2nd (Spring) term 2012/2013

A Comparison of Student Learning in an Introductory Logic Circuits Course: Traditional Face-to-Face vs. Fully Online

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

Master/Slave Flip Flops

Fundamentals of Digital Electronics

Sequential Logic. (Materials taken from: Principles of Computer Hardware by Alan Clements )

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

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

Finite State Machine Design and VHDL Coding Techniques

Useful Number Systems

Lab 1: Study of Gates & Flip-flops

Digital Controller for Pedestrian Crossing and Traffic Lights

Combinational Logic Design

Transcription:

Digital Design Using Digilent FPGA Boards -- Verilog / Active-HDL Edition Table of Contents 1. Introduction to Digital Logic 1 1.1 Background 1 1.2 Digital Logic 5 1.3 Verilog 8 2. Basic Logic Gates 9 2.1 Truth Tables and Logic Equations 9 The Three Basic Gates 9 Four New Gates 11 2.2 Positive and Negative Logic: De Morgan s Theorem 13 2.3 Sum of Products Design 16 2.4 Product of Sums Design 15 Verilog Examples 18 Example 1 2-Input Gates 18 Example 2 Multiple-Input Gates 21 Problems 24 3. Boolean Algebra and Logic Equations 28 3.1 Boolean Theorems 28 One-Variable Theorems 29 Two- and Three-Variable Theorems 29 3.2 Karnaugh Maps 34 Two-Variable K-Maps 34 Three-Variable K-Maps 36 Four-Variable K-Maps 38 3.3 Computer Mimimization Techniques 40 Tabular Representations 40 Prime Implicants 41 Essential Prime Implicants 43 Verilog Examples 45 Example 3 Majority Circuit 45 Example 4 2-Bit Comparator 47 Problems 50 4. Implementing Digital Circuits 52 4.1 Implementing Gates 52 4.2 Transistor-Transistor Logic (TTL) 54 4.3 Programmable Logic Devices (PLDs and CPLDs) 56 A 2-Input, 1-Output PLD 56 v

The GAL 16V8 58 CPLDs 60 4.4 Field Programmable Gate Arrays (FPGAs) 60 Verilog Examples 62 Example 5 Map Report 62 Problems 63 5. Combinational Logic 64 5.1 Multiplexers 64 2-to-1 Multiplexer 64 4-to-1 Multiplexer 65 Quad 2-to-1 Multiplexer 66 Verilog Examples 67 Example 6 2-to-1 Multiplexer: if Statement 67 Example 7 4-to-1 Multiplexer: Module Instantiation 70 Example 8 4-to-1 Multiplexer: case Statement 74 Example 9 A Quad 2-to-1 Multiplexer 75 Example 10 Generic Multiplexer: Parameters 77 Example 11 Glitches 79 5.2 7-Segment Displays 82 Verilog Examples 83 Example 12 7-Segment Decoder: Logic Equations 83 Example 13 7-Segment Decoder: case Statement 85 Example 14 Multiplexing 7-Segment Displays 87 Example 15 7-Segment Displays: x7seg and x7segb 89 5.3 Comparators 94 Cascading Comparators 94 TTL Comparators 95 Verilog Examples 96 Example 16 4-Bit Comparator Using a Verilog Task 96 Example 17 N-Bit Comparator Using Relational Operators 98 5.4 Decoders and Encoders 100 Decoders 100 TTL Decoders 101 Encoders 101 Priority Encoders 102 TTL Encoders 102 Verilog Examples 103 Example 18 3-to-8 Decoder: Logic Equations 103 Example 19 3-to-8 Decoder: for Loops 104 Example 20 8-to-3 Encoder: Logic Equations 105 Example 21 8-to-3 Encoder: for Loops 107 Example 22 8-to-3 Priority Encoder 107 5.5. Code Converters 109 Binary-to-BCD Converters 109 Shift and Add 3 Algorithm 110 Gray Code Converters 111 Verilog Examples 112 Example 23 4-Bit Binary-to-BCD Converter: Logic Equations 112 vi

Example 24 8-Bit Binary-to-BCD Converter: for Loops 113 Example 25 4-Bit Binary to Gray Code Converter 115 Example 26 4-Bit Gray Code to Binary Converter 116 Problems 117 6. Arithmetic Circuits 120 6.1 Adders 120 Half Adder 120 Full Adder 120 Carry and Overflow 123 TTL Adder 125 Verilog Examples 125 Example 27 4-Bit Adder: Logic Equations 125 Example 28 4-Bit Adder: Behavioral Statements 128 Example 29 N-Bit Adder: Behavioral Statements 129 6.2 Subtractors 129 Half Subtractor 129 Full Subtractor 130 An Adder/Subtractor Circuit 131 Verilog Examples 133 Example 30 4-Bit Adder/Subtractor: Logic Equations 133 Example 31 N-Bit Subtractor: Behavioral Statements 134 6.3 Shifters 135 Verilog Examples 136 Example 32 4-Bit Shifter 136 6.4 Multiplication 137 Binary Multiplication 137 Signed Multiplication 139 Verilog Examples 140 Example 33 Multiplying by a Constant 140 Example 34 A 4-Bit Multiplier 141 6.5 Division 143 Binary Division 143 Verilog Examples 144 Example 35 An 8-Bit Divider using a Task 144 6.6 Arithmetic Logic Unit (ALU) 146 Verilog Examples 147 Example 36 4-Bit ALU 147 Problems 149 7. Sequential Logic 151 7.1 Latches and Flip-Flops 151 SR Latch 151 Clocked SR Latch 153 D Latch 153 Edge-Triggered D Flip-Flop 154 Verilog Examples 156 Example 37 Edge-Triggered D Flip-Flop 156 Example 38 Edge-Triggered D Flip-Flop with Set and Clear 157 vii

Example 39 D Flip-Flops in Verilog 158 Example 40 D Flip-Flop with Asynchronous Set and Clear 159 Example 41 Divide-by-2 Counter 160 7.2 Registers 161 Verilog Examples 163 Example 42 1-Bit Register 163 Example 43 4-Bit Register 164 Example 44 N-Bit Register 165 7.3 Shift Registers 166 4-Bit Ring Counter 167 Verilog Examples 167 Example 45 Shift Registers 167 Example 46 Ring Counter 168 Example 47 Debounce Pushbuttons 169 Example 48 Clock Pulse 171 7.4 Counters 173 Arbitrary Waveform 174 Verilog Examples 175 Example 49 3-Bit Counter 175 Example 50 Modulo-5 Counter 177 Example 51 N-Bit Counter 178 Example 52 Clock Divider: Modulo-10K Counter 180 Example 53 Arbitrary Waveform 184 7.5 Pulse-Width Modulation (PWM) 185 Controlling the Speed of a DC Motor using PWM 186 Controlling the Position of a Servo using PWM 187 Verilog Examples 188 Example 54 Pulse-Width Modulation (PWM) 188 Example 55 PWM Signal for Controlling Servos 190 7.6 BASYS/Nexys-2 Board Examples 191 Verilog Examples 191 Example 56 Loading Switch Data into a Register 191 Example 57 Shifting Data into a Shift Register 193 Example 58 Scrolling the 7-Segment Display 195 Example 59 Fibonacci Sequence 200 Problems 203 8. State Machines 206 8.1 Mealy and Moore State Machines 206 8.2 A Moore Machine Sequence Detector 207 8.3 Mealy Machine Sequence Detector 209 Verilog Examples 210 Example 60 Sequence Detector 210 Example 61 Door Lock Code 215 Example 62 Traffic Lights 219 Problems 224 viii

9. Datapaths and Control Units 225 9.1 Verilog while Statement 225 Example 63 GCD Algorithm Part 1 225 9.2 Datapaths and Control Units 227 Example 64 GCD Algorithm Part 2 229 Example 65 An Integer Square Root Algorithm 237 10. Integrating the Datapath and Control Unit 247 Example 66 GCD Algorithm Part 3 249 Example 67 Integer Square Root Part 2 253 11. Memory 257 Example 68 A Verilog ROM 257 Example 69 Distributed RAM/ROM 262 Example 70 Block RAM/ROM 267 12. VGA Controller 271 Example 71 VGA-Stripes 275 Example 72 VGA-PROM 281 Example 73 Sprites in Block ROM 286 Example 74 Screen Saver 292 13. PS/2 Port 297 Example 75 Keyboard 300 Example 76 Mouse 303 Appendix A Aldec Active-HDL Tutorial 313 Part 1: Project Setup 313 Part 2: Design Entry 317 Part 3: Simulation 320 Part 4: Creating a Top-level Design 324 Part 5: Synthesis and Implementation 326 Part 6: Program FPGA Board 330 Appendix B Number Systems 331 B.1 Counting in Binary and Hexadecimal 331 B.2 Positional Notation 335 B.3 Fractional Numbers 336 B.4 Number System Conversions 336 B.5 Negative Numbers 340 Appendix C Making a Turnkey System 344 Appendix D Verilog Quick Reference Guide 346 ix