Project 1: ModelSim Tutorial and Verilog Basics

Similar documents
Lab 1: Full Adder 0.0

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

Xilinx ISE. <Release Version: 10.1i> Tutorial. Department of Electrical and Computer Engineering State University of New York New Paltz

Two's Complement Adder/Subtractor Lab L03

VHDL Test Bench Tutorial

Lab 1: Introduction to Xilinx ISE Tutorial

Lesson 1 - Creating a Project

Cadence Verilog Tutorial Windows Vista with Cygwin X Emulation

Quartus II Introduction Using VHDL Design

Software Version 10.0d Mentor Graphics Corporation All rights reserved.

EXPERIMENT 4. Parallel Adders, Subtractors, and Complementors

Let s put together a Manual Processor

Start Active-HDL by double clicking on the Active-HDL Icon (windows).

ModelSim-Altera Software Simulation User Guide

earlier in the semester: The Full adder above adds two bits and the output is at the end. So if we do this eight times, we would have an 8-bit adder.

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

Appendix K Introduction to Microsoft Visual C++ 6.0

LAB #3 VHDL RECOGNITION AND GAL IC PROGRAMMING USING ALL-11 UNIVERSAL PROGRAMMER

Life Cycle of a Memory Request. Ring Example: 2 requests for lock 17

Digital Circuit Design Using Xilinx ISE Tools

TortoiseGIT / GIT Tutorial: Hosting a dedicated server with auto commit periodically on Windows 7 and Windows 8

Getting Started Using Mentor Graphic s ModelSim

Jianjian Song LogicWorks 4 Tutorials (5/15/03) Page 1 of 14

EasyC. Programming Tips

USING STUFFIT DELUXE THE STUFFIT START PAGE CREATING ARCHIVES (COMPRESSED FILES)

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

Digital Electronics Detailed Outline

FORDHAM UNIVERSITY CISC Dept. of Computer and Info. Science Spring, Lab 2. The Full-Adder

Eventia Log Parsing Editor 1.0 Administration Guide

Building an Embedded Processor System on a Xilinx Zync FPGA (Profiling): A Tutorial

A Verilog HDL Test Bench Primer Application Note

Snagit 10. Getting Started Guide. March TechSmith Corporation. All rights reserved.

Lecture 8: Synchronous Digital Systems

Quartus II Introduction for VHDL Users

Verification & Design Techniques Used in a Graduate Level VHDL Course

CHAPTER 3 Boolean Algebra and Digital Logic

Design and Development of Virtual Instrument (VI) Modules for an Introductory Digital Logic Course

Royal Military College of Canada

TestManager Administration Guide

STEP 7 MICRO/WIN TUTORIAL. Step-1: How to open Step 7 Micro/WIN

Testing & Verification of Digital Circuits ECE/CS 5745/6745. Hardware Verification using Symbolic Computation

SOFTWARE USER GUIDE. Aleratec. Part No , EU. 1:10 USB 3.0 Copy Cruiser Mini

Practice Fusion API Client Installation Guide for Windows

IGSS. Interactive Graphical SCADA System. Quick Start Guide

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

JORAM 3.7 Administration & Monitoring Tool

Figure 1: Graphical example of a mergesort 1.

SAS Analyst for Windows Tutorial

Lab 17: Building a 4-Digit 7-Segment LED Decoder

Introduction: The Xcode templates are not available in Cordova or above, so we'll use the previous version, for this recipe.

16-bit ALU, Register File and Memory Write Interface

Gates, Circuits, and Boolean Algebra

Generating MIF files

PCB Project (*.PrjPcb)

Reviewing documents with track changes in Word 2013

5. Tutorial. Starting FlashCut CNC

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

Work with Arduino Hardware

CMOS Binary Full Adder

Audacity is a free, totally free, audio editing program. Get it here:

Installing C++ compiler for CSc212 Data Structures

Visual Studio 2008 Express Editions

Downloading Driver Files

Creating a Simple Visual C++ Program

Creating a Project with PSoC Designer

Appendix M: Introduction to Microsoft Visual C Express Edition

QUICK START GUIDE. SG2 Client - Programming Software SG2 Series Programmable Logic Relay

NEW adder cells are useful for designing larger circuits despite increase in transistor count by four per cell.

ECE 3401 Lecture 7. Concurrent Statements & Sequential Statements (Process)

6.004 Computation Structures Spring 2009

MICROSOFT ACCESS 2003 TUTORIAL

Eclipse installation, configuration and operation

Component, Model and Library Concepts. Components - the Basic Building Blocks. Modified by on 2-Jul-2014

