23
Verilog HDL Verilog HDL Gookyi Dennis A. N. Gookyi Dennis A. N. ([email protected]) ([email protected]) May.27.2014

Verilog hdl

Embed Size (px)

Citation preview

Page 1: Verilog hdl

Verilog HDL Verilog HDL Verilog HDL Verilog HDL

Gookyi Dennis A. N.Gookyi Dennis A. N.

([email protected])([email protected])

May.27.2014

Page 2: Verilog hdl

ContentsContents Module Modeling Styles

Modules Structural Modeling Dataflow Modeling Behavioral Modeling Mixed-Style Modeling

Simulation Basic Simulation Constructs Related Compiler Directive and System Tasks

2

Page 3: Verilog hdl

Modules Modules A Verilog HDL module consist of two major parts:

The interfaceThe internal (body)

Block diagram of a full adder is shown below

3

Page 4: Verilog hdl

The Interface: Port The Interface: Port DeclarationDeclaration The interface signals can be grouped into one of the

following three types: input, output or inout A complete interface can be divided into three parts:

port list, port declaration and data type declaration

4

Page 5: Verilog hdl

Port DeclarationPort Declaration The declaration of a port and its associated data type

can be combined into a single line as below:

Port list, port declaration and their associated data types can be put into a single list. This is called port list declaration or ANSI C style

5

Page 6: Verilog hdl

Port ConnectionsPort Connections Two methods are used to connect ports to external

signals:Named association: ports to be connected to external

signals are specified by listing their names. The order of the ports is not important

Positional association: the signals to be connected must have the same order as in the port list. All unconnected ports are left blank

The two methods cannot be mixed

6

Page 7: Verilog hdl

Port ConnectionsPort Connections

7

Page 8: Verilog hdl

Modeling the Internal of a Modeling the Internal of a ModuleModule The internal or body can be modeled using one of the

following styles:Structural Style

Gate levelSwitch level

Dataflow StyleBehavioral StyleMixed Style

RTL = Behavioral + Dataflow Styles

8

Page 9: Verilog hdl

Structural ModelingStructural Modeling Structural modeling of a design is by connecting

required instantiations of built-in primitives, user defined primitives or other modules through nets

Structural style is one way to model a complex digital system in a hierarchical manner

9

Page 10: Verilog hdl

Structural ModelingStructural Modeling

10

Page 11: Verilog hdl

Dataflow ModelingDataflow Modeling The module is described by specifying the data flow

between registers and how the data is processed This is done through a set of continuous assignment

statements A continuous assignment starts with the keyword

assign and has a syntax as below:

assign [delay] l_value = expression;

11

Page 12: Verilog hdl

Dataflow ModelingDataflow Modeling The block diagram of a full adder is shown below:

12

Page 13: Verilog hdl

Waveform Waveform

13

Page 14: Verilog hdl

Behavioral ModelingBehavioral Modeling The module is described in terms of the desired

design algorithm without concerning the hardware implementation details

The module uses procedural constructs: initial and always

14

Page 15: Verilog hdl

Mixed modelingMixed modeling The design is described in terms of the mixing of the

previous styles It is most commonly used in modeling large designs Register-Transfer level (RTL) is usually used in

industry to mean the combination of behavioral and dataflow constructs

Below is a full adder constructed with basic logic gates:

15

Page 16: Verilog hdl

Mixed modelingMixed modeling

16

Page 17: Verilog hdl

Simulation Simulation For a design to be useful, it must be verified to make

sure that it can operate according to the requirement Two basic simulation structures are available in

Verilog:The first is to take the UUT as an instantiated module in

the stimulus moduleThe second considers both stimulus block and UUT as

the separate instantiated module at the top-level module

17

Page 18: Verilog hdl

Related Compiler Directives: Related Compiler Directives: `timescale Directive`timescale Directive In simulations, we need to specify the physical unit of

measure This is accomplished using:

`timescale time_unit/time_precision

time unit : This is the time to be used as one unit for all the delays used in the design.

time precision : This represents the minimum delay which needs to be considered during simulation or it decides that how many decimal point would be used with the time unit.

18

Page 19: Verilog hdl

`timescale Directive`timescale Directive Code

Waveform

19

Page 20: Verilog hdl

`timescale Directive`timescale Directive Code

Waveform

20

Page 21: Verilog hdl

A Complete TestbenchA Complete Testbench Block diagram

21

Page 22: Verilog hdl

A Complete TestbenchA Complete Testbench

22

Page 23: Verilog hdl

WaveformWaveform

23