36
Digital System Design Verilog ® HDL Maziar Goudarzi

Digital System Design Verilog ® HDL Maziar Goudarzi

Embed Size (px)

Citation preview

Page 1: Digital System Design Verilog ® HDL Maziar Goudarzi

Digital System Design

Verilog® HDL

Maziar Goudarzi

Page 2: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 2

Today program

History of Verilog® HDLOverview of Digital Design with Verilog®

HDLHello World!Hierarchical Modeling Concepts

Page 3: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 3

History of Verilog® HDL

Beginning: 1983 “Gateway Design Automation” company Simulation environment

Comprising various levels of abstraction• Switch (transistors), gate, register-transfer, and higher

levels

Page 4: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 4

History of Verilog® HDL (cont’d)

Three factors to success of Verilog Programming Language Interface (PLI)

Extend and customize simulation environment Close attention to the needs of ASIC foundries

“Gateway Design Automation” partnership with Motorola, National, and UTMC in 1987-89

Verilog-based synthesis technology “Gateway Design Automation” licensed Verilog to

Synopsys Synopsys introduced synthesis from Verilog in 1987

Page 5: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 5

History of Verilog® HDL (cont’d)

VHDL VHSIC (Very High Speed Integrated Circuit)

Hardware Description Language Developed under contract from DARPA IEEE standard Public domain Other EDA vendors adapted VHDL “Gateway” put Verilog in public domain

Page 6: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 6

History of Verilog® HDL (cont’d)

Today Market divided between Verilog & VHDL

VHDL mostly in Europe Verilog dominant in US

VHDL More general language Not all constructs are synthesizable

Verilog: Not as general as VHDL Most constructs are synthesizable

Page 7: Digital System Design Verilog ® HDL Maziar Goudarzi

Verilog® HDL

Overview of Digital Design Using Verilog

Page 8: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 8

Overview of Digital Design Using Verilog

Evolution of Computer-Aided Digital DesignEmergence of HDLsTypical Design FlowImportance of HDLsPopularity of Verilog HDLTrends in HDLs

Page 9: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 9

Evolution of Computer-Aided Digital Design

SSI: Small scale integration A few gates on a chip

MSI: Medium scale integration Hundreds of gates on a chip

LSI: Large scale integration Thousands of gates on a chip CAD: Computer-Aided Design

CAD vs. CAE Logic and circuit simulators Prototyping on bread board Layout by hand (on paper or a computer terminal)

Page 10: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 10

Evolution of Computer-Aided Digital Design (cont’d)

VLSI: Very Large Scale Integration Hundred thousands of gates Not feasible anymore:

Bread boarding Manual layout design

Simulator programs Automatic place-and-route Bottom-Up design

Design small building blocks Combine them to develop bigger ones

More and more emphasis on logic simulation

Page 11: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 11

Emergence of HDLs

The need to a standardized language for hardware description Verilog® and VHDL

Simulators emerged Usage: functional verification Path to implementation: manual translation into gates

Logic synthesis technology Late 1980s Dramatic change in digital design

Design at Register-Transfer Level (RTL) using an HDL

Page 12: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 12

Typical Design Flow (in 1996)

1. Design specification2. Behavioral description3. RTL description4. Functional verification and testing5. Logic synthesis6. Gate-level netlist7. Logical verification and testing8. Floor planning, automatic place & route9. Physical layout10. Layout verification11. Implementation

Page 13: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 13

Typical Design Flow (cont’d)

Most design activity In 1996:

Manually optimizing the RTL design CAD tools take care of generating lower-level details Reducing design time to months from years

Today Still RTL is used in many cases But, synthesis from behavioral-level also possible Digital design now resembles high-level computer

programming

Page 14: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 14

Typical Design Flow (cont’d)

NOTE: CAD tools help, but the designer still has the

main role GIGO (Garbage-In Garbage-Out) concept To obtain an optimized design, the designer needs to

know about the synthesis technology• Compare to software programming and compilation

Page 15: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 15

Importance of HDLs

Retargeting to a new fabrication technology

Functional verification earlier in the design cycle

Textual concise representation of the design Similar to computer programs Easier to understand

Page 16: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 16

Popularity of Verilog HDL

Verilog HDL General-purpose Easy to learn, easy to use Similar in syntax to C Allows different levels of abstraction and mixing them Supported by most popular logic synthesis tools Post-logic-synthesis simulation libraries by all