Getting Started with the LabVIEW Mobile Module

Designing a Graphical User Interface

Lab 3: Introduction to Data Acquisition Cards

Before you can use the Duke Ambient environment to start working on your projects or

Introduction to Microsoft Excel 2010

The 104 Duke_ACC Machine

Quartus II Software Design Series : Foundation. Digitale Signalverarbeitung mit FPGA. Digitale Signalverarbeitung mit FPGA (DSF) Quartus II 1

Using Karel with Eclipse

Installing Geant4 v9.5 for Windows

The components. E3: Digital electronics. Goals:

Quick Start Using DASYLab with your Measurement Computing USB device

Finite State Machine Design A Vending Machine

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

How to use AVR Studio for Assembler Programming

Binary Adders: Half Adders and Full Adders

Chief Architect X6. Download & Installation Instructions. Chief Architect, Inc N. Mineral Dr. Coeur d Alene, Idaho

Multisim 7 Tutorial Creating Macros for Sub-circuits

SQL Server 2005: Report Builder

How to Make the Most of Excel Spreadsheets

Download and Installation Instructions. Java JDK Software for Windows

Capacitive Touch Lab. Renesas Capacitive Touch Lab R8C/36T-A Family

Multiplexers Two Types + Verilog

Creating a Gradebook in Excel

Using your Bluetooth laptop with the Logitech wireless hub

Programming LEGO NXT Robots using NXC

Organizing image files in Lightroom part 2

EZ-ZONE RMA & EtherNet/IP Configuration & Startup Using an Allen-Bradley CompactLogix PLC EtherNet/IP Fundamentals

Transcription:

is project will give you a basic understanding of ModelSim and the Verilog hardware description language (HDL). ModelSim is an IDE for hardware design which provides behavioral simulation of a number of languages, i.e., Verilog, VHDL, and SystemC. e Verilog HDL is an industry standard language used to create analog, digital, and mixed-signal circuits. HDL s are languages which are used to describe the functionality of a piece of hardware as opposed to the execution of sequential instructions like that in a regular software application. Both of these tools are used extensively in industry, so knowing how to use them can be beneficial later in your career. ModelSim Tutorial Luckily, there is a free, student version of ModelSim that can be downloaded from the following location (NOTE: If you do not have access to a Windows based computer, ModelSim is installed in the Windows labs of A.V. Williams): http://www.model.com/resources/student_edition/download.asp Follow the instructions on the page to install the program and obtain a student license, which they will send to you via e-mail. Once you have received the license and everything has been properly installed, ModelSim should execute without issue. Navigate to the Help->PDF Documentation pull-down menu and select Tutorial from the list. ankfully, ModelSim has provided a simple explanation on the basic use of the application. Read through and follow along sections 1-4 and 6 (Using Verilog) Note: e ModelSim tutorial will not instruct you on the syntax/use of Verilog. Just use their files for now and explanations will follow later in this project. Verilog Basics Now that you have a basic understanding of ModelSim, the following will give you some idea of how the Verilog language works. It is important to remember that the language is meant to model the functionality of physical hardware; thus, the language does not run as a sequential program like you are used to, where each step in a sequence of steps executes after the previous step has finished. In Verilog, as in hardware, all logic executes simultaneously. is is understandably confusing at first, but with practice it will become more intuitive. AND Gate Project 1: ModelSim Tutorial and Verilog Basics ENEE 359a: Digital VLSI Circuits, Spring 2008 Assigned: Thursday, Feb 7; Due: Tuesday, Feb 19 e first step will be to create a module, the fundamental building block in Verilog. A module represents the fundamental building block of hardware: a piece of combinatorial or sequential logic. 1

1. Start by selecting the Project tab in ModelSim. Right-click on the HDL folder you created during the ModelSim tutorial and select Add To Project -> New File. Select the appropriate fields so that the dialog looks like this: After you click OK, double-click on the file to open it in the ModelSim editor. 2. Add the following text to the file : module and2_1bit (a,b,c); input a; input b; output c; assign c = a&b; endmodule Save the file, select and right-click on it in the Project tab, and choose Compile -> Compile Selected. You should see a success message printed in the Transcript window at the bottom. Take a moment to look at the structure and syntax of the code you compiled, which describes a 1-bit, 2-input AND gate. ings to note: Semicolon after module declaration All signals in the Port List must be declared as either an input or output before they are used endmodule is one word and is not followed by a semicolon A naming convention for your modules will make your life infinitely easier my convention above lists the number of inputs after the gate type followed by the number of bits of each input. You can have your own convention just stick with it. Once the file has been successfully compiled, select the Library tab and expand your Work library. You should now see and2_1bit listed as a module. We now have a 1-bit, 2-input AND gate to use in our designs. Too bad they aren t very useful. Let s make something a little more worthwhile. 2

