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

Similar documents
CPEN 230L: Introduction to Digital Logic Laboratory Lab 7: Multiplexers, Decoders, and Seven Segment Displays

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

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

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

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

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

Verilog Design Entry, Synthesis, and Behavioral Simulation

Tutorial: Working with the Xilinx tools 14.4

JEE2600 INTRODUCTION TO DIGITAL LOGIC AND COMPUTER DESIGN. ModelSim Tutorial. Prepared by: Phil Beck 9/8/2008. Voter Function

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

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

Lab 6 : Introduction to Verilog

ECE 152A LABORATORY 2

Lab 6 : Introduction to Verilog

Introduction to Verilog

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

University of California, Davis Department of Electrical and Computer Engineering. EEC180B DIGITAL SYSTEMS Spring Quarter 2018

Tutorial: ISE 12.2 and the Spartan3e Board v August 2010

Introduction to Simulation of VHDL Designs Using ModelSim Graphical Waveform Editor. 1 Introduction. For Quartus Prime 16.1

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

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

How to Customize the ModelSim Wave View in the Altera Quartus Simulation Flow

CSEE W4840 Embedded System Design Lab 1

VeriLogger Tutorial: Basic Verilog Simulation

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

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

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

CECS LAB 1 Introduction to Xilinx EDA Tools

EXPERIMENT NUMBER 7 HIERARCHICAL DESIGN OF A FOUR BIT ADDER (EDA-2)

Step 1: Downloading the source files

Xilinx Schematic Entry Tutorial

Hardware Description Languages (HDLs) Verilog

EE 330 Spring Laboratory 2: Basic Boolean Circuits

Actel Libero TM Integrated Design Environment v2.3 Structural Schematic Flow Design Tutorial

Xilinx Tutorial Basic Walk-through

LAB 6 Testing the ALU

FPGA Introductory Tutorial: Part 1

UNIVERSITI MALAYSIA PERLIS

Getting Started with Xilinx WebPack 13.1

ENSC 350 ModelSim Altera Tutorial

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

Verilog Lab. Two s Complement Add/Sub Unit. TA: Xin-Yu Shi

SCHEMATIC DESIGN IN QUARTUS

Lab 2: Introduction to Verilog HDL and Quartus

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

Chapter 2 Getting Hands on Altera Quartus II Software

Lecture 1: Introduction Course arrangements Recap of basic digital design concepts EDA tool demonstration

AccelDSP tutorial 2 (Matlab.m to HDL for Xilinx) Ronak Gandhi Syracuse University Fall

Tutorial on Quartus II Introduction Using Verilog Code

EE 330 Laboratory Experiment Number 11

Speaker: Shao-Wei Feng Adviser: Prof. An-Yeu Wu Date: 2010/09/28

Multi cycle Processor Modification

Hardware/Software Codesign for Wireless Systems (E168b) Lab 2: GPS Correlator

Introduction to Computer Engineering (E114)

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

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

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

Lab 1: Introduction to Verilog HDL and the Xilinx ISE

Using Synplify Pro, ISE and ModelSim

Lab 1 Modular Design and Testbench Simulation ENGIN 341 Advanced Digital Design University of Massachusetts Boston

FPGA Design Tutorial

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

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

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Generating Parameterized Modules and IP Cores

EE 361L Digital Systems and Computer Design Laboratory

EXPERIMENT 1. INTRODUCTION TO ALTERA

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

Icarus Verilog HDL (iverilog)

EE 231 Fall EE 231 Lab 2

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

Experiment VERI: FPGA Design with Verilog (Part 2) (webpage: /)

CSEE W4840 Embedded System Design Lab 1

Quartus II Introduction Using Verilog Design

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Introduction to Verilog and XILINX

A3 A2 A1 A0 Sum4 Sum3 Sum2 Sum1 Sum

CSEE W4840 Embedded System Design Lab 1

ELEC 204 Digital System Design LABORATORY MANUAL

INTRODUCTION TO DE2 SYSTEM INTERFACES

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

Engineering 303 Digital Logic Design Fall 2018

EE 101 Lab 5 Fast Adders

EE 330 Laboratory Experiment Number 11 Design and Simulation of Digital Circuits using Hardware Description Languages

Quick Tutorial for Quartus II & ModelSim Altera

EE108a Lab 0: Introduction to Verilog and the EE108a tool chain, version 1.01

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

