Lab 1: Introduction to Verilog HDL and the Xilinx ISE

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

Lab 2: Introduction to Verilog HDL and Quartus

EE 231 Fall EE 231 Lab 2

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!

Tutorial: Working with the Xilinx tools 14.4

EE 1315 DIGITAL LOGIC LAB EE Dept, UMD

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

Circuit design with configurable devices (FPGA)

ECE 4305 Computer Architecture Lab #1

University of Hawaii EE 361L. Getting Started with Spartan 3E Digilent Basys2 Board. Lab 4.1

Xilinx Schematic Entry Tutorial

Logic Implementation on a Xilinx FPGA using VHDL WWU Linux platform assumed. rev 10/25/16

Lab 6 : Introduction to Verilog

Programming Xilinx SPARTAN 3 Board (Simulation through Implementation)

Xilinx Tutorial Basic Walk-through

Getting Started with Xilinx WebPack 13.1

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

Xilinx ISE Simulation Tutorial

Xilinx ISE Synthesis Tutorial

Getting started with the Xilinx Project Navigator and the Digilent BASYS 2 board.

Tutorial: ISE 12.2 and the Spartan3e Board v August 2010

An easy to read reference is:

CECS LAB 1 Introduction to Xilinx EDA Tools

Step 1: Downloading the source files

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

Logic Implementation on a Xilinx FPGA using VHDL WWU Linux platform assumed. rev 11/01/17

Verilog Design Entry, Synthesis, and Behavioral Simulation

Banks, Jasmine Elizabeth (2011) The Spartan 3E Tutorial 1 : Introduction to FPGA Programming, Version 1.0. [Tutorial Programme]

ENGN 1630: CPLD Simulation Fall ENGN 1630 Fall Simulating XC9572XLs on the ENGN1630 CPLD-II Board Using Xilinx ISim

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

Xilinx Project Navigator Reference Guide

Department of Electrical and Computer Engineering Xilinx ISIM <Release Version: 14.1i> Simulation Tutorial Using Verilog

After opening the Programs> Xilinx ISE 8.2i > Project Navigator, you will come to this screen as start-up.

Building Combinatorial Circuit Using Behavioral Modeling Lab

TUTORIAL #2 HIERARCHICAL DESIGNS AND TEST FIXTURES

ECE 491 Laboratory 1 Introducing FPGA Design with Verilog September 6, 2004

2IN35 VLSI Programming Lab Work Assignment 1: Hardware design using Verilog

PlanAhead Software Tutorial

Introduction to Verilog

Board-Data Processing. VHDL Exercises. Exercise 1: Basics of VHDL Programming. Stages of the Development process using FPGA s in Xilinx ISE.

ISE Design Suite Software Manuals and Help

Tutorial on FPGA Design Flow based on Aldec Active HDL. Ver 1.5

Hardware Description Languages (HDLs) Verilog

Introduction. About this tutorial. How to use this tutorial

4. Verify that HDL is selected as the Top-Level Source Type, and click Next. The New Project Wizard Device Properties page appears.

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0

Implementing a Verilog design into the UWEE CPLD Development Board Using Xilinx s ISE 7.1i Software: A Tutorial

PINE TRAINING ACADEMY

Programmable Logic Design I

Circuit Design and Simulation with VHDL 2nd edition Volnei A. Pedroni MIT Press, 2010 Book web:

Xilinx ISE8.1 and Spartan-3 Tutorial EE3810

Tutorial on FPGA Design Flow based on Xilinx ISE WebPack and ModelSim. ver. 2.0

The board is powered by the USB connection, so to turn it on or off you plug it in or unplug it, respectively.

To practice combinational logic on Logisim and Xilinx ISE tools. ...

EE 1315: DIGITAL LOGIC LAB EE Dept, UMD

TLL5000 Electronic System Design Base Module

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

Lab 2 Verilog Synthesis & Logic Optimization

