Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase

Model Technology Inc.


force

The force command allows you to apply stimulus interactively to VHDL signals and Verilog nets and registers. Since force commands (like all commands) can be included in a macro file, it is possible to create complex sequences of stimuli.

You can force Virtual signals if the number of bits corresponds to the signal value. You cannot force virtual functions. In VHDL and mixed models, you cannot force an input port that is mapped at a higher level or that has a conversion function on the input.

Syntax

force

[-freeze | -drive | -deposit] [-cancel <period>] [-repeat <period>] <item_name> <value> [<time>] [, <value> <time> ...]

Arguments

-freeze

Freezes the item at the specified value until it is forced again or until it is unforced with a noforce command. Optional.

-drive

Attaches a driver to the item and drives the specified value until the item is forced again or until it is unforced with a noforce command. Optional.

This option is illegal for unresolved signals.

-deposit

Sets the item to the specified value. The value remains until there is a subsequent driver transaction, or until the item is forced again, or until it is unforced with a noforce command. Optional.

If one of the -freeze, -drive, or -deposit options is not used, then -freeze is the default for unresolved items and -drive is the default for resolved items.

If you prefer -freeze as the default for resolved and unresolved VHDL signals, change the default force kind in the DefaultForceKind preference variable.

-cancel <period>

Cancels the force command after the specified <period> of current time units. Cancellation occurs at the last simulation delta cycle of a time unit. A value of zero cancels the force at the end of the current time period. Optional.

-repeat <period>

Repeats the force command, where <period> is the time at which to start repeating the cycle. A repeating force command will force a value before other non-repeating force commands that occur in the same time step. Optional.

<item_name>

Specifies the name of the HDL item to be forced. Required. A wildcard is permitted only if it matches one item. See "HDL item pathnames" for the full syntax of an item name. The item name must specify a scalar type or a one-dimensional array of character enumeration. You may also specify a record subelement, an indexed array, or a sliced array, as long as the type is one of the above. Required.

<value>

Specifies the value to which the item is to be forced. The specified value must be appropriate for the type. Required.

A VHDL one-dimensional array of character enumeration can be forced as a sequence of character literals or as a based number with a radix of 2, 8, 10 or 16. For example, the following values are equivalent for a signal of type bit_vector (0 to 3):

Value
Description
1111
character literal sequence
2#1111
binary radix
10#15
decimal radix
16#F
hexadecimal radix


Note: For based numbers in VHDL, ModelSim translates each 1 or 0 to the appropriate value for the number's enumerated type. The translation is controlled by the translation table in the pref.tcl file. If ModelSim cannot find a translation for 0 or 1, it uses the left bound of the signal type (type'left) for that value.

<time>

Specifies the time to which the value is to be applied. The time is relative to the current time unless an absolute time is specified by preceding the value with the character @. If the time units are not specified, then the default is the resolution units selected at simulation start-up. Optional.

A zero-delay force command causes the change to occur in the current (rather than the next) simulation delta cycle.

Examples

force input1 0

Forces input1 to 0 at the current simulator time.

force bus1 01XZ 100 ns

Forces bus1 to 01XZ at 100 nanoseconds after the current simulator time.

force bus1 16#f @200

Forces bus1 to 16#F at the absolute time 200 measured in the resolution units selected at simulation start-up.

force input1 1 10, 0 20 -r 100

Forces input1 to 1 at 10 time units after the current simulation time and to 0 at 20 time units after the current simulation time. This cycle repeats starting at 100 time units after the current simulation time, so the next transition is to 1 at 100 time units after the current simulation time.

force input1 1 10 ns, 0 {20 ns} -r 100ns

Similar to the previous example, but also specifies the time units. Time unit expressions preceding the "-r" must be placed in curly braces.

force s 1 0, 0 100 -repeat 200 -cancel 1000

Forces signal s to alternate between values 1 and 0 every 100 time units until time 1000. Cancellation occurs at the last simulation delta cycle of a time unit. So,

force s 1 0 -cancel 0

will force signal s to 1 for the duration of the current time period.

See also

noforce, change


Note: You can configure defaults for the force command by setting the DefaultForceKind variable in the modelsim.ini file. See "Force command defaults" .


Model Technology Inc.
Model Technology Incorporated
Voice: (503) 641-1340
Fax: (503)526-5410
www.model.com
sales@model.com
Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase