Digital System Design Verilog ® HDL Design at Structural Level Maziar Goudarzi.

Slides:



Advertisements
Similar presentations
Verilog HDL -Introduction
Advertisements

//HDL Example 4-10 // //Gate-level description of circuit of Fig. 4-2 module analysis (A,B,C,F1,F2); input.
Verilog.
Simulation executable (simv)
ELEN 468 Lecture 61 ELEN 468 Advanced Logic Design Lecture 6 Delay Models.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Verilog Intro: Part 1.
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.
1 Brief Introduction to Verilog Weiping Shi. 2 What is Verilog? It is a hardware description language Originally designed to model and verify a design.
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Digital System Design Verilog ® HDL Timing and Delays Maziar Goudarzi.
Lecture 2: Hardware Modeling with Verilog HDL
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.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Digital System Design Verilog ® HDL Modules and Ports Maziar Goudarzi.
Digital System Design Verilog ® HDL Maziar Goudarzi.
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Chap. 2 Hierarchical Modeling Concepts. 2 Hierarchical Modeling Concepts Design Methodologies 4-bit Ripple Carry Counter Modules Instances Components.
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.
ENG6090 RCS1 ENG6090 Reconfigurable Computing Systems Hardware Description Languages Part 5: Modeling Structure.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
Digital System Design Introduction to Verilog ® HDL Maziar Goudarzi.
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.
Module 1.2 Introduction to Verilog
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.
Switch Level Modeling Part II 26 September Contents 1.Clarifications: a)nMOS and pMOS instantiations b)Testbenches for NOR gate example c)Use of.
M.Mohajjel. Continuous Assignments Continuously Drive a value onto a net Left hand side must be net Right hand side registers nets function calls Keyword.
Chapter 2: Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 2-1 Chapter 2a: Structural Modeling.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Introduction to ASIC flow and Verilog HDL
Introduction to Verilog
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-1 Chapter 6: Hierarchical.
Unit 4 Structural Descriptions SYLLABUS Highlights of Structural descriptions Organization of the Structural descriptions Binding State Machines Generate(HDL),Generic(VHDL),
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.
Introduction to Verilog COE 202 Digital Logic Design Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals.
Structural Description
Hardware Description Languages: Verilog
Chapter 4 Modules and Ports
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.
Discussion 2: More to discuss
Verilog Introduction Fall
Lecture 2 Supplement Verilog-01
Hardware Description Languages: Verilog
Hardware Description Languages
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Chapter 2a: Structural Modeling
OUTLINE Introduction Basics of the Verilog Language
Introduction to Verilog
Verilog.
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
CS 153 Logic Design Lab Professor Ian G. Harris
The Verilog Hardware Description Language
Introduction to Verilog® HDL
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Digital System Design Verilog ® HDL Design at Structural Level Maziar Goudarzi

Verilog ® HDL Modules and Ports 2010DSD2

Today program Components of a Verilog Module Defining and Connecting Ports 2010DSD3

Modules 2010DSD4

SR-Latch Example 2010DSD5 module SR_latch(Q, Qbar, Sbar, Rbar); output Q, Qbar; input Sbar, Rbar; // Instantiate lower level modules nand n1(Q, Sbar, Qbar); nand n2(Qbar, Rbar, Q); endmodule module Top; wire q, qbar; reg set, reset; // Instantiate lower level modules. In this case, instantiate SR_latch // Feed inverted set and reset signals to the SR latch SR_latch l1(q, qbar, ~set, ~reset); // Behavioral block, initial 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

2010DSD6

2010DSD7

Ports Interface of the module to the environment – Internals of the module invisible to the environment – Internals can change as long as the interface (ports) not changed Items to define – Port list – Port mode – Port type ( reg or wire, and bit-width) 2010DSD8

List of Ports 2010DSD9 Example: 4-bit full-adder inside a top module 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 All ports in the list of ports must be declared in the module Example: 2010DSD10 module fulladd4(sum, c_out, a, b, c_in); output [3:0] sum; output c_out; input [3:0] a, b; input c_in;... endmodule

Port Declaration (cont’d) Note: all ports are wire by default – No need to declare it again as wire – If expected to be reg, the port needs to be declared again (only valid for output ports. Why?) – Example: the q port in DFF module module DFF(q, d, clk, reset); output q; reg q; // Output port q holds value => reg input d, clk, reset;... endmodule 2010DSD11

ANSI C Style Port Declaration Syntax 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 endmodule 2010DSD12

Module Instantiation 2010DSD13 Recall the Ripple-carry counter and TFF module T_FF(q, clk, reset); output q; input clk, reset;... endmodule module ripple_carry_counter(q, clk, reset); output [3:0] q; input clk, reset; //4 instances of the module TFF are created. T_FF tff0(q[0],clk, reset); T_FF tff1(q[1],q[0], reset); T_FF tff2(q[2],q[1], reset); T_FF tff3(q[3],q[2], reset); endmodule

Module Instantiation (cont’d) General syntax (port connection list); Example: // assuming “ module ripple_carry_counter(q, clk, reset);” ripple_carry_counter cntr1(wire_vec1, wire2, wire3); 2010DSD14