Using Synplify Pro, ISE and ModelSim

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

Tutorial on FPGA Design Flow based on Xilinx ISE Webpack andisim. ver. 1.0

Tutorial for Altera DE1 and Quartus II

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

Nexys 2/3 board tutorial (Decoder, ISE 13.2) Jim Duckworth, August 2011, WPI. (updated March 2012 to include Nexys2 board)

Tutorial on Quartus II Introduction Using Verilog Code

Introduction to Nexys 2 board - Detour Signal Lab

Verilog Simulation Mapping

475 Electronics for physicists Introduction to FPGA programming

RTL Design and IP Generation Tutorial. PlanAhead Design Tool

ELEC 204 Digital System Design LABORATORY MANUAL

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

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 1

Xilinx ISE8.1 and Spartan-3 Tutorial (Prepared by Kahraman Akdemir based on Professor Duckworth's Tutorials updated September 2006)

Tutorial on FPGA Design Flow based on Aldec Active HDL. Ver 1.5

Laboratory of Digital Circuits Design: Design, Implementation and Simulation of Digital Circuits Using Programmable Devices

Lab 2: Barrel Shifter Design

Vivado Tutorial. Introduction. Objectives. Procedure. Lab Workbook. Vivado Tutorial

ELEC 4200 Lab#0 Tutorial

Lab 7 (Sections 300, 301 and 302) Prelab: Introduction to Verilog

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

Quick Front-to-Back Overview Tutorial

EET2141 Project 2: Binary Adder Using Xilinx 7.1i Due Friday April 25

ISE Simulator (ISim) In-Depth Tutorial. UG682 (v 13.1) March 1, 2011

Lab 6: Intro to FPGAs

COS/ELE 375 Verilog & Design Tools Tutorial

EE 101 Lab 5 Fast Adders

Verilog Module Tutorial By TA Brian W. Stevens CMPE415 UMBC Spring 2015 Dr. Tinoosh Mohsenin

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.

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

NIOS CPU Based Embedded Computer System on Programmable Chip

The Alarm System: The alarm system to be designed has the following inputs.

A B A+B

Tutorial: Working with Verilog and the Xilinx FPGA in ISE 9.2i

Tutorial on Quartus II Introduction Using Schematic Designs

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

Chip Design with FPGA Design Tools

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

Laboratory #Intro to Xilinx ISE and CR-2 Kit ECE 332

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

Transcription:

EE 231-1 - Fall 2016 Lab 1: Introduction to Verilog HDL and the Xilinx ISE Introduction In this lab simple circuits will be designed by programming the field-programmable gate array (FPGA). At the end of the lab an understanding of the process of programming a programmable logic device (PLD) should be attained, and an understanding of the advantages of such an approach over using discrete components should be gained. 1 Prelab 1.1. Read the material provided in the supplement(s) (Sections 3,4,5.) 1.2. What is a half adder? Explain in terms of input and output signals. 1.3. Using the schematics of the board (Figure 1), if the FPGA sends a logic 1 to one of the LEDs, would it turn on or off? LD0 LD1 LD2 LD3 390Ω 390Ω 390Ω 390Ω LD0 LD1 LD2 LD3 Figure 1: CHMOD-S6 LEDs 2 Lab 2.1. Write a gate level Verilog program to implement the half adder circuit in Figure 2. X Y S C Figure 2: Half Adder Circuit

EE 231-2 - Fall 2016 2.2. Assign your two inputs to be the two push buttons on the board and your two outputs to be the two of the LEDs on the board. Before you continue, ask the TA to check your assignment. 2.3. Perform both functional (Behavioral) and timing (Post-Route) 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 specify 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 the inputs and outputs to the previous half-adder. Send signals to the LEDs to have them off when you send a logic 0 and turn on when you send them a logic 1. Similarly, set 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 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 3.4. A simple program modeling a circuit (Figure 3) at the gate level is described below as Listings 1,2.

EE 231-3 - Fall 2016 A B G1 w1 G3 D C G2 E Figure 3: Simple Modeled Circuit Listing 1: Simple Program in Verilog Modeling a Circuit at the Gate Level 1 module simple_circuit(output D,E, input A,B,C); 2 wire w1; // Creating a virtual wire 3 and G1(w1,A,B); // Creates AND gate with output w1 and inputs A and B 4 not G2(E,C); // Creates NOT gate output E and input C 5 or G3(D,w1,E); // Creates OR gate with output D and inputs w1 and E 6 endmodule Listing 2: Simple Program in Verilog Modeling a Circuit using Data Flow 1 module simple_circuit(output D,E, input A,B,C); 2 wire w1; // Creating a virtual wire 3 assign w1 = A & B; // Creates AND gate with output w1 and inputs A and B 4 assign E = ~C; // Creates NOT gate output E and input C 5 assign D = w1 E; // Creates OR gate with output D and inputs w1 and E 6 endmodule 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 values by: 1 assign [7:0] X = 8 b00001111; 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: 1 assign [2:0]X = 3 b101; Which assigns only to 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.

EE 231-4 - Fall 2016 Listing 3: Example of Bad Code 1 module Bad code(abcd,ef); 2 wire1; Define Wire 3 assign w1=c // Assign W1 to input C; 4 asign D = A & B; // Assign D as OR gate with C, A 5 aign E = B C; /XOR gate 6 assign F = A ^ 1w; // AND gate 7 end modules 4.1. The first line of Bad Code (Listing 4) can either be revised to Listing 4 or Listing 5. Listing 4: Revision I of Bad Code (Line 1) 1 module BadCode(input A,B,C, output D,E,F); Listing 5: Revision II of Bad Code (Line 1) 1 module BadCode(A,B,C,D,E,F); 2 input A,B,C; 3 output D,E,F; 4.2. The first line of Bad Code (Listing 4) is necessary when using input and output variables inside a module. Wires (which are neither inputs, nor outputs) should be defined as seen in Listing 6: 1 wire w1; Listing 6: Definition of Wires 4.3. Whenever a variable (wire) is being given a value, The assign keyword must preceede 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 1 assign w1 = C; //Assign w1 as C; 2 assign D = A & B; // Assign D as AND of A, B 3 assign E = C B; // Assign E as OR of B, C 4 assign F = A ^ w1; // Assign F as XOR of A, w1 4.4. The module should be closed with the endmodule keywork. A proper revision of the code from Listing 3 is as follows in Listing 8: Listing 8: Corrected Implementation of Bad Code 1 module BadCode(input A, B, C, output D, E, F); 2 wire w1; // Define Wire 3 assign w1 = C; // Assign W1 to input C 4 assign D = A & B; // Assign D as AND of A, B 5 assign E = B C; // Assign E as OR of B, C 6 assign F = A ^ w1; // Assign F as XOR of A, w1 7 endmodule 5 Supplement: Xilinx ISE To implement the circuits that you will design on the FPGA there are a few key steps.

EE 231-5 - Fall 2016 5.1 Start a new Project 5.1.1. Select File, then choose New Project. 5.1.2. Set the name of the project. Make the name descriptive, not just lab name (e.g. Lab 1,) but Lab 1 HalfAdder. 5.1.3. Set the Working Directory. This should be a folder to contain all of your projects. A sub-folder of the same name as the project will be created for the project to work within. 5.1.4. Ensure the Top-level source type is set to HDL, then Click Next to specify project settings. 5.1.5. Specify the device that you are using, and VHDL Standard. The device family we are using is the Spartan6 and the device is an XC6SLX4 in a CPG196 package with speed class of -2. Additionally, it is recommended that the VHDL Standard be set to VHDL-200X. 5.1.6. Click Next to see a project summary, then Click Finish. 5.2 Writing the Code 5.2.1. Right-Click in the Empty View and choose New Source, note the icon. 5.2.2. Choose Verilog Module and specify a file name. 5.2.3. Click Next, then specify inputs and outputs if known. 5.2.4. Click Next to see a summary, then choose Finish. Now you are ready to type in your program. 5.3 Compiling 5.3.1. Select Process, then Implement Top Module. Note the icon. It (the play icon) also shows up on the toolbar. 5.3.2. On the Design tab, you can click on Design Summary/Reports to see the results of the compilation. Additionally, as part of the Synthesize - XST are Schematic Views. 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; you may have some logic errors.

EE 231-6 - Fall 2016 Table 1: CMOD-S6 Feature Assignments Special Wire FPGA Pin Button 0 BTN0 P8 Button 1 BTN1 P9 1 Hz Clock FPGA-LFC N7 8 MHz Clock FPGA-GCLK N8 LED 0 LD0 N3 LED 1 LD1 P3 LED 2 LD2 N4 LED 3 LD3 P4 5.4 Pin Assignment You need to specify which inputs and outputs. 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. 5.4.1. Select Tools, PlanAhead, then I/O Pin Planning...Pre-Synthesis. 5.4.2. Expand the Ports Sections. 5.4.3. Set Desired pin according to Tables 1,2 in the Site form. 5.4.4. Repeat previous step until all pins are assigned. 5.4.5. Save Constraints (CTRL + S) 5.4.6. Xilinx defaults all unused pins to weak pull-down. 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 then have both the clock and the chip trying to drive this input. A safer choice is to define all unused pins As float. Change this setting as follows: 5.4.6.1. Within the ISE Project Navigator window right-click Generate Programming File in the process pane and choose Process Properties... 5.4.6.2. Browse to Configuration Options 5.4.6.3. Specify Unused IOB Pins as float 5.5 Simulating the Designed Circuit Simulation is a synthetic test of functionality such as seen in Figure 4. It is used to validate portions of designs prior to moving them to hardware, which can be a costly and time consuming process. Instead, first a design is validated using models and simulations, then final development is carried out on discrete hardware. There are two types of modes that we are concerned with: 1) Behavioral (Functional): we are not worried about the delays and we are interested to make sure that logically the

