Refactoring
Rename Refactoring
To rename an entity (type, method, macro, etc.) in the source code along with all its references, place the cursor on the desired element and use the Rename Symbol command.
Provide the new name of the entity and click Enter to perform the refactoring operation or Shift+Enter to preview and select the changes that should be performed in the source code.

Tip
Matches hidden inside a macro call (matches found inside a macro call expansion, but not among the macro call parameters) cannot be automatically renamed.
Instead, DVT will insert a // FIXME comment above the macro call to indicate that it should be refactored by hand.
Rename in File
To rename a variable, signal, method, etc. within the current file, select the name of the element and use the Replace command. Write the new name and choose to replace occurrence by occurrence or all of them at once.
This is a lightweight Rename Refactoring which you should use in contexts where the renamed element is local to the file: local parameters, method argument names, local variables, signals of a module, etc.
Extract to Variable
To extract an expression inside a function or task to a local variable, select the expression, run the Refactor... command and select Extract to local variable.
Provide a name for the new variable, which is declared and initialized with the extracted expression in the correct scope.

Bind Method Call Arguments by Name
To convert the argument bindings of a method call from positional to named, place the cursor on a method call, run the Refactor... command and select Bind Method Call Arguments by Name.

Bind Method Call Arguments by Position
To convert the argument bindings of a method call from named to positional, place the cursor on a method call, run the Refactor... command and select Bind Method Call Arguments by Position.

Connect Instance Ports by Name
To convert the port connections of an instance from positional to named, place the cursor on an instance, run the Refactor... command and select Connect instance ports by name.

Connect Instance Ports by Position
To convert the port connections of an instance from named to positional, place the cursor on an instance, run the Refactor... command and select Connect instance ports by position.

Expand .* Port Connections
To easily expand .* wildcard named port connections to explicit named port connections, place the cursor either on a module or interface instance declaration, run the Refactor... command and select Expand .* port connections.

Extract to Method
To move a code fragment to a separate new method, select a block of actions, run the Refactor... command and select Extract to task or Extract to function.
Provide a name for the new method, which is created containing the selected code fragment and the selection is replaced with a method call.

Note
Any local variables declared prior to the code fragment you extracted become arguments of the newly created method. Each argument direction is computed accordingly:
input for arguments that are only read
output for arguments that are only written
inout for arguments that are both read and written in the selected block of actions
Note
By default, if and loop conditions are evaluated to the logic data type, according to the IEEE 1800-2023 Standard for SystemVerilog. You can enforce the data type to bit using the DVT.systemVerilog.refactoring.enforceConditionDataTypeToBit
preference accessible using Preferences: Open Settings (UI) command.
This preference applies only when you select the whole condition.
Extract to Module
To automatically extract and encapsulate a fragment of a module into a new instance, select the region (must be contiguous, containing only instances, always blocks and assignments) in the editor, run the Refactor... command and select Extract to module.
Provide a name for the new module and file where the selected piece of code will be moved. The initial selection is replaced with an instance of the new module and the ports of the new module are automatically computed and connected in the instantiation.

Note
The new file is `included on the line above the declaration of the initial module.
Signals which are not referenced anywhere outside the selection will be marked with a // FIXME after the extraction.
Currently busses are propagated through a single port even if accessed through bit selects; in such a case, a // FIXME comment can help you easily identify the unique bit selects that you might consider propagating through distinct ports.
Move Selection to New File
To move a code fragment to a separate new file, select a block of code, run the Refactor... command and select Move selection to new file....
Provide a name for the new file, an `include
to this file replacing the initial selection.

Join Extern and Implementation
To merge the extern
prototype of a method or constraint with its out-of-block implementation, place the cursor either on the prototype or on the implementation, run the Refactor... command and select Join extern … prototype and implementation.

Split into Extern and Implementation
To move method or constraint implementations outside the body of the class declaration, place the cursor on the declaration, run the Refactor... command and select Split … into extern prototype and implementation.
The declaration is replaced with the extern
prototype, and the implementation is inserted after endclass
.

Add Port to Module from Selected Field
To add a selected field as a port easy and fast, place the cursor on a field, run the Refactor... command and select Add port .
You can optionally change the newly generated port name, direction type or width.
Add New Port to Module
To add a new port to a module, place the cursor on the module name, run the Refactor... command and select Add port.
After tuning the name, direction, type, and width of the new port, an empty port connection is added to all the instances of the selected module along with a // FIXME
comment.

Add New Parameter to Module
To add a new parameter to a module, place the editor cursor on the module name, run the Refactor... command and select Add parameter.
After tuning the name, type, width, and the value of the new parameter, an empty parameter override is added to all the instances of the selected module along with a // FIXME
comment.

Change Method Signature
The change method signature refactoring allows you to add, reorder or remove the arguments of a method. All updates to existing method calls will be automatically performed.
Place the cursor on the desired method, run the Refactor... command and select Change Method Signature.
In the Change Method Signature view you can modify the method’s name and arguments.

Method name changes are equivalent with Rename Refactoring.
The list of arguments can be manipulated by using the buttons on the right side of the table.
- Add: Add a new argument at the end of the list. You will be prompted to provide:
the argument type
the argument name
the actual argument to be used in existing function calls

Remove: Remove the selected argument. The selected argument will not be part of the list anymore and will be erased from function calls as well.
Up/Down: Change the position of the selected argument.
Note
The view presents validation information, such as duplicate parameters, invalid identifier names and duplicate methods.
Click OK to perform the refactoring, or Preview to preview and select the changes that should be performed in the source code. After you click Finish the changes are performed, and the project is rebuilt.
Note
In specific preprocessing scenarios - for example when a method declaration or a method call lies within a macro expansion - the refactoring cannot be automatically carried out. A FIXME comment will be inserted in the relevant code location.
Expand Macro
To easily expand macro calls, place the cursor on the macro name, run the Refactor... command and select Expand macro.

Collapse Macro
To easily collapse macro expansions, place the cursor on the start pragma of a macro expansion, run the Refactor... command and select Collapse macro.
