Verilog HDL

HasmukhPKoringa 605 views 76 slides Aug 23, 2023
Slide 1
Slide 1 of 76
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76

About This Presentation

This presentation contain Verilog HDL language


Slide Content

Dr. HasmukhP Koringa,
EC Dept.
Government Engineering College Rajkot
VerilogHDL

Acknowledgment
Verilog HDL Dr. H P Koringa
2
Thispresentationissummarizeandtaken
referencesfromvariousbooks,papers,websites
andpresentationonVerilogHDL.Iwouldliketo
thankstoallprofessors,researchersandauthors
whohavecreatedsuchgoodworkonthisVerilog
HDL.MyspecialthankstoVerilogHDLbook
authorSamirpalnitkar.

 Verilog/VHDL is Used
Verilog HDL Dr. H P Koringa
3

What is Verilog?
It is a Hardware Description Language ( HDL )to design the digital
system.
Two major HDL languages:
-Verilog
-VHDL
Verilog is easier to learn and use (It is like the C language).
VerilogHDL is both behavioral and structural language
It is case sensitive language
Models of verilogHDL can describe both function of design and the
components
It can also define connection of components in design
Verilog HDL Dr. H P Koringa
4

History
Verilog HDL Dr. H P Koringa
5
Verilogwas invented by PhilMoorbyand PrabhuGoelin
1983/1984 at Gateway Design automation.
GDA was purchased by CandenceDesign system in 1990.
Originally, verilogwas intended for describe and simulation
only.
Later support for synthesis added.
Cadence transferred Veriloginto the public domain under the
Open VerilogInternational (OVI).

Verilogwas later submitted to IEEE and became IEEE
standard 1364-1995, commonly referred to as Verilog-95.

History
Verilog HDL Dr. H P Koringa
6
Verilog2001 Extensions to Verilog-95 were submitted back to
IEEE to cover few limitation of Verilog-95.
This extension become IEEE Standard 1364-2001 known as
Verilog-2001.
Verilog-2001 is the dominant flavorof Verilogsupported by the
majority of commercial EDA software packages.
Today all EDA developer companies are using Verilog-2001.
Verilog2005 : Don’t be confused with System Verilog, Verilog
2005 (IEEE Standard 1364-2005) consists of minor corrections.

A separate part of the Verilogstandard, Verilog-AMS, attemmpts
to integrate analogand mixed signal modelingwith traditional
Verilog.

History
Verilog HDL Dr. H P Koringa
7
System Verilogis a superset of Verilog-2005 with new features and
capabilities to aid design-verification and design- modeling.
As of 2009, the System Verilogand Veriloglanguage standards
were merged into System Verilog2009 (IEEE Standard 1800-
2009).
The advent of hardware verification language such as Open Vera,
System C encouraged the development of Superlogby Co-Design
Automation Inc.
Co-Design Automation Inc was later purchased by Synopsys.
The foundations of Superlogand Vera were donated to Accellera,
which later became the IEEE standard 1800- 2005: System Verilog.

Design Methodology
Verilog HDL Dr. H P Koringa
8
Based on Design Hierarchy
Based on Abstraction

Based on Design Hierarchy
Verilog HDL Dr. H P Koringa
9
Top Down Design Methodology
Bottom Up Design Methodology

Top Down Design Methodology
Verilog HDL Dr. H P Koringa
10

