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

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

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

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design

Tutorial on Verilog HDL

Chap 3. Modeling structure & basic concept of Verilog HDL

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

Course Topics - Outline

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

Chap 6 Introduction to HDL (d)

Hardware Description Languages (HDLs) Verilog

Verilog Tutorial (Structure, Test)

VHDL 2 Combinational Logic Circuits. Reference: Roth/John Text: Chapter 2

Verilog. Verilog for Synthesis

VeriLogger Tutorial: Basic Verilog Simulation

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

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

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

Design Using Verilog

Introduction to Digital Design with Verilog HDL

101-1 Under-Graduate Project Digital IC Design Flow

CSE140L: Components and Design Techniques for Digital Systems Lab

Verilog for Combinational Circuits

VLSI Design 13. Introduction to Verilog

CSE140L: Components and Design

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

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

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

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

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

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

Introduction to Verilog

Advanced Digital Design with the Verilog HDL

Chapter 6: Hierarchical Structural Modeling

Hardware Description Language (HDL)

Verilog HDL. Gate-Level Modeling

Hardware description languages

ECEN 468 Advanced Digital System Design

Chapter 2 Using Hardware Description Language Verilog. Overview

Introduction to Verilog HDL. Verilog 1

Mridula Allani Fall Fall

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

ECE 353 Lab 3 (Verilog Design Approach)

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

Combinational Logic Design with Verilog. ECE 152A Winter 2012

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

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

Chapter 5: Tasks, Functions, and UDPs

HDL for Combinational Circuits. ENEL211 Digital Technology

EEL 4783: HDL in Digital System Design

Introduction to Verilog HDL

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Lecture 15: System Modeling and Verilog

Verilog Design Entry, Synthesis, and Behavioral Simulation

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

Verilog Module 1 Introduction and Combinational Logic

Introduction. Purpose. Intended Audience. Conventions. Close

Course Topics - Outline

Hardware Description Language VHDL (1) Introduction

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Verilog 1 - Fundamentals

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

Verilog Design Principles

Chapter 2a: Structural Modeling

Verilog HDL Introduction

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran

Writing Circuit Descriptions 8

Verilog Design Principles

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

ECE 152A LABORATORY 2

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 4 Introduction to VHDL

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

14. Introducton to Verilog

JUNE, JULY 2013 Fundamentals of HDL (10EC45) PART A

Synthesizable Verilog

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

SYSTEM SPECIFICATIONS USING VERILOG HDL. Dr. Mohammed M. Farag

Image Courtesy CS250 Section 2. Yunsup Lee 9/4/09

14. Introducton to Verilog

DIGITAL SYSTEM DESIGN

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

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

Digital Design with FPGAs. By Neeraj Kulkarni

Modules, ports, instantiation

VHDL: A Crash Course

Basic Language Concepts

Contents. Appendix D Verilog Summary Page 1 of 16

Combinational Logic Circuits

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Verilog Tutorial. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

Verilog Tutorial 9/28/2015. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

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

Topics. Midterm Finish Chapter 7

RIZALAFANDE CHE ISMAIL TKT. 3, BLOK A, PPK MIKRO-e KOMPLEKS PENGAJIAN KUKUM. SYNTHESIS OF COMBINATIONAL LOGIC (Chapter 8)

Nikhil Gupta. FPGA Challenge Takneek 2012

Verilog HDL. Testing & Verification Dept. of Computer Science & Engg,, IIT Kharagpur

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

Transcription:

: P-1/26 Textbook: Verilog HDL 2 nd. Edition Samir Palnitkar Prentice-Hall, Inc. : INSTRUCTOR : CHING-LUNG SU E-mail: kevinsu@yuntech.edu.tw

Chapter 4 P-2/26 Chapter 4 Modules and

Outline of Chapter 4 P-3/26 4.1 Modules 4.2 4.3 Hierarchical Names

4.1 Modules P-4/26 4.1 Modules 4.2 4.3 Hierarchical Names

4.1 Modules P-5/26 Distinct Parts of a Module in Verilog Module Name, Port Lists, Port Declaration (if ports present) Parameters (optional), Declaration of wires, regs and other variables, Instantiation of lower level modules Data flow statements (assign) always and initial blocks. All behavior statements go in these blocks. Tasks and functions endmodule statement

4.1 Modules P-6/26 Module Example: SR Latch // This example illustrates the different components of a module // Module name and port list SR_latch module module SR_latch(Q, Qbar, Sbar, Rbar); //Port declarations output Q, Qbar; input Sbar, Rbar; // Instantiate lower level modules // In this case, instantiate Verilog primitive "nand" gates // Note, how the wires are connected in a cross coupled fashion. nand n1(q, Sbar, Qbar); nand n2(qbar, Rbar, Q); endmodule //endmodule statement Sbar (set) n1 Q // Module name and port list // Stimulus module module Top; wire q, qbar; // Declarations of wire, reg and other variables reg set, reset; // Instantiate lower level modules // In this case, instantiate SR_latch SR_latch l1(q, qbar, ~set, ~reset); initial // Behavioral block, initial begin $monitor($time, " set = %b, reset= %b, q= %b\n",set,reset,q); set = 0; reset = 0; #5 reset = 1; #5 reset = 0; #5 set = 1; #5 set = 0; reset = 1; #5 set = 0; reset = 0; #5 set = 1; reset = 0; end endmodule // endmodule statement Rbar (reset) n2 Qbar

4.1 Modules P-7/26 SR Latch Simulation Results

P-8/26 4.1 Modules 4.2 4.3 Hierarchical Names

P-9/26 provide the interface by which a module can communication with its environment. The environment can interact with the module only through its ports. The internals of the module can be changed without affecting the environment as long as the interface is not modified. are also referred to as terminals.