Port Connection Rules Two parts of a port: – internal to module (when defining the module) – external to module (when instantiating the module) 2010DSD15

Port Connection Rules (cont’d) Width matching – Legal to connect items of different sizes A warning may be issued by Verilog simulator Unconnected ports – Allowed in Verilog – Example: // assuming “module fulladd4(sum, c_out, a, b, c_in);” fulladd4 fa0(SUM,, A, B, C_IN); // output port c_out is unconnected 2010DSD16

Port Connection Rules (cont’d) module Top; 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); // legal or Illegal? Why?... endmodule // Top 2010DSD17 module fulladd4(output reg [3:0] sum, output reg c_out, input [3:0] a, b, input c_in);... endmodule

2010DSD18

Port Mapping Connecting by ordered list – More intuitive for beginners – Mostly used when having few ports Connecting by name – Used when having more ports – Gives independence from order of ports The order of ports in the port list of a module can be changed without changing the instantiations 2010DSD19

Connecting by Ordered List module fulladd4(sum, c_out, a, b, c_in);... endmodule module Top; // Declare connection variables reg [3:0] A, B; reg C_IN; wire [3:0] SUM; wire C_OUT; // Signals are connected to ports in order (by position) fulladd4 fa_ordered(SUM, C_OUT, A, B, C_IN);... endmodule 2010DSD20

Connecting Ports by Name module fulladd4(sum, c_out, a, b, c_in);... endmodule module Top; // Declare connection variables reg [3:0] A, B; reg C_IN; wire [3:0] SUM; wire C_OUT; // Signals are connected to ports by name fulladd4 fa_byname(.c_out(C_OUT),.sum(SUM),.b(B),.a(A));... endmodule 2010DSD21

Hierarchical Names Hierarchical design – An identifier for every signal, variable, or module instance – The same identifier can be used in different levels of the hierarchy – Hierarchical name referencing Unique name to every identifier in the hierarchy Syntax: DSD22

Hierarchical Names (cont’d) 2010DSD23

Hierarchical Names (cont’d) module stimulus; wire q, qbar; reg set, reset; SR_latch m1(q, qbar, ~set, ~reset); initial... endmodule module SR_latch(Q, Qbar, S, R); output Q, Qbar; input S, R; nand n1(Q, S, Qbar); nand n2(Qbar, R, Q); endmodule Hierarchical names stimulus stimulus.q stimulus.qbar stimulus.setstimulus.resetstimulus.m1 stimulus.m1.Qstimulus.m1.Qbarstimulus.m1.S stimulus.m1.Rstimulus.m1.n1stimulus.m1.n2 2010DSD24

Have you learned this topic? How to – Define modules – Instantiate modules – Do port mapping Components of a module Hierarchical Design in Verilog HDL ® 2010DSD25

Today Objectives Add Switch modeling Primitive gates in Verilog Structural design using primitive gates Gate-level delay types and syntax 2010DSD26

Primitive Gates in Verilog: And/Or Gates 2010DSD27

And/Or Gates Examples Syntax – Similar to module instantiations Examples wire out, in1, in2, in3; and a1(out, in1, in2); nand na1(out, in1, in2); nand na1_3inp(out, in1, in2, in3); and (out, in1, in2); // Legal gate instantiation. No need to instance name. 2010DSD28

201029

Buf/Not Gates Exactly one input, but multiple outputs 2010DSD30

Buf/Not Gate Examples // basic gate instantiations. buf b1(OUT1, IN); not n1(OUT1, IN); // More than two outputs buf b1_2out(OUT1, OUT2, IN); // gate instantiation without instance name not (OUT1, IN); // legal gate instantiation 2010DSD31

Bufif/Notif Gates 2010DSD32

Bufif/Notif Examples //Instantiation of bufif gates. bufif1 b1 (out, in, ctrl); bufif0 b0 (out, in, ctrl); //Instantiation of notif gates notif1 n1 (out, in, ctrl); notif0 n0 (out, in, ctrl); 2010DSD33

Arrays of Gate Instances Multiple instantiations wire [7:0] OUT, IN1, IN2; nand n0(OUT[0], IN1[0],IN2[0]); nand n1(OUT[1], IN1[1],IN2[1]); nand n2(OUT[2], IN1[2],IN2[2]); nand n3(OUT[3], IN1[3],IN2[3]); nand n4(OUT[4], IN1[4],IN2[4]); nand n5(OUT[5], IN1[5],IN2[5]); nand n6(OUT[6], IN1[6],IN2[6]); nand n7(OUT[7], IN1[7],IN2[7]); Array of instances wire [7:0] OUT, IN1, IN2; nand n[7:0](OUT, IN1, IN2); 2010DSD34

Examples: 4-to-1 Multiplexer 2010DSD35

Examples: 4-to-1 Multiplexer (cont’d) module mux4_to_1 (output out, input i0, i1, i2, i3, s1, s0); wire s1n, s0n; wire y0, y1, y2, y3; not (s1n, s1); not (s0n, s0); and (y0, i0, s1n, s0n); and (y1, i1, s1n, s0); and (y2, i2, s1, s0n); and (y3, i3, s1, s0); or (out, y0, y1, y2, y3); endmodule 2010DSD36

