getting started with sveditor v1.5

21
Getting Started with SVEditor v1.5 Getting Started with SVEditor Author: Matthew Balance Last Updated: November 25, 2010 Overview SVEditor provides a SystemVerilog development environment for the Eclipse framework. SVEditor provides a syntax-coloring editor for SystemVerilog files, and SystemVerilog scanners that support content assist and cross-linking between elements in different SystemVerilog files. This document provides a getting-started guide for SVEditor, including information on how to install SVEditor, how to configure source paths, and how to access SVEditor’s features. Table of Contents Overview .............................................................................................................................. 1 Version Requirements .......................................................................................................... 1 Installing SVEditor .............................................................................................................. 1 Preparing a SystemVerilog Project ...................................................................................... 6 Creating a Project ............................................................................................................. 6 Setting Project Paths ........................................................................................................ 9 Editing SystemVerilog Files .............................................................................................. 13 Outline View .................................................................................................................. 13 Cross-Linking ................................................................................................................ 14 Content Assist ................................................................................................................ 14 Override Tasks/Functions .............................................................................................. 15 Indenting Content ........................................................................................................... 16 Creating a New Class File .................................................................................................. 17 Class Hierarchy View ........................................................................................................ 20 Key Bindings ..................................................................................................................... 21 Version Requirements SVEditor is tested with Eclipse 3.5 and Java 6 (SVEditor is built for Java 5, so either Java 5 or Java 6 should be fine). Installing SVEditor SVEditor can be installed either by downloading the release archive from the SVEditor Sourceforge Site, or installed directly from the SVEditor Update Site. These instructions will describe setting up the SVEditor Update Site. Copyright 2008-2010 Matthew Ballance. All Rights Reserved 1

Upload: christopher-patterson

Post on 30-Nov-2015

61 views

Category:

Documents


2 download

DESCRIPTION

Good pdf for SV editor

TRANSCRIPT

Getting Started with SVEditor v1.5

Getting Started with SVEditorAuthor: Matthew BalanceLast Updated: November 25, 2010

OverviewSVEditor provides a SystemVerilog development environment for the Eclipse framework. SVEditor provides a syntax-coloring editor for SystemVerilog files, and SystemVerilog scanners that support content assist and cross-linking between elements in different SystemVerilog files.

This document provides a getting-started guide for SVEditor, including information on how to install SVEditor, how to configure source paths, and how to access SVEditor’s features.

Table of ContentsOverview .............................................................................................................................. 1 Version Requirements .......................................................................................................... 1 Installing SVEditor .............................................................................................................. 1 Preparing a SystemVerilog Project ...................................................................................... 6

Creating a Project ............................................................................................................. 6 Setting Project Paths ........................................................................................................ 9

Editing SystemVerilog Files .............................................................................................. 13 Outline View .................................................................................................................. 13 Cross-Linking ................................................................................................................ 14 Content Assist ................................................................................................................ 14 Override Tasks/Functions .............................................................................................. 15 Indenting Content ........................................................................................................... 16

Creating a New Class File .................................................................................................. 17 Class Hierarchy View ........................................................................................................ 20 Key Bindings ..................................................................................................................... 21

Version RequirementsSVEditor is tested with Eclipse 3.5 and Java 6 (SVEditor is built for Java 5, so either Java 5 or Java 6 should be fine).

Installing SVEditorSVEditor can be installed either by downloading the release archive from the SVEditor Sourceforge Site, or installed directly from the SVEditor Update Site. These instructions will describe setting up the SVEditor Update Site.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 1

Getting Started with SVEditor v1.5

Note: If a previous version of SVEditor was installed via a release archive, this version must be uninstalled before installing from the SVEditor Update Site.

Launch Eclipse and select Help->Install New Software from the Eclipse main menu.

Figure 1 - Open the Install New Software Dialog

