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

Similar documents
EE 231 Fall EE 231 Lab 2

Lab 2: Introduction to Verilog HDL and Quartus

Lab 1: Introduction to Verilog HDL and the Xilinx ISE

CET4805 Component and Subsystem Design II. EXPERIMENT # 5: Adders. Name: Date:

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

Tutorial on Quartus II Introduction Using Verilog Code

ECE 3610 Microprocessing Systems Lab #1 Verilog Design of the TOC Using Quartus II

Terasic DE0 Field Programmable Gate Array (FPGA) Development Board

University of Florida EEL 3701 Dr. Eric M. Schwartz Madison Emas, TA Department of Electrical & Computer Engineering Revision 1 5-Jun-17

FPGA Introductory Tutorial: Part 1

Tutorial for Altera DE1 and Quartus II

Chapter 2 Getting Hands on Altera Quartus II Software

Tutorial on Quartus II Introduction Using Schematic Designs

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180A DIGITAL SYSTEMS I Winter 2015

NOTE: This tutorial contains many large illustrations. Page breaks have been added to keep images on the same page as the step that they represent.

Quick Tutorial for Quartus II & ModelSim Altera

Physics 536 Spring Illustrating the FPGA design process using Quartus II design software and the Cyclone II FPGA Starter Board.

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 10: Implementing Binary Adders. Name: Date:

SCHEMATIC DESIGN IN QUARTUS

Quartus II Introduction Using Verilog Designs. 1 Introduction. For Quartus II 12.0

Quartus II Introduction Using Verilog Design

Lab 2 EECE473 Computer Organization & Architecture University of Maine

CPE 200L LABORATORY 4: INTRODUCTION TO DE2 BOARD UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND:

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 7: VHDL and DE2 Board. Name: Date:

UNIVERSITI MALAYSIA PERLIS

PRELAB! Read the entire lab, and complete the prelab questions (Q1- Q3) on the answer sheet before coming to the laboratory.

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 6: Quartus II Tutorial and Practice. Name: Date:

NIOS CPU Based Embedded Computer System on Programmable Chip

Altera Quartus II Tutorial ECE 552

1 Introduction 2. 2 Background 3. 3 Getting Started 4. 4 Starting a New Project 6. 5 Design Entry Using VHDL Code 13

CSCB58 - Lab 0. Intro to The Lab & The DE2 Board. Prelab /4 Part I (in-lab) /1 Part II (in-lab) /1

Chapter 2: Hardware Design Flow Using Verilog in Quartus II

CET4805 Component and Subsystem Design II. EXPERIMENT # 2: VHDL(VHSIC Hardware Descriptive Language) Name: Date:

Contents. Appendix B HDL Entry Tutorial 2 Page 1 of 14

2 nd Year Laboratory. Experiment: FPGA Design with Verilog. Department of Electrical & Electronic Engineering. Imperial College London.

QUARTUS II Altera Corporation

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

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Laboratory Exercise #1 Using the Vivado

CSE P567 - Winter 2010 Lab 1 Introduction to FGPA CAD Tools

QuartusII.doc 25/02/2005 Page 1

Engineering 303 Digital Logic Design Spring 2017

Quartus II Introduction Using Schematic Design

SOPC LAB1. I. Introduction. II. Lab contents. 4-bit count up counter. Advanced VLSI Due Wednesday, 01/08/2003

Laboratory Exercise 3 Comparative Analysis of Hardware and Emulation Forms of Signed 32-Bit Multiplication

Introduction to the Altera SOPC Builder Using Verilog Designs. 1 Introduction

EXPERIMENT 1. INTRODUCTION TO ALTERA

University Program 3 Kit

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

NIOS CPU Based Embedded Computer System on Programmable Chip

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

Laboratory Exercise 3

CHAPTER 1 INTRODUCTION... 1 CHAPTER 2 ASSIGN THE DEVICE... 7 CHAPTER 3 DESIGN ENTRY CHAPTER 4 COMPILE AND VERIFY YOUR DESIGN...

A B A+B

SignalTap II with Verilog Designs. 1 Introduction. For Quartus II 13.1

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Laboratory Exercise #1 Using the Vivado

