Refactoring in the DVT Eclipse IDE - How to Perform Extract to Module Refactoring

Description

This video shows how a fragment of a module can be automatically extracted and encapsulated into a new module instance.

This makes it easy to take a large module and break it up into several pieces for better readability and easier reuse.

Explore the design and verification tools: https://www.dvteclipse.com
Or request a license: https://www.dvteclipse.com/request-license

Transcript

Introduction

Extract to Module Refactoring allows you to encapsulate a fragment of a module into a new instance.

Selecting the Code Fragment

In the editor, select a contiguous region from a module declaration containing only instances, always blocks and assignments.

Performing the Extract to Module Refactoring

  1. Press CTRL+1, select Extract to Module from the list of quick assist proposals and press Enter.
  2. The New File for Extracted Module dialog pops up.
  3. Fill in the new module name, the directory of the newly created file and press Finish when done.

Result of the Refactoring

A new module containing the selected piece of code is created in its own file, and included just above the declaration of the initial module.

The ports of the new module are automatically computed based on how the signals involved in the extracted fragment interact with the remainder of the module.

The initial selection is replaced with an instance of the new module connected appropriately.

Alternative Way to Trigger the Refactoring

This refactoring operation can also be triggered from the editor's context menu: Refactor > Extract to Module.