Give a name to the site (eg SVEditor), then fill in the SVEditor Update Site (http://sveditor.sourceforge.net/update) in the Location field.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 2

Figure 2: - Install New Software Dialog

Getting Started with SVEditor v1.5

Select the previously-downloaded SVEditor update-site JAR file and select OK. Then, select ‘OK’ in the ‘Add Site’ dialog.

After selecting ‘OK’ in the Add Site dialog, SVEditor will appear in the Install dialog. Activate the check-box beside the SVEditor category and select ‘Next’. The next dialog page (Figure 4) just shows the new software to be installed. Select ‘Next’.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 3

Figure 3: - Selecting the SVEditor Version to Install

Getting Started with SVEditor v1.5

Figure 4 - Install Details

The next dialog prompts to accept the SVEditor license. Select ‘I accept…’ and select Finish. SVEditor install. Finally, Eclipse will prompt to restart the workbench. Select ‘Restart’. SVEditor is now installed and ready to use.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 4

Getting Started with SVEditor v1.5

Figure 5 - License Dialog

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 5

Getting Started with SVEditor v1.5

Preparing a SystemVerilog ProjectSVEditor is project-centric, much as Eclipse is project-centric. SVEditor assumes that most of the SystemVerilog source being actively edited is contained within one or more Eclipse projects. External SystemVerilog source (eg libraries or frameworks such as OVM or VMM) can be referenced as project-external paths.

Creating a ProjectSVEditor does not have a special SystemVerilog project type, and will work within any Eclipse project. If the SystemVerilog source is already within an Eclipse project and imported to your workspace, you can skip to the following step.

In this example, we will create a project for the ‘xbus’ example from the OVM library (http://www.ovmworld.org). The first step is to open the ‘New Project wizard from the Eclipse main menu.

Figure 6 - Opening the New Project Wizard

This will open an Eclipse dialog to select the type of project to create. In this case, we will use the ‘General Project’ type.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 6

Getting Started with SVEditor v1.5

Select Next to move to the next page in the wizard where the project name and path are specified.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 7

Getting Started with SVEditor v1.5

Figure 7 - Project Details

We name the project ‘xbus’ to match what it is named in the OVM source distribution. We un-check the ‘Use default location’ check-box and change the Location path to be the same as the xbus directory on the filesystem.

Next, select Finish to complete creation of the Eclipse project. The ‘xbus’ project is now shown in the Project Explorer and contains the existing source for the ‘xbus’ example.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 8

Getting Started with SVEditor v1.5

Figure 8 - New Project in Project Explorer

Setting Project PathsAt this point (setting up a basic project with no project paths specified), limited SystemVerilog indexing will be done. The structure of elements within a single file (classes, modules, etc) will be shown in the Outline view for the editor and content assist will be done for these elements. However, content assist and cross-referencing will not be done for other files in the project or referenced by the project.

In the xbus example, there are files within the same project that should be available for content assist and cross-referencing. The OVM library should also be used. We will specify these using the Project Properties dialog. Open the Project Properties dialog by selecting the project and selecting ‘Properties’ from the context menu.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 9

Getting Started with SVEditor v1.5

Figure 9 - Open Project Properties Dialog

Figure 10 - Project Properties Dialog

Select the ‘SystemVerilog Project Properties’ section in the Project Properties dialog. This will show the tabs for configuring project paths. There are several types of project paths that can be specified.

• Source Collections – Allows a directory of sources to be specified. Because of the way that SystemVerilog encourages/enforces a single top-level compile unit (a

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 10

Getting Started with SVEditor v1.5

package that includes files that define classes within the package), Source Collections are best used to specify directories of Verilog modules.

• Library Paths – Allows SystemVerilog package files to be specified. These files then include other SystemVerilog sources.

• Arguments Files – Allows argument files (file lists) to be specified. Often, these are used to specify file compile orders, include paths, and pre-processor defines. Currently, Mentor Graphics Modelsim / Questa switches are accepted.

The xbus project provides an argument file for Questa. The argument file specifies the top-level package files to compile within the xbus project and the include paths that allow the package files to find included files.

Figure 11 - Adding an Argument File Path

Select the Argument Files tab, then select the ‘Add’ button. In the resulting dialog, select ‘Add Workspace Path’. Browse to xbus/example/compile_questa_sv.f and select ‘OK’. Select ‘OK’ in the Add Path dialog.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 11

Getting Started with SVEditor v1.5

Next, we will add a path for the OVM library since it is outside of the project. Select the ‘Library Paths’ tab and select the ‘Add’ button. Select ‘Add Filesystem Path’ and browse to the location for the ovm_pkg.sv file. Select OK.

Finally, select ‘OK’ in the Project Project dialog. Now, cross-referencing and content assist will work for all SystemVerilog files referenced by the argument file and for the OVM library.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 12

Getting Started with SVEditor v1.5

Editing SystemVerilog Files

Figure 12 - EclipseWorkbench with Open SVEditor and Outline View

SVEditor provides several features to make editing SystemVerilog files easier and more productive.

Outline ViewThe Outline View is a built-in Eclipse view that provides a structural view of the actively-edited file. SVEditor populates the Outline View with structural SystemVerilog information, such as classes, modules, functions, and fields.

Figure 13 - Navigation via the Outline View

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 13

Getting Started with SVEditor v1.5

Selecting an element in the Outline View causes the active editor to navigate to the selected element and highlight the bounds of the item.

Cross-LinkingWhen editing a SystemVerilog class or module, it is often helpful to reference a class or module used within the current module. SVEditor provides a context-menu entry and a shortcut (F3) to access cross-linking. Cross-linking works when the cursor is positioned:

• On the file path of an `include directive. Invoking Open Declaration opens the referenced file

• On a class or structure type name (eg class-field declaration). Opens the file that contains the class or structure declaration.

• On a field or task/function reference. Figure 14 shows invoking Open Declaration on the expression slaves[i].assign_vi(xi). The cursor was placed on ‘assign_vi’. In this case SVEditor will navigate to the task or function named ‘assign_vi’ within the class of which ‘slaves’ is an instance.

Figure 14 - Open Declaration for a Class Field

Content AssistContent assist is common in many editors for code files (Java, C++, etc). SVEditor provides content assist that is very similar to the content assist provided by the Eclipse Java or C++ editor.

Content assist is invoked either explicitly by typing <CTRL>-<SPACE>, or implicitly when a ‘.’ is typed. In both cases, SVEditor provides a list of possible matches for the specified prefix.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 14

Getting Started with SVEditor v1.5

Override Tasks/FunctionsSVEditor provides a wizard that creates task or function templates for methods that are overridden by the active class. Open the Override Methods dialog from the context menu within SVEditor, as shown in Figure 15.

Figure 15 - Opening the Override Methods Dialog

When the Override Methods dialog opens, find the class and method to override and select it as shown in Figure 16.

Figure 16 - Override Methods Dialog

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 15

Getting Started with SVEditor v1.5

Selecting OK causes SVEditor to create a new method template at the cursor location, as shown in Figure 17. If Auto-Indent is enabled, the newly-inserted content will be indented.

Figure 17 - New Task Template

Indenting ContentThere are two primary methods for indenting content – auto-indent and explicit indenting. Auto-indent is enabled and disabled via the SVEditor Preferences page, and is enabled by default.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 16

Getting Started with SVEditor v1.5

Creating a New Class FileSVEditor provides a wizard for creating new class files. The wizard can be invoked from the main menu (File->New->SystemVerilog Class) if the SystemVerilog perspective is active.

The wizard can also be invoked from the context menu when a container (folder or project) is selected.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 17

Figure 18: Open the New Class wizard from the main menu

Figure 19: Open the New Class wizard from the context menu

Getting Started with SVEditor v1.5

Change the source folder if necessary. Specify the name of the class to be created. By default, the file name of the class will be classname.svh. If a different name is desired, uncheck the 'Default Filename' check-box and change the filename.

If the class being created extends from an existing class, either type the name in the 'Super Class' text entry or select the 'Browse' button.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 18

Figure 20: Browse for super-class

Getting Started with SVEditor v1.5

Classes that are accessible from the index of the containing project are available when browsing for a super-class. In this particular case, a new OVM test is being created, which must extend from ovm_test.

It is often necessary to implement the constructor of a class, especially if there is a super-class. Leaving 'Implement new()' checked causes the new class to implement the constructor. If a super-class is specified and that class has a constructor, a call to the super-constructor is made. In the case of our new test-case class, the following code is generated.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 19

Figure 21: New SystemVerilog Class generated code

Getting Started with SVEditor v1.5

Class Hierarchy ViewThe class hierarchy view provides a handy way to see the relationship between a class being editing and its super- and sub-class hierarchy (if any). The class hierarchy view is opened by selecting a class type (select the word or place the cursor on the word), and selecting 'Open Type Hierarchy' from the context menu, as shown in Figure 22. The Hierarchy View can also be opened using the F4 shortcut.

The hierarchy view shows the class hierarchy and the members declared by each class in the hierarchy. Double-clicking on a class in the class-hierarchy tree or a field, task, or function in the member list will open the corresponding source file in a new editor.

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 20

Figure 22: - Opening the Type Hierarchy Viewer

Getting Started with SVEditor v1.5

Key Bindings

Key Sequence Action

F3 Opens the declaration of the selected text or the text surrounding the cursor

F4 Opens the type hierarchy for the selected class

CTRL+I Auto-indent the selected text. If no text is selected, indent the entire file

SHIFT+CTRL+F Auto-indent the selected text. If no text is selected, indent the entire file

SHIFT+CTRL+/ Block-comment the selected text

SHIFT+CTRL+\ Uncomment the selected text

Copyright 2008-2010 Matthew Ballance. All Rights Reserved 21

Figure 23: - Class Hierarchy Viewer