Tutorial on Verilog HDL

Similar documents
Design Using Verilog

HDL for Combinational Circuits. ENEL211 Digital Technology

What is Verilog HDL? Lecture 1: Verilog HDL Introduction. Basic Design Methodology. What is VHDL? Requirements

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

Introduction to Verilog HDL. Verilog 1

Verilog Tutorial (Structure, Test)

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

ECEN 468 Advanced Digital System Design

Federal Urdu University of Arts, Science and Technology, Islamabad VLSI SYSTEM DESIGN. Prepared By: Engr. Yousaf Hameed.

EE 8351 Digital Logic Circuits Ms.J.Jayaudhaya, ASP/EEE

DIGITAL SYSTEM DESIGN

P-1/26. Samir Palnitkar. Prentice-Hall, Inc. INSTRUCTOR : CHING-LUNG SU.

Introduction. Why Use HDL? Simulation output. Explanation

Digital Design with FPGAs. By Neeraj Kulkarni

Verilog. What is Verilog? VHDL vs. Verilog. Hardware description language: Two major languages. Many EDA tools support HDL-based design

Hardware Description Languages (HDLs) Verilog

Module 2.1 Gate-Level/Structural Modeling. UNIT 2: Modeling in Verilog

Introduction to Verilog design. Design flow (from the book)

ACS College of Engineering. Department of Biomedical Engineering. Logic Design Lab pre lab questions ( ) Cycle-1

VeriLogger Tutorial: Basic Verilog Simulation

101-1 Under-Graduate Project Digital IC Design Flow

Chap 3. Modeling structure & basic concept of Verilog HDL

Combinational Logic Design with Verilog. ECE 152A Winter 2012

Introduction to Verilog HDL

DIGITAL SYSTEM DESIGN

Combinational Logic Circuits

Synthesis of Combinational and Sequential Circuits with Verilog

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Verilog for Combinational Circuits

Combinational Logic II

Lecture #2: Verilog HDL

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

EEL 4783: Hardware/Software Co-design with FPGAs

Chap 6 Introduction to HDL (d)

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

Verilog Hardware Description Language ROOM: B405

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Module 4. Design of Embedded Processors. Version 2 EE IIT, Kharagpur 1

Introduction to Verilog design. Design flow (from the book) Hierarchical Design. Lecture 2

C-Based Hardware Design

Contents. Appendix D Verilog Summary Page 1 of 16

Advanced Digital Design with the Verilog HDL

Combinational Logic. Prof. Wangrok Oh. Dept. of Information Communications Eng. Chungnam National University. Prof. Wangrok Oh(CNU) 1 / 93

N-input EX-NOR gate. N-output inverter. N-input NOR gate

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

Introduction to Verilog

Hardware Description Language VHDL (1) Introduction

Chapter 2 Using Hardware Description Language Verilog. Overview

Spiral 1 / Unit 4 Verilog HDL. Digital Circuit Design Steps. Digital Circuit Design OVERVIEW. Mark Redekopp. Description. Verification.

Verilog HDL Introduction

Verilog. Verilog for Synthesis

Lecture 32: SystemVerilog

Hardware description languages

Spring 2017 EE 3613: Computer Organization Chapter 5: Processor: Datapath & Control - 2 Verilog Tutorial

2/14/2016. Hardware Synthesis. Midia Reshadi. CE Department. Entities, Architectures, and Coding.

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

תכן חומרה בשפת VERILOG הפקולטה להנדסה

Digital Design (VIMIAA01) Introduction to the Verilog HDL

VLSI II E. Özgür ATES

Introduction to Verilog

Chapter 3 Part 2 Combinational Logic Design

CSE241 VLSI Digital Circuits Winter Recitation 1: RTL Coding in Verilog

ECE 353 Lab 3 (Verilog Design Approach)

Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL. Variables and Logic Value Set. Data Types. Why use an HDL?

A Brief Introduction to Verilog Hardware Definition Language (HDL)

VHDL Examples Mohamed Zaky

Introduction to Verilog/System Verilog

Verilog Module 1 Introduction and Combinational Logic

Chapter 6 Combinational-Circuit Building Blocks

VLSI Design 13. Introduction to Verilog

EGC220 - Digital Logic Fundamentals

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

CENG 241 Digital Design 1

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

Chapter 6: Hierarchical Structural Modeling

Declarations of Components and Entities are similar Components are virtual design entities entity OR_3 is

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb UMass Amherst Fall 2017

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

What Is VHDL? VHSIC (Very High Speed Integrated Circuit) Hardware Description Language IEEE 1076 standard (1987, 1993)

Course Topics - Outline

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

CSE140L: Components and Design Techniques for Digital Systems Lab

register:a group of binary cells suitable for holding binary information flip-flops + gates

Online Verilog Resources

TOPIC : Verilog Synthesis examples. Module 4.3 : Verilog synthesis