PRELAB! Read the entire lab, and complete the prelab questions (Q1-Q3) on the answer sheet before coming to the laboratory.

Laboratory 4 Design a Muti-bit Counter and Programming a FPGA

Design Flow Tutorial

DOWNLOADING DESIGNS TO THE ALTERA DE10-LITE FPGA

COSC 3215 Embedded Systems Laboratory

Tutorial 2 Implementing Circuits in Altera Devices

University of California, Davis Department of Electrical and Computer Engineering. Lab 1: Implementing Combinational Logic in the MAX10 FPGA

Introduction to the Altera SOPC Builder Using Verilog Design

E85: Digital Design and Computer Architecture J. Spjut and R. Wang Spring 2014

EE 1315 DIGITAL LOGIC LAB EE Dept, UMD

Lab 6: Integrated the Decoder with Muti-bit Counter and Programming a FPGA

Laboratory 4 Design a Muti-bit Counter

Step 1: Downloading the source files

Hardware Description Languages (HDLs) Verilog

EET 1131 Lab #7 Arithmetic Circuits

TUTORIAL #2 HIERARCHICAL DESIGNS AND TEST FIXTURES

CHAPTER 3 METHODOLOGY. 3.1 Analysis of the Conventional High Speed 8-bits x 8-bits Wallace Tree Multiplier

Digital Systems Laboratory

ECE 353 Lab 3. MIDI Note Number Display. Lab Info. Electrical and Computer Engineering

NIOS CPU Based Embedded Computer System on Programmable Chip

Verilog Simulation Mapping

The development board used in this class is ALTERA s DE The board provides the following hardware:

Workshop on Digital Circuit Design in FPGA

Tutorial 3. Appendix D. D.1 Design Using Verilog Code. The Ripple-Carry Adder Code. Functional Simulation

Quartus II Version 14.0 Tutorial Created September 10, 2014; Last Updated January 9, 2017

University of Massachusetts Amherst Computer Systems Lab 2 (ECE 354) Spring Lab 1: Using Nios 2 processor for code execution on FPGA

DE2 Board & Quartus II Software

and 32 bit for 32 bit. If you don t pay attention to this, there will be unexpected behavior in the ISE software and thing may not work properly!

Chip Design with FPGA Design Tools

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

Sidewinder Development Board rev 1.0

ECE 353 Lab 4. MIDI Receiver in Verilog. Professor Daniel Holcomb UMass Amherst Fall 2016

Laboratory Exercise 1

ELEC 4200 Lab#0 Tutorial

Quartus II Tutorial. September 10, 2014 Quartus II Version 14.0

PART 1. Simplification Using Boolean Algebra

TLL5000 Electronic System Design Base Module. Getting Started Guide, Ver 3.4

My First FPGA Design Tutorial

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

EE 367 Logic Design Lab #1 Introduction to Xilinx ISE and the ML40X Eval Board Date: 1/21/09 Due: 1/28/09

Experiment 3. Digital Circuit Prototyping Using FPGAs

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

PHYS 623 Field Programmable Gate Arrays Laboratory 1

Transcription:

Lab 1: Introduction to Verilog HDL and Altera IDE Introduction In this lab you will design simple circuits by programming the Field-Programmable Gate Array (FPGA). At the end of the lab you should be able to understand the process of a Programmable Logic Device (PLD), and the advantages of such an approach over using discrete components. 1 Prelab 1.1. Read the material provided in the supplementary section. 1.2 What is a half adder? Explain in terms of input and output signals 1.2. Using the schematics of the board, if the FPGA sends a logic 1 to one of the LEDs, would it turn on or off? Figure 1: Schematic of Cyclone IV LEDs

