Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
VAMS-LRM-2-3-1.pdf
Скачиваний:
43
Добавлен:
05.06.2015
Размер:
3.73 Mб
Скачать

Accellera

 

Version 2.3.1, June 1, 2009

VERILOG-AMS

real x;

 

analog begin

 

if (in == 0)

 

x = 0.0;

 

else

 

x = 3.0; V(out) <+ x;

end endmodule

7.3.2 Accessing X and Z bits of a discrete net in a continuous context

Discrete nets can contain bits which are set to x (unknown) or z (high impedance). Verilog-AMS HDL supports accessing of 4-state logic values within the analog context. The x and z states must be translated to equivalent analog real or integer values before being used within the analog context. The language supports the following specific features, which provide a mechanism to perform this conversion.

the case equality operator (===)

the case inequality operator (!==)

the case, casex, and casez statements

binary, octal and hexadecimal numeric constants which can contain x and x as digits.

The case equality and case inequality operators have the same precedence as the equality operator.

Example:

module a2d(dnet, anet); input dnet;

output anet; wire dnet; ddiscrete dnet; electrical anet; real avar;

analog begin

if (dnet === 1’b1) avar = 5;

else if (dnet === 1’bx)

avar = avar; // hold value else if (dnet === 1’b0)

avar = 0;

else if (dnet === 1’bz)

avar = 2.5; // high impedance - float value

V(anet) <+ avar; end

endmodule

A case statement could also have been used as an alternative to the above if-else-if statement to perform the 4-state logic value comparisons.

Example:

case (dnet)

1’b1: avar = 5;

1’bx: avar = avar; // hold value

Copyright © 2009 Accellera Organization, Inc.

152

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