CSE140L: Components and Design

EECS 427 Lecture 14: Verilog HDL Reading: Many handouts/references. EECS 427 W07 Lecture 14 1

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Verilog HDL [As per Choice Based Credit System (CBCS) scheme]

Verilog Design Entry, Synthesis, and Behavioral Simulation

Verilog 1 - Fundamentals

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

Lab 6 : Introduction to Verilog

Verilog Coding Guideline

Introduction. Purpose. Intended Audience. Conventions. Close

EECS150 - Digital Design Lecture 8 - Hardware Description Languages

VERILOG HDL. 1 ENGN3213: Digital Systems and Microprocessors L#5-6

Transcription:

Tutorial on Verilog HDL

HDL Hardware Description Languages Widely used in logic design Verilog and VHDL Describe hardware using code Document logic functions Simulate logic before building Synthesize code into gates and layout Requires a library of standard cells

Verilog Verilog is one of the two major Hardware Description Languages(HDL) used by hardware designers in industry and academia. VHDL is another one Verilog is easier to learn and use than VHDL Verilog HDL allows a hardware designer to describe designs at a high level of abstraction such as at the architectural or behavioral level as well as the lower implementation levels (i.e., gate and switch levels).

Why use Verilog HDL Digital systems are highly complex. The Verilog language provides digital designer a software platform. Verilog allows users to express their design with behavioral constructs. A program tool can convert the Verilog program to a description that was used to make chip, like VLSI.

Taste of Verilog Module name Module ports module Add_half ( sum, c_out, a, b ); input a, b; output sum, c_out; wire c_out_bar; xor (sum, a, b); // xor G1(sum, a, b); nand (c_out_bar, a, b); not (c_out, c_out_bar); endmodule Declaration of port modes Declaration of internal signal Instantiation of primitive gates a b G1 c_out_bar sum Verilog keywords c_out

Lexical Convention Lexical convention are close to C++. Comment // to the end of the line. /* to */ across several lines. Keywords are lower case letter. the language is case sensitive

Lexical Convention Numbers are specified in the traditional form or below. <size><base format><number> Size: contains decimal digitals that specify the size of the constant in the number of bits. Base format: is the single character followed by one of the following characters b(binary),d(decimal),o(octal),h(hex). Number: legal digital.

Lexical Convention Example : 347 // decimal number 4 b101 // 4- bit binary number 0101 8 o12 // 8-bit octal number 12 10 h8f // 10-bit hex number 8f 8 d83 // 8-bit decimal number 83 String in double quotes this is a introduction

Lexical Convention Operator are one, two, or three characters and are used in the expressions. just like C++. Identifier: specified by a letter or underscore followed by more letter or digits, or signs.

Program structure Structure module <module name> (< port list>); < declares> <module items> endmodule. Module name an identifier that uniquely names the module.. Port list a list of input, inout and output ports which are referenced in other modules.

Program structure. Declares section specifies data objects as registers, memories and wires as well as procedural constructs such as functions and tasks.. Module items initial constructs always constructs assignment.

Test Module structure module <test module name> ; // Data type declaration. Inputs declared as reg and outputs declared as wire // Instantiate module ( call the module that is going to be tested) // Apply the stimulus // Display results // Display results endmodule

Three Modeling Styles in Verilog Structural modeling (Gate-Level Modeling) Use predefined or user-defined primitive gates. Dataflow modeling Use assignment statements (assign) Behavioral modeling Use procedural assignment statements (always)

Structural model //structural model of a NAND gate // program nand2.v module my_nand(a, B, F); input A, B; output F; nand G(F, A, B); // first parameter must be output. endmodule

Example of gate NAND Test bench module test_nand for the nand1.v module test_my_nand; // Test bench to test nand reg A, B; wire F; my_nand test_my_nand(a, B, F); // instantiate my_nand. initial begin // apply the stimulus, test data A = 1'b0; B = 1'b0; #100 A = 1'b1; // delay one simulation cycle, then change A=>1. #100 B = 1'b1; #100 A = 1'b0; end initial #500 $finish; begin // setup monitoring //$monitor("time=%0d a=%b b=%b out1=%b", $time, A, B, F); //#500 $finish; end endmodule

Structural Modeling //Gate-level description of a 2-to-4-line decoder //Figure 4-19 module decoder_gl (input A,B,E, output [0:3] D); wire Anot, Bnot, Enot; not n1 (Anot, A), n2 (Bnot, B), n3 (Enot, E); nand n4 (D[0], Anot, Bnot, Enot), n5 (D[1], Anot,B, Enot), n6 (D[2], A, Bnot, Enot), n7 (D[3], A, B, Enot); endmodule