P-10/26 List of A module definition contains an optional list of ports. If the module does not exchange any signals with the environment, there are no ports in the list. Consider a 4-bit full adder that is instantiated inside a top-level module Top. Example 4-bit full adders: Top a b c_in Full Adder (4-bit) fulladd4 sum c_out

P-11/26 Port Example for 4-bit 4 Full Adder module fulladd4 (sum, c_out, a, b, c_in); //Module with a list of ports module Top; //No list of ports, top-level module in simulation

Port Declaration can be declared as follows: P-12/26 Verilog Keyword input output inout Type of Port Input Port Output Port Bidirectional Port Example of fulladd4: module fulladd4 (sum, c_out, a, b, c_in); //Begin port declarations section output [3:0] sum; output c_cout; input [3:0] a, b; input c_in; //End port declaration section <module internals> endmodule

P-13/26 Port Declaration (Cont.) All port declarations are implicitly declared as wire in Verilog. If output ports hold their value, they must be declared as reg. For example of DFF, we want the output q to retain its value until the next clock edge. The port declarations for DFF will look as next slice:

P-14/26 Port Declaration (Cont.) module DFF(q, d, clk, reset); output q; reg q; //Output port q holds value, therefore it is //declared as reg input d, clk, reset; endmodule

P-15/26 Port Declaration (Cont.) input and inout cannot be declared as reg because reg variables store values and input ports should not store values. fulladd4 declaration in ANSI C Style: module fulladd4 (output reg [3:0] sum, output reg c_out, input [3:0] a, b, //wire by default input c_in; // wire by default ) <module internals> endmodule

P-16/26 Port Connection Rules net net inout input output reg or net net reg or net net Width Matching: It is legal to connect internal and external items of different sizes. Mismatching of Width: Warning Message!!

P-17/26 Example of Illegal Port Connection This problem is rectified if the variable SUM is declared as a net (wire). module Top //Declare connection variable reg [3:0] A, B; reg C_IN; reg [3:0] SUM; wire C_OUT // Instantiate fulladd4, call it fa0 fulladd4 fa0(sum, C_OUT, A, B, C_IN); //Illegal connection because output port sum in module //fulladd4 is connect to a register variable SUM in module Top <stimulus> endmodule

P-18/26 Connecting to External Signals 1. Connecting by ordered list 2. Connecting ports by name

P-19/26 Connecting by Ordered List Connecting by ordered list is the most intuitive method for most beginners. The signals to be connected must appear in the module instantiation in the same order as the ports in the port list in the module definition.

P-20/26 Example for Connecting by Ordered List module Top; //Declare connection variables reg [3:0]A,B; reg C_IN; wire [3:0] SUM; wire C_OUT; //Instantiate fulladd4, call it fa_ordered. //Signals are connected to ports in order (by position) fulladd4 fa_ordered (SUM, C_OUT, A, B, C_IN); <stimulus>... endmodule module fulladd4 (sum, c_out, a, b, c_in); output[3:0] sum; output c_cout; input [3:0] a, b; input c_in;... <module internals>... endmodule

P-21/26 Connecting by Name For large designs where modules have remembering the order of the ports in the module definition is impractical and error-prone. Verilog provides the capability to connect external signals to ports by the port names. You can specify the port connections in any order as long as the port name in the module definition correctly matches the external signal. Unconnected ports can be dropped. Advantage of connecting ports by name is that the port name is not changed, the order of ports in the port list of a module can be rearranged without changing the port connections in module instantiations.

P-22/26 Example for Connecting by Name module Top; //Declare connection variables reg [3:0]A,B; reg C_IN; wire [3:0] SUM; wire C_OUT; // Instantiate module fa_byname and connect signals to ports by name fulladd4 fa_byname (.c_out(c_out),.sum(sum),.b(b),.c_in(c_in),.a(a),); <stimulus>... endmodule module fulladd4 (sum, c_out, a, b, c_in); output[3:0] sum; output c_cout; input [3:0] a, b; input c_in;... <module internals>... endmodule or // Instantiate module fa_byname and connect signals to ports by name fulladd4 fa_byname(.sum(sum),.b(b),.c_in(c_in),.a(a),);.c_out(c_out)

4.3 Hierarchical Names P-23/26 4.1 Modules 4.2 4.3 Hierarchical Names

4.3 Hierarchical Names P-24/26 Hierarchical Name Verilog supports a hierarchical design methodology. A particular identifier has a unique place in the design hierarchy. Hierarchical name referencing allows us to denote every identifier in the design hierarchy with a unique name. A hierarchical name is a list of identifiers separated by dots (".") for each level of hierarchy. Any identifier can be addressed from any place in the design by simply specifying the complete hierarchical name of that identifier. The top-level module is called the root module because it is not instantiated anywhere

4.3 Hierarchical Names P-25/26 Design Hierarchy for SR Latch Simulation stimulus (Root Level) Hierarchical Names for SR_Latch n1 (nand) m1 (SR_Latch) n2 (nand) Q, Qbar S, R (Signals) q, qbar, set, reset, (variables) stimulus stimulus.qbar stimulus.reset stimulus.m1.q stimulus.m1.s stimulus.n1 stimulus.q stimulus.set stimulus.m1 stimulus.m1.qbar stimulus.m1.r stimulus.n2

4.3 Hierarchical Names P-26/26 Design Hierarchy for SR Latch Simulation (Cont.) stimulus is the top-level module (root module). The identifiers defined in this module are q, qbar, set, and reset. The root module instantiates m1, which is a module of type SR_latch. The module m1 instantiates nand gates n1 and n2. Q, Qbar, S, and R are port signals in instance m1. To display the level of hierarchy, use the special character %m in the $display task.