2 Lab 2.1. Write a gate level Verilog program to implement the half adder circuit shown in Figure 2. Figure 2: Half Adder Circuit 2.2. Assign your two inputs to the two push buttons and your two outputs to two of the LEDs. Before you continue, ask the TA to check your assignment. 2.3. Perform both functional and timing simulations. The simulations can also be done with the Logic Analyzer. Print your waveforms. Are the two waveforms the same? Discuss. 2.4. Write a Verilog program to implement the same half adder circuit using dataflow modeling and simulate your circuit again. Note: you don t have to respecify your waveforms as you have already saved them in a file. 2.5. Program your PLD (be sure to have the correct device selected) to implement your circuit and verify that it works. Ask the TA to initial your lab book once you have it working. 2.6. Use vectors to describe your inputs and outputs. Send signals to all of the LEDs to have them off when you send them a logic 0 and turn on when you send them a logic 1, and similarly, the input to be logic 1 into your circuit when you press the button and zero otherwise. 3 Supplement Verilog An introduction to Verilog HDL is discussed in the sections to follow 3.1. In order to write a Verilog HDL description of any circuit you will need to write a module, which is the fundamental descriptive unit in Verilog. A module is the is a set of text describing your circuit and is enclosed by the key words module and endmodule. 3.2. As the program describes a physical circuit you will need to specify the inputs, the outputs, the behavior of the circuit, and how the gates are wired. To accomplish this, you need the keywords input, output, and wire to define the inputs, outputs, and the wiring between the gates, respectively.

3.3. There are multiple ways to model a circuit: Gate level modeling Dataflow modeling Behavioral modeling Or a combination of the above 2.1.4. A simple program modeling the circuit in Figure 2 at the gate level is shown below. Figure 2: Simple Circuit Listing 1: Simple Program in Verilog Modeling a Circuit at the Gate Level Listing 2: Simple Program in Verilog Modeling a Circuit using Data Flow 3.5. As seen above, the outputs come first in the port list followed by the inputs. Single line comments begin with // Multi-line comments are enclosed by /*...*/ Verilog is case sensitive. 3.6. A simple program modeling a circuit using dataflow is provided in Listing 2. 3.7. You can use identities describing multiple bits known as vectors. Given an identifier [7:0]X you can assign value by: Where the 8 b specifies that we are defining an 8 bit binary number and 00001111 is that 8 bit binary number. You can also assign parts of the number as:

Which assigns only the last bits 2-0 of X. 4 Supplement: Writing Bad Code A discussion of poor and incorrect coding practices will follow, with emphasis on how to correct the mistakes. For purposes of discussion the ill-written code in Listing 3 will be discussed. Listing 3: Example of Bad Code 4.1 The first line of Bad Code in Listing 3 can either be revised to Listing 4 or Listing 5. Listing 4: Revision I of Bad Code (Line 1) Listing 5: Revision II of Bad Code (Line 1) 4.2. The fist line of Bad Code (Listing 4) is necessary when using input and output variables inside a module. Wire (which are neither inputs, nor outputs) should be defined as seen in Listing 6. Listing 6: Definition of Wires 4.3. Whenever a variable (wire) is being given a value, the assign keyword must precede the variable being set and the associated logic. Revision of Bad Code (Listing 4) lines 3-6 can be seen in Listing 7. Listing 7: Proper Usage of Assign Operator 4.4. The module should be closed with the endmodule keyword. A proper revision of the code from Listing 3 is as follows in the Listing 8.

Listing 8: Corrected Implementation of Bad Code 5 Suplement: Altera Quartus In order to implement the circuits that you will design on the FPGA, there are a few key steps. 5.1 Starting a new Project 5.1.1. Click New Project Wizard. 5.1.2. Set the directory name. Make sure that you create a new folder/directory for each project and do not copy the directory over. 5.5.3. Set the name of the project. Naming each project after the number of the lab is a good idea, e.g., Lab_1_HalfAdder. 5.5.4. Click Yes to create a directory if it does not exist. 5.5.5. You can add existing files if you already have them, otherwise select Next. 5.5.6. Next you need to specify the device that you are using. The device family we are using is the Cyclone IV E and the device is the EP4CE22F17C6 5.5.7. Click Next. 5.5.8 Click Finish. 5.2 Writing the Code 5.2.1. Select File > New or Ctrl + N. 5.2.2. Choose Verilog HDL File. 5.2.3. Click Ok. 5.2.4. Select File > Save As. NOTE: The name of the file should be the name of the Project. Also, the name of the main module needs to be the same name as the file. 5.2.5. Choose Save as type, and select Verilog HDL File. 5.2.6. Put a check mark in the box Add file to current project. Unless the file is part of the project you won t be able to proceed. If you do not add the file now you can always add it later by selecting Project > Add/Remove Files to Project.