//Gate-level hierarchical description of 4-bit adder // Description of half adder (see Fig 4-5b) //module halfadder (S,C,x,y); // input x,y; // output S,C; module halfadder (output S,C, input x,y); //Instantiate primitive gates xor (S,x,y); and (C,x,y); endmodule //Description of full adder (see Fig 4-8) module fulladder (output S,C, input x,y,z); wire S1,C1,C2; //Outputs of first XOR and two AND gates halfadder HA1 (S1,C1,x,y), HA2 (S,C2,S1,z); //Instantiate the halfadder or g1(c,c2,c1); endmodule

//Description of 4-bit adder (see Fig 4-9) module ripple_carry_4bit_adder (output [3:0] S, output C4, input [3:0] A,B, input C0) // input [3:0] A,B; //input C0; //output [3:0] S; //output C4; wire C1,C2,C3; //Intermediate carries //Instantiate the fulladder fulladder FA0 (S[0], C1, A[0], B[0], C0), FA1 (S[1], C2, A[1], B[1], C1), FA2 (S[2], C3, A[2], B[2], C2), FA3 (S[3], C4, A[3], B[3], C3); endmodule The names are required!

Dataflow Modeling //HDL Example 4-3 //---------------------------------------------- //Dataflow description of a 2-to-4-line decoder //See Fig.4-19 module decoder_df (output [0:3] D, input A, B, enable); assign D[0] = ~(~A & ~B & ~ enable), endmodule D[1] = ~(~A & B & ~ enable), D[2] = ~(A & ~B & ~ enable), D[3] = ~(A & B & ~ enable);

Dataflow Modeling //HDL Example 4-4 //---------------------------------------- //Dataflow description of 4-bit adder module binary_adder (A, B, Cin, SUM, Cout); input [3:0] A,B; input Cin; output [3:0] SUM; output Cout; assign {Cout, SUM} = A + B + Cin; endmodule concatenation Binary addition

Dataflow Modeling //HDL Example 4-5 //----------------------------------- //Dataflow description of a 4-bit comparator. module magcomp (A,B,ALTB,AGTB,AEQB); input [3:0] A,B; output ALTB,AGTB,AEQB; assign ALTB = (A < B), AGTB = (A > B), AEQB = (A == B); endmodule

Dataflow Modeling //HDL Example 4-6 //---------------------------------------- //Dataflow description of 2-to-1-line multiplexer module mux2x1_df (A, B, select, OUT); input A,B,select; output OUT; assign OUT = select? A : B; endmodule

Behavioral Description module Add_half ( sum, c_out, a, b ); input a, b; a output sum, c_out; reg sum, c_out; b always @ ( a or b ) begin sum = a ^ b; // Exclusive or c_out = a & b; // And end endmodule Must be of the reg type Procedure assignment statements Add_half sum c_out Event control expression

Example of Flip-flop module Flip_flop ( q, data_in, clk, rst ); input data_in, clk, rst; output q; reg q; always @ ( posedge clk ) begin if ( rst == 1) q = 0; else q = data_in; end endmodule data_in clk rst Declaration of synchronous behavior Procedural statement q

Using Verilogger Pro Evaluation Version. enter the window of Verilogger Start Program SynaptiCad Verilogger Pro..

How to build a new project Click Menu [ Project] [New Project] enter the conversation window. Enter the Project Name. default: untitled.hpj. *.hpj Enter the Project Directory C:\SynaptiCAD\project\ Or others..click the [Finish] to close the window.

Other menus of [Project] [Open Project] [Close Project] [Save Project] [Save Project as] [Add User Source Files] all the user source used by this project. Project setting Print Project Hierarchy

Verilogger Editor Use the Verilogger Editor to build a program. In the Verilogger Window: click [Editor] [New HDL file] pop up a editor window for you.. Others Menu in the [Editor] same as Menu[Project]

Example of gate NAND Save the HDL files as nand1.v in menu [Editor] [Save HDL File As] and save another HDL file as test-nand1.v Attach these two HDL files to the new project test.hpj in [project]->[add User Source Files] Run the simulation program run/resume simulation button or in the [simulate].

How to build a new project?

How to create a HDL file?

How to save the HDL file?

How to add a source HDL file to a Project(project1)

Now, Ready to run the program!

The Report Window of Verilogger.(all the simulation information is in this window)

Example of gate NAND Simulation report from Verilog-Report window. Running... Time=0 a=0 b=0 out1=1 Time=1 a=1 b=0 out1=1 Time=2 a=1 b=1 out1=0 Time=3 a=0 b=1 out1=1 0 Errors, 0 Warnings Compile time = 0.00000, Load time = 0.00000, Execution time = 0.06000 Normal exit

Diagram window of Simulation result

How to copy the diagram to Microsoft Word!

Example of gate NAND Wave from Verilog diagram. Verilog windows Activate the the diagram windows Method 1: [File] -> [Print Diagram] -> Print to: [WMF Metafile[MS Word]; Method 2: [edit] [copy to clipboard] select wave form, name and time line select ok then you can paste the diagram to anywhere you want.

You can paste the diagram here!