Chapter 7-User Defined Primitives
Chapter 7-User Defined Primitives
Chapter 7
2
Syntax
3
Syntax
• Example
4
UDP ports rules
5
The Body of UDP
6
The Body of UDP (cont.)
7
Table and Initial
• Table
Table is used for describing the function of
UDP. Verilog reserved word table marks the
start of table and reserved word endtable
marks the end of table.
Each line inside a table is one condition;
when an input changes, the input condition
is matched and the output is evaluated to
reflect the new change in input.
• Initial
Initial statement is used for initialization of
sequential UDPs. This statement begins with
the keyword 'initial'. The statement that
follows must be an assignment statement
that assigns a single bit literal value to the
output terminal reg.
8
Symbol
• UDP uses special symbols to describe functions like rising edge,
don't care and so on. The table below shows the symbols that are
used in UDPs.
9
Combinational UDPs
10
Combinational UDPs (cont.)
• The order of the inputs in the state
table description must correspond to
the order of the inputs in the port list
in the UDP definition header. It is not
related to the order of the input
declarations.
• Each row in the table defines the
output for a particular combination of
input states. If all inputs are specified
as x, then the output must be
specified as x. All combinations that
are not explicitly specified result in a
default output state of x.
11
Combinational UDPs (cont.)
12
The Body of UDP (cont.)
13
Level Sensitive Sequential UDP
• Level-sensitive sequential behavior is represented in the
same way as combinational behavior, except that the
output is declared to be of type reg, and there is an
additional field in each table entry. This new field
represents the current state of the UDP.
The output is declared as reg to indicate that there is an internal
state. The output value of the UDP is always the same as the
internal state.
A field for the current state has been added. This field is
separated by colons from the inputs and the output.
• Sequential UDPs have an additional field inserted
between the input fields and the output field, compared to
combinational UDP. This additional field represents the
current state of the UDP and is considered equivalent to
the current output value. It is delimited by colons.
14
Level Sensitive Sequential UDP (cont.)
• Example
15
Edge-Sensitive UDPs
• In level-sensitive behavior, the values of the inputs and the
current state are sufficient to determine the output value.
Edge-sensitive behavior differs in that changes in the output
are triggered by specific transitions of the inputs.
• As in the combinational and the level-sensitive entries, a ?
implies iteration of the entry over the values 0, 1, and x. A
dash (-) in the output column indicates no value change.
• All unspecified transitions default to the output value x. Thus,
in the previous example, transition of clock from 0 to x with
data equal to 0 and current state equal to 1 result in the
output q going to x.
• All transitions that should not affect the output must be
explicitly specified. Otherwise, they will cause the value of the
output to change to x. If the UDP is sensitive to edges of any
input, the desired output state must be specified for all edges
of all inputs.
16
Edge-Sensitive UDPs (cont.)
17
Example UDP with initial
18
The End