Vivado Tutorial. Introduction. Objectives. Procedure

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

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

ENGR 5865 DIGITAL SYSTEMS

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

Introduction to Verilog HDL

Lab 2: Barrel Shifter Design

5 January ModelSim v5.7 Quick Reference Guide

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

Digital Circuit Design Using Xilinx ISE Tools

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

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

Transcription:

CPEN 230L: Introduction to Digital Logic Laboratory Lab #6: Verilog and ModelSim Purpose Define logic expressions in Verilog using register transfer level (RTL) and structural models. Use Quartus II to synthesize the Verilog logic expressions into logic gates that get fitted into a FPGA. Use ModelSim with Verilog to simulate and debug the operation of the digital circuits designed. Background In previous labs we defined digital logic designs using truth tables, logic expressions, and schematic diagrams. In this lab and those following, we will use the Verilog Hardware Description Language (HDL) to define, build (a.k.a. synthesize), and test digital logic. To synthesize the logic expressions written in Verilog into logic gates that get fitted into a FPGA we will use Quartus II. To test the correct operation of the circuit we will simulate its behavior using ModelSim. In digital logic terminology, the circuit to be verified is called a Device Under Test (DUT) or Unit Under Test (UUT). The environment used to verify the DUT is called a test bench. A test bench has two parts: Input vectors or stimulus to drive the DUT inputs. For example, in the case of a full adder the eight possible input combinations would be the input vectors. Output monitoring to observe DUT outputs. These observations are normally a truth table and/or timing diagrams. For example, in the case of a full adder CarryOut and SumOut would be monitored. Part 1: Combinational Logic Design using Verilog and ModelSim Pre-lab: Read and thoroughly understand textbook pages 68-78 Introduction to Verilog. Knowing this now will make the rest of the semester go much smoother. Quickly skim textbook Appendix A Verilog Reference. You need to know where to find this information when you need it. Most important are pages 685-703. Next most important are pages 709-712 and 725-731 (skipping Figure A.40 and A.41). The rest is less important to this class. Read and understand the Verilog code below. o Create files logicmistery_tb.v and logicmistery.v containing the provided code. o Compile and execute the code using Icarus Verilog. You should see a truth table. What logic expression is being implemented by module logicmistery? Make a truth table showing output d for all possible inputs a, b and c. Page 1 of 5

// CPEN 230L Lab 6a, testbench for module logicmistery // File: logicmistery_tb.v module logicmistery_tb; reg a, b, c; wire d; reg [2:0] count; // test bench, so no inputs/outputs // inputs to the DUT // output from the DUT // 3-bit value to help generate DUT inputs logicmistery DUT(d, a, b, c); // instantiate the DUT initial begin count = 3'b0; // initialize count to 000 binary $display("time a b c d"); // truth table header $monitor("%4d %2d %1d %1d %2d", // output formatting $time, a, b, c, d); // signals to be output #40 $finish; // time goes 0 to 40 in steps of 5, then ends end always begin {a, b, c} = count; // 3-bit count goes to 1-bit a, b, c #5 count = count+1; // increment count every 5 time ticks end endmodule // CPEN 230L Lab 6a, Combinational Logic // File: logicmistery.v module logicmistery(w, X, Y, Z); output W; input X, Y, Z; // RTL model assign W = (X!Y) && Z; endmodule During-Lab do the following to simulate the Verilog design using ModelSim: A. Create folder \Documents\CPEN230L\Lab6\Lab6a\. B. Use ModelSim to create a Project. Select File -> New -> Project. This opens the Create Project dialog window. a. Set the Project Name to be logicmistery_tb. b. Set the Project Location to be folder Lab6a that you created above. c. Leave the Default Library Name set to "work". d. Click OK. You should see an Add items to the Project window. C. Create a testbench file. a. In the Add items to the Project window, click Create New File. b. In the resulting Create Project File window, enter File Name logicmistery_tb and Add file as type Verilog. Click OK. The new design file will appear in the project window. Click Close to close the Add items to the Project window. c. Double click the logicmistery_tb.v file. You will see another window that allows you to input your Verilog statements. This is ModelSim s plain text editor. Page 2 of 5