fabrication vendors PLI to customize Verilog simulators to designers’ needs

Page 17: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 17

Trends in HDLs

Design at behavioral levelFormal verification techniquesVery high speed and time critical circuits

e.g. microprocessors Mixed gate-level and RTL designs

Hardware-Software Co-design System-level languages: SystemC, SpecC, …

Page 18: Digital System Design Verilog ® HDL Maziar Goudarzi

Verilog® HDL

Hello World!

Page 19: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 19

Basics of Digital Design Using HDLs

Circuit Under Design(CUD)

84

Generatinginputs to CUD

Checkingoutputsof CUD

Test bench

Stimulus block

Page 20: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 20

ModelSim® Simulation Environment

You’ll see in the laboratory

Page 21: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 21

Verilog Basic Building Block

Module

module not_gate(in, out); // module name+ports // comments: declaring port type input in; output out;

// Defining circuit functionality assign out = ~in;

endmodule

Page 22: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 22

useless Verilog Example

module useless;

initial

$display(“Hello World!”);

endmodule

Note the message-display statement Compare to printf() in C

Page 23: Digital System Design Verilog ® HDL Maziar Goudarzi

Verilog® HDL

Hierarchical Modeling Concepts

Page 24: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 24

Design Methodologies

Page 25: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 25

4-bit Ripple Carry Counter

Page 26: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 26

T-flipflop and the Hierarchy

Page 27: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 27

Modules

module <module_name>(<module_terminal_list>); ... <module internals> ...endmodule

Example:module T_ff(q, clock, reset); ... <functionality of T_flipflop> ...endmodule

Page 28: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 28

Modules (cont’d)

Verilog supported levels of abstraction Behavioral (algorithmic) level

Describe the algorithm used Very similar to C programming

Dataflow level Describe how data flows between registers and is processed

Gate level Interconnect logic gates

Switch level Interconnect transistors (MOS transistors)

Register-Transfer Level (RTL) Generally known as a combination of behavioral+dataflow that is

synthesizable by EDA tools

Page 29: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 29

Instances

module ripple_carry_counter(q, clk, reset);

output [3:0] q; input clk, reset;

//4 instances of the module TFF are created.

TFF tff0(q[0],clk, reset); TFF tff1(q[1],q[0], reset); TFF tff2(q[2],q[1], reset); TFF tff3(q[3],q[2], reset);

endmodule

Page 30: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 30

Instances (cont’d)

module TFF(q, clk, reset); output q; input clk, reset; wire d;

DFF dff0(q, d, clk, reset); not n1(d, q); // not is a Verilog provided primitive.

endmodule

// module DFF with asynchronous resetmodule DFF(q, d, clk, reset); output q; input d, clk, reset; reg q;

always @(posedge reset or negedge clk) if (reset)

q = 1'b0; else

q = d;

endmodule

Page 31: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 31

Instances (cont’d)

Illegal instantiation example: Nested module definition not allowed Note the difference between module definition and module instantiation

// Define the top level module called ripple carry// counter. It is illegal to define the module T_FF inside// this module.module ripple_carry_counter(q, clk, reset); output [3:0] q; input clk, reset;

module T_FF(q, clock, reset);// ILLEGAL MODULE NESTING:<module T_FF internals>:endmodule // END OF ILLEGAL MODULE NESTING

endmodule

Page 32: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 32

Simulation- Test Bench Styles

Page 33: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 33

Example

Design block was shown before ripple_carry_counter, T_FF, and D_FF modules

Stimulus block

Page 34: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 34

Example (cont’d)

module stimulus; reg clk; reg reset; wire[3:0] q;

// instantiate the design block ripple_carry_counter r1(q, clk, reset);

// Control the clk signal that drives the design block. initial clk = 1'b0; always #5 clk = ~clk;

// Control the reset signal that drives the design block initial begin reset = 1'b1; #15 reset = 1'b0; #180 reset = 1'b1; #10 reset = 1'b0; #20 $stop; end

initial // Monitor the outputs $monitor($time, " Output q = %d", q);endmodule

Page 35: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 35

What we learned today

History of Verilog HDLPrinciples of digital design using HDLsOur first Verilog design example

Page 36: Digital System Design Verilog ® HDL Maziar Goudarzi

2005 Verilog HDL 36

Other Notes

Course web-page http://ce.sharif.edu/courses

Exercise 1 Install and use ModelSim in the lab. to simulate ripple_carry_counter example

Chapter 2 exercises