EE 231-7 - Fall 2016 0 ns 1 ns 2 ns 3 ns 4 ns 5 ns 6 ns 7 ns Figure 4: Functional Simulation circuit is working. 2) Timing (Post-*): we simulated the circuit and include the delays in all the gates. First perform the functional simulation, and then perform the timing. When simulating the circuit you need to figure out the waveforms for the inputs that will make you confident that your circuit works. If you have a simple circuit, you can easily test all the possibilities. As the circuit gets more and more complicated you will need to figure out a scheme to verify its operation. In simulating your circuit there are four main steps, and they are as follows: Create a Verilog Test Fixture. Specify a waveform for each input. Run the simulation to generate the output for verification. Verify results are consistent with what is expected. These steps can be achieved according to the following steps: 5.5.1. Right-Click in the Hierarchy and choose New Source, note the icon. 5.5.2. Choose Verilog Test Fixture and specify a file name. 5.5.3. Click Next, then specify the verilog file to be tested. 5.5.4. Click Next to see a summary, then choose Finish. 5.5.5. Note the first line is a time-scale shown as length of time unit/simulator precision. Modify the first line of code to reflect a more accurate operational frequency. Such an example is seen in Listing 9. 1 timescale 10ns / 1ps Listing 9: Verilog Time Scale 5.5.6. The Test Fixture is a full Verilog environment, but the simplest way to use it is to specify the input values, and how long to wait before changing them (in integer multiples of the major time unit) inside the always block, seen below in Listing 10. Listing 10: Brute-Force Assignment within Verilog Test Fixture 1 initial begin 2 sw0 = 0; 3 sw1 = 0; 4 #1; 5 sw0 = 1;