Verilogcode for 4 bit binary parallel
adder
Verilog HDL Dr. H P Koringa
11
module adder4 (A,B,S,C); //module name and port list
input [3..0] A,B; // port declaration
output [3..0] S;
output c;
fulladderadd0 (.A[0](a), .B[0](b), .S[0](s),

Bottom Up Design Methodology
Verilog HDL Dr. H P Koringa
12

Based on Abstraction Level
Verilog HDL Dr. H P Koringa
13
BehavioralLevel
Data Flow Level
Gate Level
Switch Level

Based on Abstraction Level
Verilog HDL Dr. H P Koringa
14
BehavioralLevel
Data Flow Level
Gate Level
Switch Level

Lexical Conventions
Close to C / C++.
Comments:
// Single line comment
/* multiple
lines
comments */
/b Black Space
/t Tab Space
/n New line

CaseSensitive:
Keywords:
-Reserved.
-lower case.
-Examples: module, case, initial, always.

Number:
decimal, hex, octal, binary
Verilog HDL Dr. H P Koringa
15

Identifier
•A ... Z ,a ... z ,0 ... 9 , Underscore , $
Strings are limited to 1024 chars
First char of identifier must not be a digit and $
Verilog HDL Dr. H P Koringa
16

Numbers:
<size>’<base format><number>
-Size: No. of bits (optional)( default size is 32 bits).
-Base format: b: binary
d : decimal
o : octal
h : hexadecimal
(DEFAULT IS DECIMAL)
Verilog HDL Dr. H P Koringa
17

Verilog HDL Dr. H P Koringa
18
Underscore character
-Underscore can be place between digit of number
Data= 16’b 1010_1100_0011 _0101;
-Note: Never put starting digit as underscore
String:
var= " Enclose between quotes on a single line“;
Verilogsupport string data type assignment and treated as
ASCII character.

Program Structure
Verilog describes a system as a set of modules.
Each module has an interface to other modules.
Usually:
-Each module is put in a separate file.
-One top level module that contains:
Instances of hardware modules.
Test data.

Modules can be specified:
-Behaviorally.
-Structurally.
Verilog HDL Dr. H P Koringa
19

Module
General definition
module module_name( port_list);
port declarations;

variable declaration;

description of behavior;

task and function;
endmodule
module HalfAdder(A, B, Sum Carry);
inputA, B;
outputSum, Carry;
assignSum = A ^ B;
//^ denotes XOR
assignCarry = A & B; // & denotes AND
endmodule
Verilog HDL Dr. H P Koringa
20

Port
Verilog HDL Dr. H P Koringa
21
input
output
inout

regand wiredata objects may have a value of:
-0: logical zero
-1: logical one
-x: unknown
-z: high impedance
Registers are initialized to x at the start of simulation.
Any wire not connected to something has the value x .
Verilog HDL Dr. H P Koringa
22

Physical Data Types
Registers (reg ):
-Store values
reg[7:0] A;// 8-bit register
regX; // 1-bit register
How to declare a memory in verilog?
reg[7:0] A [1023:0];// A is 1K words each 8-bits

Wires ( wire ):
-Do not store a value.
-Represent physical connections between entities.
wire [7:0] A;
wireX;
Verilog HDL Dr. H P Koringa
23

Nets/Wire
Verilog HDL Dr. H P Koringa
24
In Verilogdefault declaration of any variable is net/wire type.
A net/wire does not store value except for trireg net.
Net/wire must be driven by such as gate or continuous
assignment.
If no driver connected to net, it value will be high impedance
(z).
Multi bit wire: wire [31..0] data_bus32

Advanced Net types
Verilog HDL Dr. H P Koringa
25
tri: it is similar to wire as syntax wise as well as functionally
Only difference between tri and wire is, wire denote single
driver, while tri means multiple driver.

Advanced Net Types
Verilog HDL Dr. H P Koringa
26
trireg: triregis wire except that when the net having capacitive
effect.
Capacitive effect means it can store previous value.
Therefore it work on two state.
Driver state: when the driver net having value 1,0,x then the driver
net follow the driver net.

Capacitive state: when driver net unconnected or having high
impedance then driver net hold last value.

Advanced Net Types
Verilog HDL Dr. H P Koringa
27
trio & tri1 : trio & tri1 are resistive Pulldownand pullup
devices.
when the value of the driving net is high then driven net will
get a value of the input.
When the value of the driving net is low the driven net get a
value of pulldown or pullup.
Ex: trio y;
buff tristate(y,a,ctrl); // when control signal is high, y=a;
// when control signal is low ; y=0 instead of high impedence.

Advanced Net Types
Verilog HDL Dr. H P Koringa
28
supply0 & supply1 : these are used to model ground and
power.
Ex: supply1 VDD;
supply0 GND;
wor, wand, triorand triand:
When one single net is driven by two net having same signal
strength then it is difficult to determine the output of driven
net.
In this case we can use the output oringor andingon both the
nets.

Register
Verilog HDL Dr. H P Koringa
29
Declaration
reg<signed><range><list_of_register_variables>;
regdata; // single bit variable
regsigned [7..0] data_bus;// multiple bit signed variable
reg[7..0] data_bus // multiple bit unsigned variable
Integer: This is general regtype variable. Use to manipulate
mathematical calculation.
This is 32 bit integer sign number
Ex: integer data; // 32 bit signed value;

Real
Verilog HDL Dr. H P Koringa
30
real: This is real register data type.
Default value of real data type is zero.
Ex: real data=3.34;
real data 2e6;//2*10^6
Note: real value can not be passed from one module to another
module.

Vector
Verilog HDL Dr. H P Koringa
31
Vector bit select: reg[31..0] data;
bit_select=data[7];
Vector part select: reg[31..0] data;
part_select=data[7..0];
reg[0..31] data_bus;
part_select= data_bus[0..7];
Variable vector part select:
variable_name[<starting_bit>+:width]
byte_select= data_bus[16+:8]; //starting from 16 to 23
variable_name[<starting_bit- >:width];
byte_select= data_bus[16-:8]; //starting from 9 to 16

Verilog HDL Dr. H P Koringa
32
Memory: memory is multi bit array
Ex. reg[7..0] mem_data[0..N-1];
Parameter: To declare constant value in Verilogparameter is
used.
Localparam:
LocalparamWD=32

Verilogsystem task
Verilog HDL Dr. H P Koringa
33
To perform routing operation (to display output value, simulation
time etc.)
System task start with $
Ex. $display
$monitor
$strobe
$write
$time
$finish
$recordfile
$dumpfile

Display
Verilog HDL Dr. H P Koringa
34
Display Information: Value can be display in binary,
hexadecimal, octal or decimal.

VerilogCompiler Directive
Verilog HDL Dr. H P Koringa
35
Compiler directive: compiler directive are define in
Verilogor macro.
These macro are define like ‘<keyword>
Ex. ‘timescale 1ns/1ns
‘define data_width8
‘include‘ifdefine

Timescale
Verilog HDL Dr. H P Koringa
36
‘timescale <reference time unit>/<precision>;
Ex. ‘timescale 1ns/1ps;
#1.003; //will be consider as valid delay
#1.0009; // will be consider as 1ns delay

Gate level abstraction
Verilog HDL Dr. H P Koringa
37
This is also know as structural abstraction.
Design is describe in terms of gates.
Very easy to write code if design in structural form.
For large circuit its very difficult to implement using gate
level.

Basic gate primitive in Verilog
Verilog HDL Dr. H P Koringa
38

Basic gate primitive in Verilog
Verilog HDL Dr. H P Koringa
39

Basic gate primitive in Verilog
Verilog HDL Dr. H P Koringa
40

Example Verilogdesign using
gate level abstraction
1-bit full adder circuit
Expression
Sum = (in1 xorin2 xorcin)
Carryout = (in1 and in2 ) or (in2 and cin) or
(in1 and cin)
in1
in2
cin
sum
cout
1-bit Full adder circuit
Verilog HDL Dr. H P Koringa
41

Structural model of a full adder circuit
modulefadd(in1, in2, cin, sum,cout);
inputin1,in2, cin;
output sum, cout;
wirex1,a1,a2,a3,o1,o2;
xor(x1,in1,in2);
xor(sum,x1,cin);
and(a1,in1,in2);
and(a2,in1,cin);
and(a3,in2,cin);
or(o1, a1,a2);
or(cout,o1,a3);
endmodule
Verilog HDL Dr. H P Koringa
42

Gate Delay
Verilog HDL Dr. H P Koringa
43
Rise delay
Fall delay
Turn-off delay
Gate output transition to high impedance state (z).

Gate delay examples
Verilog HDL Dr. H P Koringa
44
and # (5) a1 (out,in1 ,in2); //delay 5 for all transition.
and # (4,5) a2(out,in1 ,in2); //rise =4, fall =5 and turn-
off=min (4,5)

Bufif0 #(3,4,5) b1(out,in,cntr); //rise=3,fall=4 and turn-
off=5;

Min/Typ/Max values
Verilog HDL Dr. H P Koringa
45
For each type of delay-rise, fall and turn- off-three values
min, typand max can be specified.
Min/Typ/Max values are used to model devices whose
delays varies within min to max range because of IC
fabrication process variations.
Ex. and #(3:4:5) a1(out,in1 ,in2); // when one delay is
specified.
and # (3:4:5, 4:5:6) a2(out,in1 ,in2); // when two delays are
specified.
and #(3:4:5, 3:4:5, 4:5:6) a3(out,in1 ,in2); //when all three
delays are specified.

Data Flow level abstraction
Verilog HDL Dr. H P Koringa
46
The gate level approach is very well for small scale logic.
With the synthesis tool we can convert data level code to
gate level code.
All the booleanfunction can be implemented using data flow
level.
Expressed using continuous assignment.
Expressions, Operators, Operands.

Continuous Assignment
Verilog HDL Dr. H P Koringa
47
This is used to drive a value onto a net.
This is equivalent to gate after synthesis.
Define by key word assign
Ex . assign out = in1 & in2;
The left hand side value know as output net and it must be
net data type.
Operands on right hand side can be reg as well wire.
Delay can be specified in term of #time_unit
assign sum #10 = a+b;

Delay Type
Verilog HDL Dr. H P Koringa
48
Three ways to define delay in continuous assignment
statement
Regular assignment delay
ex. assign #10 dout= in1$in2;
Implicit assignment delay
ex. wire #10 dout= in1$in2;
Net declaration delay.
ex. wire #10 dout;
assign dout= in1$in2;

Operators
Binary Arithmetic Operators:
Operator
Type
Operator SymbolOperation
Performed
Number of
Operands
Arithmetic
* multiply two
/ divide two
+ add two
- subtract two
% modulus two
** power one
Verilog HDL Dr. H P Koringa
49

Relational Operators:
Operator
Type
Operator SymbolOperation
Performed
Number of Operands
Relational
> greater than two
< less than two
>=
greater than
or equal
two
<=
less than or
equal
two
== equality two
!= inequality two
=== Case equality two
!==
Case
inequality
two
Verilog HDL Dr. H P Koringa
50

Logical Operators:
Operator TypeOperator SymbolOperation
Performed
Number of
Operands
Logical
! logical negationone
&& logical and two
|| logical or two
Verilog HDL Dr. H P Koringa
51

Operator TypeOperator
Symbol
Operation
Performed
Number of
Operands
Bitwise
~ bitwise negationone
& bitwise and two
| bitwise or two
^ bitwise xor two
^~or ~^ bitwise xnor two
Bitwise Operators:
Verilog HDL Dr. H P Koringa
52

Other operators:
Unary Reduction Operators
Unaryreductionoperatorsproduceasinglebitresultfromapplyingthe
operatortoallofthebitsoftheoperand.
Forexample,&AwillANDallthebitsofA.
Concatenation:
C = {A[0], B[1:7]}
Shift Left:
A = A << 2 ; // right >>
Conditional:
A = C > D ?B + 3 :B –2 ; ex 2x1 muxassign out=control?in1:in0
4x1 mux: assign out = s1? (s0? I3 : i2) : (s0? i1: i0);
Replication:
A = {4{B}}; // will replicate value of B four times and
assign to A
Verilog HDL Dr. H P Koringa
53

Data flow Level Model
4x1 multiplexer
moduleMUX_4x1 (out ,in4 , in3 , in2, in1 , cntrl2, cntrl1);
outputout;
inputin1, in2, in3, in4, cntrl1, cntrl2;
wire out;
assignout = (in1 & ~cntrl1 & ~cntrl2) |
(in2 & ~cntrl1 &cntrl2)|
(in3 &cntrl1 & ~cntrl2)|
(in4 &cntrl1 &cntrl2);
endmodule
Verilog HDL Dr. H P Koringa
54

Data Flow model of a full adder
circuit
modulefadd(in1, in2, cin, sum,cout);
inputin1,in2, cin;
outputsum, cout;
assign {cout, sum}=in1 +in2 +cin;
endmodule
Verilog HDL Dr. H P Koringa
55

Behaviorallevel Abstraction
Verilog HDL Dr. H P Koringa
56
Modelling circuit with logic gate and continuous assignments
is quite complex.
Behaviorallevel is the higher level of abstraction in which
model can be defined as its functional behavioral.
Verilogbehavioralmodels contain structured procedural
statements that control the simulation and manipulate
variables.
Two types of structured procedure constructs

Initial and always

initialStatement
alwaysStatement
initialStatement : Executes only once
alwaysStatement : Executes in a loop
Example:

initial begin
Sum = 0;
Carry = 0;
end


always@(A or B) begin
Sum = A ^ B;
Carry = A & B;
end

Two Procedural Constructs
Verilog HDL Dr. H P Koringa
57

Procedural Assignment
Verilog HDL Dr. H P Koringa
58
Procedural assignment , are used or updating reg, integer,
time and memory variables.
Continuous assignmentProcedural assignment
Drives net/wire variables onlyDrive reg, integer, time and
memory variables
Updateoutput whenever an
input operand changes its value
Procedural assignment update
the value of regvariables under
the control of procedural flow
constructs that surround them

Blocking assignments
Verilog HDL Dr. H P Koringa
59
Blocking assignments statements are executed in the order
they are specified in a sequential block.
The = operator is used for blocking assignments.
Ex. rega,b,c,d;
initial
begin
a=1’b0; b=1’b1;
# 5 c = a&b;
#10 d = a| b;
end

Nonblockingassignments
Verilog HDL Dr. H P Koringa
60
Nonblockingassignments allows scheduling of assignments
without blocking execution of the statements that follow in
sequential block.
The <= operator is used to specify nonblocking assignments.
Ex. rega,b,c,d;
initial
begin
a=1’b0; b=1’b1;
c <= # 5 a&b;
d <= #10 a| b;
end

Nonblockingassignments
Verilog HDL Dr. H P Koringa
61
Operation of nonblockingassignments
1. The right hand side expressions are evaluated, results are
stored internally in simulator.
2. At the end of time step, in which the given delay has
expired or the appropriate event has taken place, the
simulator executes the assignments by assigning the stored
value to the left-hand side.
Ex. a<=b;
b <= a;
Sequence to write statements is not important.

Timing control
Verilog HDL Dr. H P Koringa
62
Delay based Timing Control
Intra-Assignment Timing Controls
Inter-Assignment Timing Controls
Zero-Assignment Delay
Even based Timing Control
Regular Event Control
Named Event Control
Event OR Control
Level Sensitive Timing Control

Conditional Statement
Verilog HDL Dr. H P Koringa
63
Theif statement
Syntax:
if (conditional_expression)
statement;
else
statement;
modulemux(out,in0,in1,sel);
input in1,in2,sel;
output out;
regout;
alway@(in1 @ in2 @ sel )
if (sel==1)
out=in1;
else
out = in0;
endmodule

The if else statement
Verilog HDL Dr. H P Koringa
64

Case Statement
Verilog HDL Dr. H P Koringa
65
Thecase statement
Syntax:
case(Expression )
Alternative 1: statement1;
Alternative 1: statement1;
Alternative 1: statement1;
Default: statement_default;
endcase
modulemux(out,in0,in1,sel);
input in1,in2,sel;
output out;
regout;
alway@(in1 @ in2 @ sel )
case (sel)
1’b0: out = in0;
1’b1: out = in1;
default: $display(“Invalid”);
endcase
endmoule

Looping Constructs
Verilog HDL Dr. H P Koringa
66
TherearefourloopingconstructsinVerilogarewhile,for,
repeatandforever.
Allofthesecanonlyappearinsideinitialandalwaysblocks.
while:executesastatementorsetofstatementswhileacondition
istrue.
for:executesastatementorasetofstatements.Thisloopcan
initialise,testandincrementtheindexvariableinaneatfashion.
repeat:executesastatementorasetofstatementsafixedumber
oftimes.
forever:executesastatementorasetofstatementsforeverand
even,oruntilthesimulationishalted.

While Loop
Verilog HDL Dr. H P Koringa
67
Syntax:
while(condition)
begin
statement1;
statement2;
statement3;
---
end
the while loop executes while
condition is true, the conditional
can be consist of logical expression.
‘define jugvol100;
modulejug_and_cup;
variable jug, cup;
initial
begin
jug = 0;
cup = 10;
while( jug<jugvol)
begin
jug = jug +cup;
end
end
endmodule

for Loop
Verilog HDL Dr. H P Koringa
68
Syntax:
for(initialisation; conditional;
update)
begin
statement1;
statement2;
statement3;
---
end
same as the for loop of C
modulefor_loop_ex;
variable data, index;
initial
begin
data =0;
for( index=0;index<10; index
= index+1)
begin
data= data+5;
end
end
endmoule

repeat Loop
Verilog HDL Dr. H P Koringa
69
Syntax:
repeat(conditional)
begin
statement1;
statement2;
statement3;
---
end
•repeat loop execute fixed number of
times.
•Conditional can be constant, variable or
signal value but must be number.
•If conditional is x or z then it treated as
zero.
modulejug_and_cup;
variable jug, cup, count;
initial
begin
jug =0;
cup=10;
count = 5;
repeat( count)
begin
jug = jug +cup;
end
end
endmodule

forever Loop
Verilog HDL Dr. H P Koringa
70
Syntax:
forever statement;
•Forever loop executes
continuously until end of simulation
is requested by a $finish.
•It is similar to while loop whose
condition is always true.
•The forever statement must be
used with timing control to limit
the execution.
regclock;
initial
begin
clock=1’b0;
forever #5clock = ~clock;
end
initial
#2000
$finish;

Tasks and Functions
Verilog HDL Dr. H P Koringa
71
Tasks and functions provide the ability to execute common
procedures from several different places in a description.
They also provide a means of breaking up large procedures
into smaller ones to make it easier to read and debug the
source descriptions.

Input, output and inoutargument values can be passed into
and out of both tasks and functions.

Tasks and Functions
Verilog HDL Dr. H P Koringa
72
Afunctionmustexecuteinonesimulationtimeunit;ataskcan
containtimecontrollingstatements.
Afunctioncannotenableataskbittaskcanenableothertaskand
functions.
Afunctionmusthaveatlistoneinputargumentwhiletaskcanhave
zeroormoreargumentsofanytype.
Afunctionreturnasinglevaluewhiletaskdoesnotreturnavalue
Thepurposeoffunctionistorespondtoaninputvaluebyreturninga
singlevalue.
Ataskcansupportmultiplegoalsandcancalculatemultipleresult
values.However,onlytheoutputorinoutargumentspassresult
valuesbackfrotheinvocationofatask.

AVerilogmodelusesafunctionalasanoperandinanexpression. The
valueofthatoperandisthevaluereturnedbythefunction.

Task
Verilog HDL Dr. H P Koringa
73
Syntax:
Syntax:
task <name_of_task>
<parameter_declaration>
<input_declaration>
<output_declaration>
<inout_declaration>
<reg_declaration>
<time_declaration>
<integer_declaration>
<real_declaration>
<event_declaration>
<task body>
endtask
Example:
task clk_gen;
input integer clk_period;
begin
clk= 1’b0;
forever #clk_period/2
clk= ~clk;
end
endtask

Function
Verilog HDL Dr. H P Koringa
74
Syntax:
function<range_or_type?><name_of_function>
<parameter_declaration>
<input_declaration>
<output_declaration>
<inout_declaration>
<reg_declaration>
<time_declaration>
<integer_declaration>
<real_declaration>
<event_declaration>
endtask
Example:
Function integeradd;
input integer data1;
input integer data2;
begin
add = data1 +data2;
end
endfunction

Calling a task and Function
Verilog HDL Dr. H P Koringa
75
moduletask_funct_test;
integer data_type;
initial
begin
task_name(task_parameter);
data_type= function_name(funct_parameter);
end
assignfunct_value= function_name(funct_parameter);
endmodule

Q ?
Verilog HDL Dr. H P Koringa
76