Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
xst.pdf
Скачиваний:
141
Добавлен:
11.06.2015
Размер:
5.64 Mб
Скачать

R

Behavioral Verilog Expressions

case (expression) expression: statement

...

default: statement endcase

for (variable = expression; condition; variable = variable + expression) statement

while (condition) statement

forever statement

functions and tasks

All variables are declared as integer or reg. A variable cannot be declared as a wire.

Behavioral Verilog Expressions

This section discusses Behavioral Verilog Expressions, and includes:

“About Behavioral Verilog Expressions”

“Operators Supported in Behavioral Verilog”

“Expressions Supported in Behavioral Verilog”

“Results of Evaluating Expressions in Behavioral Verilog”

About Behavioral Verilog Expressions

An expression involves constants and variables with arithmetic, logical, relational, and conditional operators as shown in Table 8-1, “Operators Supported in Behavioral Verilog.” The logical operators are further divided as bit-wise versus logical, depending on whether it is applied to an expression involving several bits or a single bit.

Operators Supported in Behavioral Verilog

Table 8-1: Operators Supported in Behavioral Verilog

Arithmetic

Logical

Relational

Conditional

 

 

 

 

+

&

<

?

 

 

 

 

-

&&

==

 

 

 

 

 

*

|

===

 

 

 

 

 

**

||

<=

 

 

 

 

 

/

^

>=

 

 

 

 

 

%

~

>=

 

 

 

 

 

 

~^

!=

 

 

 

 

 

 

^~

!==

 

 

 

 

 

 

<<

>

 

 

 

 

 

 

>>

 

 

 

 

 

 

XST User Guide

www.xilinx.com

529

10.1

Chapter 8: XST Behavioral Verilog Language Support

Table 8-1: Operators Supported in Behavioral Verilog (Cont’d)

R

Arithmetic

Logical

Relational

Conditional

 

 

 

 

 

<<<

 

 

 

 

 

 

 

>>>

 

 

 

 

 

 

Expressions Supported in Behavioral Verilog

Table 8-2: Expressions Supported in Behavioral Verilog

Expression

Symbol

Supported/Unsupported

 

 

 

Concatenation

{}

Supported

 

 

 

Replication

{{}}

Supported

 

 

 

 

+, -, *,**

Supported

Arithmetic

 

 

/

Supported only if second operand is a power of 2

 

 

 

Modulus

%

Supported only if second operand is a power of 2

 

 

 

Addition

+

Supported

 

 

 

Subtraction

-

Supported

 

 

 

Multiplication

*

Supported

 

 

 

Power

**

Supported

 

 

• Both operands are constants, with the second

 

 

operand being non-negative.

 

 

• If the first operand is a 2, then the second

 

 

operand may be a variable.

 

 

• XST does not support the real data type. Any

 

 

combination of operands that results in a real

 

 

type causes an error.

 

 

• The values X (unknown) and Z (high

 

 

impedance) are not allowed.

 

 

 

Division

/

Supported

 

 

XST generates incorrect logic for the division

 

 

operator between signed and unsigned constants.

 

 

Example: -1235/3’b111

 

 

 

Relational

>, <, >=, <=

Supported

 

 

 

Logical Negation

!

Supported

 

 

 

Logical AND

&&

Supported

 

 

 

Logical OR

||

Supported

 

 

 

Logical Equality

==

Supported

 

 

 

Logical Inequality

!=

Supported

 

 

 

Case Equality

===

Supported

 

 

 

530

www.xilinx.com

XST User Guide

 

 

10.1

R

Behavioral Verilog Expressions

Table 8-2: Expressions Supported in Behavioral Verilog (Cont’d)

Expression

Symbol

Supported/Unsupported

 

 

 

Case Inequality

!==

Supported

 

 

 

Bitwise Negation

~

Supported

 

 

 

Bitwise AND

&

Supported

 

 

 

Bitwise Inclusive OR

|

Supported

 

 

 

Bitwise Exclusive OR

^

Supported

 

 

 

Bitwise Equivalence

~^, ^~

Supported

 

 

 

Reduction AND

&

Supported

 

 

 

Reduction NAND

~&

Supported

 

 

 

Reduction OR

|

Supported

 

 

 

Reduction NOR

~|

Supported

 

 

 

Reduction XOR

^

Supported

 

 

 

Reduction XNOR

~^, ^~

Supported

 

 

 

Left Shift

<<

Supported

 

 

 

Right Shift Signed

>>>

Supported

 

 

 

Left Shift Signed

<<<

Supported

 

 

 

Right Shift

>>

Supported

 

 

 

Conditional

?:

Supported

 

 

 

Event OR

or, ','

Supported

 

 

 

Results of Evaluating Expressions in Behavioral Verilog

Table 8-3, “Results of Evaluating Expressions in Behavioral Verilog,” lists the results of evaluating expressions using the more frequently used operators supported by XST.

The (===) and (!==) operators are special comparison operators useful in simulations to check if a variable is assigned a value of (x) or (z). They are treated as (==) or (!=) in synthesis.

Table 8-3: Results of Evaluating Expressions in Behavioral Verilog

 

a b

a==b

a===b

a!=b

a!==b

a&b

a&&b

a|b

a||b

a^b

 

 

 

 

 

 

 

 

 

 

 

 

0 0

1

1

0

0

0

0

0

0

0

 

 

 

 

 

 

 

 

 

 

 

 

0 1

0

0

1

1

0

0

1

1

1

 

 

 

 

 

 

 

 

 

 

 

 

0 x

x

0

x

1

0

0

x

x

x

 

 

 

 

 

 

 

 

 

 

 

 

0 z

x

0

x

1

0

0

x

x

x

 

 

 

 

 

 

 

 

 

 

 

 

1 0

0

0

1

1

0

0

1

1

1

 

 

 

 

 

 

 

 

 

 

 

 

1 1

1

1

0

0

1

1

1

1

0

 

 

 

 

 

 

 

 

 

 

 

 

1 x

x

0

x

1

x

x

1

1

x

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

XST User Guide

 

www.xilinx.com

 

 

 

 

531

10.1

 

 

 

 

 

 

 

 

 

 

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]