EE 231-8 - Fall 2016 6 #2; 7 sw0 = 0; 8 sw1 = 1; 9 #2; 10 sw0 = 1; 11 sw1 = 1; 12 end The code sets sw0, sw1 to 0, waits 1 time-unit, then sets sw0 to 1. It waits another 2 time-units, then sets sw0 to 0 and sw1 to 1. The program, then, waits another 2 time-units before setting sw0 and sw1 to 1. 5.5.7. Of additional note is a simple way to generate a clock signal. Append the code shown in Listing 11 to your Test Fixture to generate a clock with period of two time-units. 1 always 2 #1 clk = ~clk; Listing 11: Simple Clock Source in a Verilog Test Fixture 5.5.8. Save the Test Bench and switch view: from Implementation to Simulation. Note: The Drop-Down labeled Behavioral can be used to specify the type of simulation used. 5.5.9. Click on the Test Bench in the Hierarchy panel, then expand ISim Simulator shown in the Processes pane. 5.5.10. Double-Click...Check Syntax to validate your code. 5.5.11. Double-Click Simulate... to run the simulation. 5.5.12. ISim will launch with your simulation results. It is likely the simulation will need to be zoomed out to appreciate the results. 5.6 Programming the FPGA The final step is to program the FPGA with your designed circuit. Be sure the correct device is selected. 5.6.1. Ensure you are in the Implementation view, then select your desired code. 5.6.2. Under the process pane, double-click Implement Design. 5.6.3. Then, double-click Generate Programming File. 5.6.4. Double-click Configure Device which will Launch impact. 5.6.5. Double-click Create PROM File. 5.6.6. Choose Xilinx Flash/PROM, then click the green arrow. 5.6.7. Choose Auto Select PROM.

