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

 

Accellera

Analog and Mixed-signal Extensions to Verilog HDL

Version 2.3.1, June 1, 2009

initial_step and final_step take a list of quoted strings as optional arguments. The strings are compared to the name of the analysis being run. If any string matches the name of the current analysis name, the simulator generates an event on the first point and the last point of that particular analysis, respectively.

If no analysis list is specified, the initial_step global event point (or initial DC analysis) of every analysis. The final_step only active during the solution of the last point of every analyses.

5.10.3 Monitored events

is active during the solution of the first global event, without an analysis list, is

Monitored events are detected using event functions with the @ operator. The triggering of a monitored event is implicit due to change in signals, simulation time, or other runtime conditions.

5.10.3.1 cross function

The cross() function is used for generating a monitored analog event to detect threshold crossings in analog signals when the expression crosses zero (0) in the specified direction. In addition, cross() controls the timestep to accurately resolve the crossing.

analog_event_functions ::= // from A.6.5 cross ( analog_expression [ , analog_expression_or_null

[ , constant_expression_or_null [ , constant_expression_or_null [ , analog_expression ] ] ] ] )

...

Syntax 5-16—The cross analog event function

The expressions in this syntax have the following meanings:

cross ( expr [ , dir [ , time_tol [ , expr_tol [ , enable ] ] ] ] )

where expr is required, and dir, time_tol, and expr_tol are optional. The expr, dir, and enable arguments are specified as analog_expression.The tolerances (time_tol and expr_tol) are specified as constant_expression and shall be non-negative. Analog filter functions cannot be used for dir or enable argument and they should evaluate to integers. If the tolerances are not defined, then the tool (e.g., the simulator) sets them. If either or both tolerances are defined, then the direction shall also be defined.

The direction indicator evaluates to an integer. If it is set to 0 or is not specified, the event and timestep control occur on both positive and negative crossings of the signal. If dir is +1, the event and timestep control only occur on rising edge transitions of the signal. If dir is –1, the event and timestep control only occur on falling edge transitions of the signal. For any other values of dir, the cross() function does not generate an event and does not act to control the timestep.

expr_tol and time_tol are absolute tolerances and are defined as shown in Figure 5-6. They represent the maximum allowable error between the and the true crossing point and when the event triggers. The event

113

Copyright © 2009 Accellera Organization, Inc. All rights reserved.

Accellera

 

Version 2.3.1, June 1, 2009

VERILOG-AMS

shall occur after the threshold crossing, and while the signal remains in the box defined by actual crossing and expr_tol and time_tol.

 

 

 

 

 

 

 

time_tol

threshold

expr_tol

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

event

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

actual crossing

Figure 5-6: Timing of event relative to threshold crossing.

If expr_tol is specified, time_tol shall also be specified and both tolerances shall be satisfied at the crossing.

The following description of a sample-and-hold illustrates how the cross() function can be used.

module sh (in, out, smpl); parameter real thresh = 0.0;

parameter integer dir = +1 from [-1:0] exclude 0; output out;

input in, smpl; electrical in, out, smpl; real state;

analog begin

@(cross(V(smpl) - thresh, dir)) state = V(in);

V(out) <+ transition(state, 0, 10n); end

endmodule

If enable is specified and nonzero, then cross() functions as just described. If enable argument is specified and it is zero, then cross() is inactive, meaning that it does not generate an event at threshold crossings and does not act to control the timestep. Thus, there are two ways to disable the cross function, either by specifying enable as 0, or giving a value other than –1, 0, or 1 to dir. In the following example, the first way is used to allow the sample and hold to be disabled. Notice that in this example, the tolerances are not specified, and so take their default values.

module sh (in, out, smpl, en); parameter real thresh = 0.0;

parameter integer dir = +1 from [-1:0] exclude 0; output out;

input in, smpl, en; electrical in, out, smpl; real state;

analog begin

@(cross(V(smpl) - thresh, dir, , , en === 1’b1)) state = V(in);

V(out) <+ transition(state, 0, 10n); end

endmodule

Copyright © 2009 Accellera Organization, Inc.

114

 

Accellera

Analog and Mixed-signal Extensions to Verilog HDL

Version 2.3.1, June 1, 2009

The cross() function maintains its internal state and has the same restrictions as analog operators. In particular, it shall not be used inside an if, case, casex, or casez statement unless the conditional expression is a genvar expression. In addition, cross() is not allowed in the repeat and while iteration statements. It is allowed in the analog_for statements.