5.2.7. Click Save. Now you are ready to type your program. 5.3 Compiling 5.3.1 To compile your code, you can either go to Processing > Start Compilation, click the play icon on the toolbar, or use Ctrl + L. 5.3.2. You can click on Processing > Compilation Report to see the results of the compilation. 5.3.3. If there are no errors, then your program s syntax is correct. This does not mean that your program will do what you want because you may have some logic errors. Note: Warnings will not stop your code from compiling but may contain helpful information for diagnosing logical issues. 5.4 Pin Assignment Assigning the pins on the FPGA allows the user to interface with the hardware and confirm that their code works as intended. Some pins have already been internally wired to the LEDs and push buttons on the board. A list of those pins is provided in Table 1. Be sure the selected device is the Cyclone IV E: EP4CE22F17C6. 5.4.1. Go to Assignments > Pin Planner or Ctrl + Shift + N. 5.4.2. Under Filter select Pins: all. 5.4.3. After successful compilation your input/outputs should already be listed but not assigned. If you are missing a node, double click <<new node>>; a drop-down menu should appear to add an input/output. Select the input/output you want to assign. 5.4.4. In the column labeled Location, select the pin you want to assign to that input/output node. Table 1 shows the locations of the hardwired pins for your evaluation board. For example: To connect output C to the LED7, you would select Location Pin L3 for Node C. 5.4.5. Repeat Steps 3 and 4 until all inputs/outputs are assigned for your circuit. 5.4.6. The Altera default is that all unused pins should be assigned As outputs driving ground. This is a good choice for pins not connected to anything (it reduces power and noise), but is not good for pins that may be connected to a clock input you would then have both the clock and the Altera chip trying to drive this input. A safer choice is to define all unused pins As input tri-stated with weak pull up resistor. Go to Assignments > Device. Click on Device and Pin Options. Select the Unused Pins tab.

From the Reserve all unused pins drop-down menu, select As input tri-stated with weak pull-up resistor. Table 1: Pin Assignments for the LEDs, Push Buttons, DIP-Switches, and Clock inputs 5.5 Simulating the Designed Circuit Once you have assigned places for the inputs and the outputs as well as values for the inputs, you can simulate the circuit. The simulation of the circuit can be done in two modes: Functional and Timing. The Functional Simulation checks that the logic for your function is working correctly. The Timing Simulation runs the simulation with the delay in the gates included. In simulating your circuit there are four main steps: Create a waveform file. Select your inputs and outputs. Create a waveform for each input. Run the simulation to generate the output for verification with your expected results. A more detailed explanation of the above steps is described below. Select File > New. Click on University Program VWF.

Click Ok. Save the file using some meaningful name; the name of the lab is a good idea, i.e. Lab_1_HalfAdder.vwf. Right-click below Name and select Insert Node or Bus. Click on Node Finder and click List. This should bring all the outputs and inputs onto the Nodes Found list. Use >> to move all the nodes to the Selected Nodes Side. Click Ok and Ok again. Set the desired simulation time by selecting Edit > End Time. Select View > Fit in Window. Select the inputs and outputs you want to observe by clicking Edit > Insert > Insert Node or Bus. Click on Node Finder. Click on the input/output you want to observe by clicking on the > sign. Repeat this process for all your inputs/outputs. The next step is to specify the logic value of each of the inputs you have selected and duration of that value by right clicking on the input and selecting Value > *your selected value* Save the file, e.g. Lab_1_HalfAdder.vwf. After the waveforms have been defined, we can simulate our circuit. First perform the functional simulation, and then perform the timing. Click Start Functional Simulation or Start Timing Simulation at the top of the window. 5.6 Programing the FPGA The final step is to program the FPGA with the circuit you designed. Be sure the correct device is selected before continuing. 5.6.1 Select Tools > Programmer. 5.6.2. Select JTAG in the Mode box.

5.6.3. If USB Blaster is not chosen in the box next to Hardware Setup, select by clicking on the Hardware Setup. Then click on USB-Blaster, the Close. 5.6.4. You should see a file listed with extension.sof, if not add it from Output. 5.6.5. Finally, press Start. The program will download on your board and once it is finished you can test your circuit in hardware.