3. Return to the editor and add the following text to the end of the file we were just working on : module and2_32bit(a,b,c); input [31:0] a; input [31:0] b; output [31:0] c; assign c = a&b; endmodule is module performs a bit-wise AND on 2, 32-bit inputs, as you probably have guessed. Note how multiple bit-width inputs are declared. Similar to arrays in C, using the square bracket indicates that the signal is more than one bit. e most-significant-bit is listed first, and the least-significant-bit is second. Compile the file again and check your Work library. You will now see both your 1-bit and 32-bit AND gates listed. Note: Since you are allowed to have multiple modules per file, it is a good idea to keep similar modules in the same file to avoid clutter Additional Gates: OR and XOR 1. Create and compile similar files for an OR and XOR gate of various bit-widths (two modules for each logical function: OR and XOR gates of 1 bit and 32 bits). Full Adder Now that we have the basic building blocks of a digital system, we will create something useful: an adder. According to wikipedia A full adder is a logical circuit that performs an addition operation on three binary digits. e full adder produces a sum and carry value, which are both binary digits. e truth table for a full adder can be seen below. From the truth table we can reason that the block diagram can be created from the following logic (also from wikipedia): You are now going to implement this in Verilog using the modules you have already created. 3

1. Under the Project tab, add a new Verilog file to your HDL directory called fulladder.v and fill it with the following text: module fulladder(a,b,cin, s,cout); input a; input b; input cin; output s; output cout; wire axorb; wire candaxorb; wire aandb; xor2_1bit XORgate1 (a,b,axorb); xor2_1bit XORgate2 (axorb,cin,s); and2_1bit ANDgate1 (cin,axorb,candaxorb); and2_1bit ANDgate2 (a,b,aandb); or2_1bit ORgate1 (candaxorb, aandb, cout); endmodule As you can see, there is far more to this module than our previous designs. After the input and output declarations, we are now declaring several wire objects. ink of these exactly as how they sound: a wire which will carry a signal from a source to a destination. We will use these wires to connect our gates together in order to create this full-adder. After the wire declarations there are module declarations. Here, we instantiate the gates we have made and connect the appropriate wires to their respective ports. With the block diagram image above, try and reason about what was done in the code. Note: Make sure the order of the wires in your port list is correct for your particular modules. You may have ordered them differently than in my code. Note: Be as verbose as possible with your variable and module names. It will make your/ my life much easier. 2. Assuming your file compiled successfully, you will now simulate the full-adder you just created. Under the Library tab, expand your Work library and double-click on the module labeled fulladder. e ModelSim windows should rearrange themselves and some new text will appear in the Transcript tab. Note: Any action you perform with the user interface also has a corresponding command which can be executed from the command line. For example, loading a module for simulation (which you just did by double-clicking) can by done by executing the command vsim work.and2_1bit assuming your AND gate is named as such. 3. In the Objects window, select all of the items listed using the standard shift-click. Once they are all selected, right-click and select Add To Wave -> Selected Signals. 4

is should open up the Wave tab with all of the signals from the fulladder module. 4. At the command line in the Transcript tab, type run 100 and hit enter. e waveform should display a bunch of red and blue lines representing undefined or high-impedance signals. is is because there are no values on the input. Let s change this. 5. At the command line, type the following: force a 0; force b 1; force cin 1; run 100 is time, the waveform should display green lines for each signal. Using the truth table above, make sure your outputs s and cout are the correct values. Using the syntax above, change the values of the inputs to observe the module s behavior. Hopefully, for all combinations of inputs, the correct output is produced. 4-bit Adder, Built from 1-bit Full Adders 1. Now, create a module for a 4-bit, 2-input adder using the full-adder module just created. Use the internets to find a block diagram. Turn in all of your HDL source code and a screenshot of the waveform after you have added together a couple of numbers (In decimal, explained below). 5

Tips: You can splice off individual wires from a multi-bit width signal by using the brackets, just like in C. If you need the least-significant-bit of signal output, address it with output[0]. Right-click on a signal in the waveform window to select the radix. When turning in the screenshot of your results, and for your own use, use Decimal. When forcing signals via the command line you can specify the radix of the value you are forcing. Here is an example : force a d4 force b d11 e d stands for Decimal. h works for hex, b for binary, etc. 6