Stimulus Block module stimulus; reg IN0, IN1, IN2, IN3; reg S1, S0; wire OUTPUT; mux4_to_1 mymux(OUTPUT, IN0, IN1, IN2, IN3, S1, S0); initial begin IN0 = 1; IN1 = 0; IN2 = 1; IN3 = 0; #1 $display("IN0= %b, IN1= %b, IN2= %b, IN3= %b\n",IN0,IN1,IN2,IN3); S1 = 0; S0 = 0; #1 $display("S1 = %b, S0 = %b, OUTPUT = %b \n", S1, S0, OUTPUT); S1 = 0; S0 = 1; #1 $display("S1 = %b, S0 = %b, OUTPUT = %b \n", S1, S0, OUTPUT); S1 = 1; S0 = 0; #1 $display("S1 = %b, S0 = %b, OUTPUT = %b \n", S1, S0, OUTPUT); S1 = 1; S0 = 1; #1 $display("S1 = %b, S0 = %b, OUTPUT = %b \n", S1, S0, OUTPUT); end endmodule 37

Examples: 4-bit ripple-carry full adder 2010DSD38 module fulladd(output sum, c_out, input a, b, c_in); wire s1, c1, c2; xor (s1, a, b); and (c1, a, b); xor (sum, s1, c_in); and (c2, s1, c_in); xor (c_out, c2, c1); endmodule C2

Examples: 4-bit ripple-carry full adder (cont’d) 2010DSD39 module fulladd4( output [3:0] sum, output c_out, input [3:0] a, b, input c_in); wire c1, c2, c3; // Instantiate four 1-bit full adders. fulladd fa0(sum[0], c1, a[0], b[0], c_in); fulladd fa1(sum[1], c2, a[1], b[1], c1); fulladd fa2(sum[2], c3, a[2], b[2], c2); fulladd fa3(sum[3], c_out, a[3], b[3], c3); endmodule

Stimulus Block 2010DSD40 module stimulus; reg [3:0] A, B; reg C_IN; wire [3:0] SUM; wire C_OUT; fulladd4 FA1_4(SUM, C_OUT, A, B, C_IN); initial $monitor($time," A= %b, B=%b, C_IN= %b, --- C_OUT= %b, SUM= %b\n“, A, B, C_IN, C_OUT, SUM); initial begin A = 4'd0; B = 4'd0; C_IN = 1'b0; #5 A = 4'd3; B = 4'd4; #5 A = 4'd2; B = 4'd5; #5 A = 4'd9; B = 4'd9; #5 A = 4'd10; B = 4'd15; #5 A = 4'd10; B = 4'd5; C_IN = 1'b1; end endmodule

Delay Models and Gate Level Delays 2010DSD41

Delay Models Transport Delay Model – Path delay, Pin-to-pin delay, propagation delay Inertial Delay Model – Input Inertial delay – Output Inertial delay 2010DSD42

Gate Delays in Verilog Rise delay Fall delay Turn-off delay Delay for value change to x 2010DSD43

Specifying Gate Delay // Delay of delay_time for all transitions and #(delay_time) a1(out, i1, i2); // Rise and Fall Delay Specification. and #(rise_val, fall_val) a2(out, i1, i2); // Rise, Fall, and Turn-off Delay Specification bufif0 #(rise_val, fall_val, turnoff_val) b1 (out, in, control); Examples: and #(5) a1(out, i1, i2); //Delay of 5 for all transitions and #(4,6) a2(out, i1, i2); // Rise = 4, Fall = 6 bufif0 #(3,4,5) b1 (out, in, control); // Rise = 3, Fall = 4, Turn-off = DSD44

Min/Typ/Max Delay values Can be separately specified for each delay type // One delay // if +mindelays, delay= 4 // if +typdelays, delay= 5 // if +maxdelays, delay= 6 and #(4:5:6) a1(out, i1, i2); // Two delays // if +mindelays, rise= 3, fall= 5, turn-off = min(3,5) // if +typdelays, rise= 4, fall= 6, turn-off = min(4,6) // if +maxdelays, rise= 5, fall= 7, turn-off = min(5,7) and #(3:4:5, 5:6:7) a2(out, i1, i2); // Three delays // if +mindelays, rise= 2 fall= 3 turn-off = 4 // if +typdelays, rise= 3 fall= 4 turn-off = 5 // if +maxdelays, rise= 4 fall= 5 turn-off = 6 bufif0 #(2:3:4, 3:4:5, 4:5:6) a3(out, in, ctrl); 45

2010DSD46

Delay Example module stimulus; reg A, B, C; wire OUT; D d1( OUT, A, B, C); initial begin A= 1'b0; B= 1'b0; C= 1'b0; #10 A= 1'b1; B= 1'b1; C= 1'b1; #10 A= 1'b1; B= 1'b0; C= 1'b0; #20 $finish; end endmodule DSD47

Have you learned this topic? Implement a given gate-level circuit diagram in Verilog Implement arrays of gates Specify delays for the gates you model Follow the propagation of events with gate delays 2010DSD48