Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-1 Chapter 6: Hierarchical.

Slides:



Advertisements
Similar presentations
//HDL Example 4-10 // //Gate-level description of circuit of Fig. 4-2 module analysis (A,B,C,F1,F2); input.
Advertisements

Verilog.
Simulation executable (simv)
The Verilog Hardware Description Language
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Verilog Modules for Common Digital Functions
Verilog Intro: Part 1.
Hardware Description Language (HDL)
Anurag Dwivedi.  Verilog- Hardware Description Language  Modules  Combinational circuits  assign statement  Control statements  Sequential circuits.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
Counters Discussion 12.1 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
Digital System Design Verilog ® HDL Modules and Ports Maziar Goudarzi.
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
Combinational Logic in Verilog
INTRODUCTION TO VERILOG HDL Presented by m.vinoth.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
ECE 2372 Modern Digital System Design
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Chapter 2: Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 2-1 Ders – 2: Yapısal Modelleme.
Module 2.1 Gate-Level/Structural Modeling UNIT 2: Modeling in Verilog.
CH71 Chapter 7 Hardware Description Language (HDL) By Taweesak Reungpeerakul.
Chapter 5: Tasks, Functions, and UDPs Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 5-1 Ders - 5 : Görevler,
Digital System Design Verilog ® HDL Parameters, and Generate Blocks Maziar Goudarzi.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.
Brief Verilog.
Digital System Design Verilog ® HDL Design at Structural Level Maziar Goudarzi.
Chapter 2: Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 2-1 Chapter 2a: Structural Modeling.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Copied with Permission from prof. Mark PSU ECE
Verilog hdl – II.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 12 - Introduction.
Chapter 8: Combinational Logic Modules Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 8-1 Chapter 8: Combinational.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
Chapter 5: Tasks, Functions, and UDPs Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 5-1 Chapter 5: Tasks, Functions,
Chapter1: Introduction Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 1-1 Chapter 1: Introduction Prof. Ming-Bo.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
Digital System Design Verilog ® HDL Dataflow Modeling Maziar Goudarzi.
Modern VLSI Design 3e: Chapter 8 Copyright  1998, 2002 Prentice Hall PTR Topics n Verilog register-transfer modeling: –basics using traffic light controller;
Hardware Description Languages: Verilog
Verilog Introduction Fall
Supplement on Verilog adder examples
Lecture 2 Supplement Verilog-01
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Chapter 5: Tasks, Functions, and UDPs
Chapter 2a: Structural Modeling
Chapter 7: Advanced Modeling Techniques
Chapter 9: Sequential Logic Modules
HDL Programming Fundamentals
Lecture 2: Continuation of SystemVerilog
Chapter 8: Combinational Logic Modules
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
Supplement on Verilog adder examples
The Verilog Hardware Description Language
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-1 Chapter 6: Hierarchical Structural Modeling Prof. Ming-Bo Lin Department of Electronic Engineering National Taiwan University of Science and Technology

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-2 Module Definitions // port list style module module_name [#(parameter_declarations)][port_list]; parameter_declarations; // if no parameter ports are used port_declarations; other_declaration; statements; endmodule // port list declaration style module module_name [#(parameter_declarations)][port_declarations]; parameter_declarations; // if no parameter ports are used other_declarations; statements; endmodule

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-3 Port Declarations  Three types  input  output  inout module adder(x, y, c_in, sum, c_out); input [3:0] x, y; input c_in; output reg [3:0] sum; output reg c_out;

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-4 Types of Parameters  module parameters  parameter  localparam  specify parameters parameter SIZE = 7; parameter WIDTH_BUSA = 24, WIDTH_BUSB = 8; parameter signed [3:0] mux_selector = 4’b0;

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-5 Constants Specified Options  `define compiler directive `define BUS_WIDTH 8  Parameter parameter BUS_WIDTH = 8;  localparam localparam BUS_WIDTH = 8;

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-6 Parameter Ports module module_name #(parameter SIZE = 7, parameter WIDTH_BUSA = 24, WIDTH_BUSB = 8, parameter signed [3:0] mux_selector = 4’b0 ) (port list or port list declarations)... endmodule

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-7 Module Instantiation  Syntax module_name [#(parameters)] instance_name [range]([ports]); module_name [#(parameters)] instance_name [{,instance_name}]([ports]);

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-8 Port Connection Rules  Named association.port_id1(port_expr1),...,.port_idn(port_exprn)  Positional association port_expr1,..., port_exprn

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-9 Parameterized Modules  An example module adder_nbit(x, y, c_in, sum, c_out); parameter N = 4; // set default value input [N-1:0] x, y; input c_in; output [N-1:0] sum; output c_out; assign {c_out, sum} = x + y + c_in; endmodule

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-10 Module Parameters Values  Ways to change module parameters values  defparam statement  module instance parameter value assignment

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-11 Overriding Parameters  Using the defparam statement // define top level module … output [3:0] qout4b; output [7:0] qout8b; // instantiate two counter modules defparam cnt_4b.N = 4, cnt_8b.N = 8; counter_nbits cnt_4b (clock, clear, qout4b); counter_nbits cnt_8b (clock, clear, qout8b); module counter_nbits (clock, clear, qout); parameter N = 4; // define counter size … clock or posedge clear) begin // qout <= (qout + 1) % 2^n if (clear) qout <= {N{1'b0}}; else qout <= (qout + 1) ; End

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-12 // define top level module … output [3:0] qout4b; output [7:0] qout8b; // instantiate two counter modules counter_nbits #(4) cnt_4b (clock, clear, qout4b); counter_nbits #(8) cnt_8b (clock, clear, qout8b); Overriding Parameters  Using module instance parameter value assignment--- one parameter module counter_nbits (clock, clear, qout); parameter N = 4; // define counter size … clock or posedge clear) begin // qout <= (qout + 1) % 2^n; if (clear) qout <= {N{1'b0}}; else qout <= (qout + 1) ; end

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-13 Overriding Parameters  Using module instance parameter value assignment --- two parameters // define top level module module … … hazard_static #(4, 8) example (x, y, z, f); module hazard_static (x, y, z, f); parameter delay1 = 2, delay2 = 5; … and #delay2 a1 (b, x, y); not #delay1 n1 (a, x); and #delay2 a2 (c, a, z); or #delay2 o2 (f, b, c); endmodule hazard_static #(.delay2(4),.delay1(6)) example (x, y, z, f); parameter value assignment by name --- minimize the chance of error!

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-14 Hierarchical Path Names  An identifier can be defined within  Modules  Tasks  Functions  Named blocks (See Section 7.1.3)  Hierarchical path names 4bit_adder // top level --- 4bit_adder 4bit_adder.fa_1 // fa_1 within 4bit_adder 4bit_adder.fa_1.ha_1 // ha_1 within fa_1 4bit_adder.fa_1.ha_1.xor1 // xor1 within ha_1 4bit_adder.fa_1.ha_1.xor1.S // net s within xor1

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-15 generate Block Structures  The keywords used  generate and endgenerate // convert Gray code into binary code parameter SIZE = 8; input [SIZE-1:0] gray; output [SIZE-1:0] bin; genvar i; generate for (i = 0; i < SIZE; i = i + 1) begin: bit assign bin[i] = ^gray[SIZE-1:i]; end endgenerate

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-16 The generate Loop Construct // convert Gray code into binary code parameter SIZE = 8; input [SIZE-1:0] gray; output [SIZE-1:0] bin; reg [SIZE-1:0] bin; genvar i; generate for (i = 0; i < SIZE; i = i + 1) begin:bit bin[i] = ^gray[SIZE - 1: i]; end endgenerate

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-17 An n-bit Adder // define a full adder at dataflow level. module full_adder(x, y, c_in, sum, c_out); // I/O port declarations input x, y, c_in; output sum, c_out; // Specify the function of a full adder. assign {c_out, sum} = x + y + c_in; endmodule

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-18 An n-bit Adder module adder_nbit(x, y, c_in, sum, c_out); … genvar i; wire [N-2:0] c; // internal carries declared as nets. generate for (i = 0; i < N; i = i + 1) begin: adder if (i == 0) // specify LSB full_adder fa (x[i], y[i], c_in, sum[i], c[i]); else if (i == N-1) // specify MSB full_adder fa (x[i], y[i], c[i-1], sum[i], c_out); else // specify other bits full_adder fa (x[i], y[i], c[i-1], sum[i], c[i]); end endgenerate

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-19 An n-bit Adder module adder_nbit(x, y, c_in, sum, c_out); … genvar i; wire [N-2:0] c; // internal carries declared as nets. generate for (i = 0; i < N; i = i + 1) begin: adder if (i == 0) // specify LSB assign {c[i], sum[i]} = x[i] + y[i] + c_in; else if (i == N-1) // specify MSB assign {c_out, sum[i]} = x[i] + y[i] + c[i-1]; else // specify other bits assign {c[i], sum[i]} = x[i] + y[i] + c[i-1]; end endgenerate

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-20 An n-bit Adder module adder_nbit(x, y, c_in, sum, c_out); … genvar i; reg [N-2:0] c; // internal carries declared as nets. generate for (i = 0; i < N; i = i + 1) begin: adder if (i == 0) // specify LSB {c[i], sum[i]} = x[i] + y[i] + c_in; else if (i == N-1) // specify MSB {c_out, sum[i]} = x[i] + y[i] + c[i-1]; else // specify other bits {c[i], sum[i]} = x[i] + y[i] + c[i-1]; end endgenerate

Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-21 A UDP Example // an example of sequential UDP instantiations parameter N = 4; input clk, clear; output [N-1:0] qout; …. genvar i; generate for (i = 0; i < N; i = i + 1) begin: ripple_counter if (i == 0) // specify LSB T_FF tff (qout[i], clk, clear); else // specify the rest bits T_FF tff (qout[i], qout[i-1], clear); end endgenerate