EE 231-9 - Fall 2016 5.6.8. Assign a File Name, and Specify the Output File Location to the project directory. 5.6.9. Select the *.bit file generated in the first step as input. 5.6.10. Do NOT add additional devices. 5.6.11. Double-Click Generate File... 5.6.12. Go to Boundary Scan by clicking on it. 5.6.13. Right-Click and choose Add Xilinx Device 5.6.14. Specify the *.bit file created earlier 5.6.15. Double-Click the SPI/BPI box and specify the *.mcs file 5.6.16. Specify SPI PROM S25FL128S and press Ok. 5.6.17. Click on the Xilinx FPGA icon to program Note: Clicking on the FLASH icon will program the device to persist after power cycling, but takes significantly longer. 5.6.18. Double-Click Program

EE 231-10 - Fall 2016 Table 2: CMOD-S6 DIP Assignments DIP Pin FPGA Pin Wire Wire FPGA Pin DIP Pin 1 P5 PIO01 PIO48 M2 48 2 N5 PIO02 PIO47 M1 47 3 N6 PIO03 PIO46 L2 46 4 P7 PIO04 PIO45 L1 45 5 P12 PIO05 PIO44 K2 44 6 N12 PIO06 PIO43 K1 43 7 L14 PIO07 PIO42 J2 42 8 L13 PIO08 PIO41 J1 41 9 K14 PIO09 PIO40 G2 40 10 K13 PIO10 PIO39 G1 39 11 J14 PIO11 PIO38 H2 38 12 J13 PIO12 PIO37 H1 37 13 H14 PIO13 PIO36 F2 36 14 H13 PIO14 PIO35 F1 35 15 F14 PIO15 PIO34 E2 34 16 F13 PIO16 PIO33 E1 33 17 G14 PIO17 PIO32 D2 32 18 G13 PIO18 PIO31 D1 31 19 E14 PIO19 PIO30 C1 30 20 E13 PIO20 PIO29 B1 29 21 D14 PIO21 PIO28 A2 28 22 D13 PIO22 PIO27 B3 27 23 C13 PIO23 PIO26 A3 26 24 VU GND 25