5.10.3.2 above function

The above() function is almost identical to the cross() function, except that it also triggers during initialization or dc analysis. It generates a monitored analog event to detect threshold crossings in analog signals when the expression crosses zero (0) from below. As with the cross() function, above() controls the timestep to accurately resolve the crossing during transient analysis.

analog_event_functions ::=

// from A.6.5

...

 

| above ( analog_expression [ , constant_expression_or_null

 

[ , constant_expression_or_null [ , analog_expression ] ] ] )

 

...

 

 

 

Syntax 5-17—The above analog event function

 

The expressions in this syntax have the following meanings:

 

above ( expr [ , time_tol [ , expr_tol [ , enable ] ] ] )

 

where expr is required. The tolerances (time_tol and expr_tol) are optional, but if specified shall be non-neg- ative. All arguments are real expressions. If the tolerances are not defined, then the tool (e.g., the simulator) sets them.

The above() function can generate an event during initialization. If the expression is positive at the conclusion of the initial condition analysis that precedes a transient analysis, the above() function shall generate an event. In contrast, the cross() function can only generate an event after the simulation time has advanced from zero. The cross() function will not generate events for non-transient analyses, such as ac, dc, or noise analyses of SPICE (see 4.6.1), but the above() function can. During a dc sweep, the above() function shall also generate an event when the expression crosses zero from below; however, the step size of the dc sweep is not controlled to accurately resolve the crossing.

The following example uses the above() function in place of the cross() function in the description of a simplified version of the sample-and-hold module introduced in the previous section. If the voltage on the smpl port is above 2.5V initially (at time=0), then use of the above() function ensures that the input is sampled and passed to the output when solving for the initial state of the circuit. If the voltage on the smpl port never crosses 2.5V in the positive direction, then the cross() function of the previous example would never trigger, even if the voltage on the smpl port is always above 2.5V.

module sh (in, out, smpl); output out;

input in, smpl; electrical in, out, smpl; real state;

analog begin

@(above(V(smpl) - 2.5)) state = V(in);

V(out) <+ transition(state, 0, 10n);

115

Copyright © 2009 Accellera Organization, Inc. All rights reserved.

Accellera

 

Version 2.3.1, June 1, 2009

VERILOG-AMS

end endmodule

If enable is specified and nonzero, then above() functions as just described. If enable argument is specified and it is zero, then above() is inactive, meaning that it does not generate an event at threshold crossings and does not act to control the timestep.

The above() function maintains its internal state and has the same restrictions on its use as the cross() function.

5.10.3.3 timer function

The timer() function is used to generate analog events to detect specific points in time.

analog_event_functions ::=

// from A.6.5

...

 

| timer ( analog_expression [ , analog_expression_or_null

 

[ , constant_expression_or_null [ , analog_expression ] ] ] )

 

Syntax 5-18—The timer analog event function

 

The expressions in this syntax have the following meanings:

 

timer ( start_time [ , period [ , time_tol [ , enable ] ] ] )

 

where start_time is required; period and time_tol are optional arguments. The start_time and period arguments are analog_expressions. The tolerance (time_tol) is a constant_expression and shall be non-negative. Analog filter functions cannot be used for the start and period arguments.

The timer() function schedules an event which occurs at an absolute time (start_time). The analog simulator places a time point within time_tol of an event. At that time point, the event evaluates to True.

If time_tol is not specified, the default time point is at, or just beyond, the time of the event. If the period is specified as greater than zero (0), the timer function schedules subsequent events at multiples of period. If the period expression evaluates to a value less than or equal to 0.0, the timer shall trigger only once at the specified start_time (if the start_time is in the future with respect to the current simulation time).

If the start_timer or period expressions change value during the evaluation of the analog block, the new event will be scheduled based on the latest value of the start_time and period.

If enable is specified and nonzero, then timer() functions as just described. If enable argument is specified and it is zero, then timer() is inactive, meaning that it does not generate events as long as enable is zero. However, it will start generating events once enable returns to being nonzero as if it had never been disabled.

A pseudo-random bit stream generator is an example how the timer function can be used.

module bitStream (out); output out; electrical out;

parameter period = 1.0; integer x;

Copyright © 2009 Accellera Organization, Inc.

116

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