d. Copy the Verilog code for module logicmistery_tb above (not including the module logicmistery code) to the input window. This is your testbench code. e. Select File > Save. D. Create a new Verilog file that will contain module logicmistery, the circuit to be tested. a. Select File -> New -> Source -> Verilog to create a new Verilog file. b. Copy the Verilog code for module logicmistery into the Verilog file window. c. Select File -> Save and save file logicmistery.v. d. Notice that top-level menu options can change depending on the active window pane. For example, when the logicmistery.v editing pane is active there is a Source menu option at the top of ModelSim. Click in the Project pane and see the Source menu option change to a Project menu. e. Select Project -> Add to Project -> Existing File. You will see the Add file to Project dialog window which allows you to add a file to the current project. f. Click Browse and then select logicmistery.v. g. Click Open. On the Add file to Project window click OK. You should have 2 files in your Project, logicmistery_tb.v and logicmistery.v. In the Project pane Status column the question marks mean the files haven t been compiled into the project or the source has changed since the last compile. h. Compile the files. Select Compile -> Compile All or right click in the Project pane and select Compile -> Compile All. In the transcript window you should see 2 compiles, 0 failed with no errors. F. Start simulation. a. Click the Library tab to see a window of all library units with work at the top. Expand work by clicking the + in front of it. Right-click on logicmistery_tb and select Simulate. Right-click in the window where you see simulation signals a, b, c, count and d. Select Add to -> Wave -> Signals in Region. b. In the Wave pane, drag /logicmistery_tb/count to the top so the waveforms are in order from top to bottom: count, a, b, c, d. c. In the Run Length entry near the top of the user interface, change simulation time to 10 ms. d. Click on the Run button to the right of 10 ms and see a Finish Vsim pop-up asking Are you sure you want to finish? Answer No. e. If the waveforms are not visible, display them by clicking on the Wave tab. Right-click in the Wave window to see zoom options and select Zoom Full. You should see similar to the images below. Click any location under the waveforms and you will see a thick yellow line. Click different locations and observe the change in value of variables on the left. Also notice that the Transcript window contains the output of the $display and $monitor statements in the logicmistery_tb.v Verilog code. It shows the values of inputs and outputs as they change state. f. Do a screen capture to the entire ModelSim window. G. Include two images like these in your lab report. Transcript pane showing the resulting truth table Waveforms showing count, derived inputs a,b,c, and output d Page 3 of 5

Part 2: Majority Gate Design using Verilog and ModelSim Pre-lab: Write Verilog code to describe a 3-input majority gate using an RTL model. Put your code in file majority.v. Use the code in file logicmistery.v code as a starting point. The first lines of any Verilog file you write for this lab should be similar to this: // CPEN 230L Lab 6 part 2, Majority Gate using RTL coding style // File: majority.v Create file majority_tb.v to test module majority. Use the code in file logicmistery_tb.v as a starting point. o Debug majority_tb.v and majority.v using Icarus Verilog. Your code should include comments similar to the sample code above. A good guideline is to remember that your target reader is a student that hasn t done the lab and is learning from your code. Use comments to describe both what you are doing and more importantly why. During-Lab Create directory majority_tb and ModelSim Project majority_tb to simulate and test module majority. Verify that the simulation waveforms and Transcript window output are as you expected. Show your code and results to your lab instructor. Implement any change suggestions made and remember them for similar future efforts. In your lab report, include Wave and Transcript pane images similar to the examples above. Also include your well-commented well-formatted source code as described in the Lab Report Template. Page 4 of 5

Part 3: Full Adder Design using Verilog and ModelSim Pre-Lab Write Verilog code in file fulladder.v to describe a full adder using an RTL model. In file fulladder_tb.v create test bench code for module fulladder. o Debug fulladder_tb.v and fulladder.v using Icarus Verilog. During-Lab Create directory Lab6c and ModelSim Project fulladder_tb to simulate and test module fulladder. Verify that the simulation waveforms and Transcript window output are as you expected. In your lab report, include Wave and Transcript pane results similar to the examples above. Also in case you made any change to your prelab Verilog code make sure to include your new Verilog code. Exit ModelSim and take a backup copy of all your files with you. Pre-Lab Deliverables Before the lab starts, please hand in the following documents: Part 1 A snapshot of the table generated compiling and executing the files logicmistery.v and logicmistery_tb.v Part 2 majority.v and majority_tb.v A snapshot of the table generated Part 3 fulladder.v and fulladder_tb.v A snapshot of the table generated NOTE: The penalty for not handing in the prelab deliverables is 50% of the lab grade Page 5 of 5