This tutorial is intended to help an HDL user transition to using Eclipse with SVEditor as a plug-in. The tutorial will cover setup and installation of Eclipse and the SystemVerilog Editor and then take you through a quick tour of what Eclipse offers you over and above a normal editor like VI / EMACS.
First off Eclipse is an IDE, as opposed to an editor. Hopefully as the tutorial progresses the distinction will become more clear, but in it's simplest terms, an IDE is aware of the all the files in the project, and not just the file(s) that is/are open. This brings:
Eclipse is to Vi/EMACS, what Vi/EMACS is to Notepad. This is really good news, hang on to that thought. That said, this is a significant jump in functionality, and will take a bit of getting used to and to learn to take advantage of. Remember that it took a while to really start taking advantage of the features Vi/EMACS. Now you'd never go back to Notepad, would you?
It is going to take a little while to re-train your fingers. There are GOING to be functions that you are used to using that you either behave differently, or, occasionally are missing entirely in Eclipse. Eclipse has a significant number of features that your previous editor didn't have. In my experience, Eclipse brings enough "extra" that it significantly outweighs the "missing/different".
There are several ways of installing Eclipse and the SVEditor plugin for Eclipse. These are detailed on the Installing SVEditor page. If you do not have Eclipse and the SVEditor plugin installed please follow the directions on the link above.
The following sections take you through launching Eclipse, and some of the concepts that you'll come across when you first launch Eclipse including:
The first thing Eclipse asks you to do when launched is to Choose a Workspace. For this tutorial, choose the default location.
If you are asking yourself what a workspace is... a workspace is a place that Eclipse uses to do it's cache'ing. The following is an example of items that may be stored in the cache:
Please refer to the Appendix Workspace vs. Projects further on in this tutorial for more details.
First off, What is a perspective? In its simplest terms a perspective is a combination items associated with a given task / context including:
A perspective customizes the user interface for a given task. Developers will commonly switch between a JAVA perspective (where the window layout is primarily dominated by the code being edited) and a DEBUG perspective where the window layout is likely dominated by Watch windows, Breakpoint lists, console etc. You can change perspectives within a given workspace.
To open the SVE perspective Window>Open Perspective>Other>SystemVerilog. The System Verilog perspective can also be opened using the icon in the image below. Unused perspectives can be closed by right-clicking on the perspective and hitting Close.
A project in Eclipse terminology is a group of code that needs to be treated as a set. As HDL designers this is usually a group of files that we can synthesize and or simulate. Examples of projects include:
A Workspace could contain multiple projects. For example if you are working on 2 separate pieces of IP, they can both be open in Eclipse simultaneously.
This section of the tutorial will walk you through creating an SVEditor project in Eclipse, setting some environment variables and guiding you through the point where Eclipse has "compiled" or "indexed" your code. The following zip file contains two "dummy" chips, chip1 and chip2. These could be chips, modules, or any other piece of IP.
Environment variables are often used for various things in a design project. An environment variable could be used to point to a given place on the file system where libraries are used, or can be used to point to a location on the file system which contains locally checked out code.
Eclipse has the ability to store environment variables in it's .project file (which was created by Eclipse earlier in the tutorial). When an environment variable is called Eclipse will look:
For now though, we are going to set an environment variable that chip1 uses in it's files.f.
Advanced Notes
Eclipse stores it's project settings at the root of your project (these are the only files that Eclipse generates outside the workspace). The two files are .project and .svproject. These are xml files and can be browsed at your convenience.
Eclipse is aware of more than what is required to do basic code colorization. Eclipse is aware of the design hierarchy, class hierarchy and so on. To do this Eclipse needs to compile the code in your project. The compiled output will be stored in the workspace (note that this is not the same location as where the project is stored) leaving the area where the source code resides unaffected.
As you work (type) Eclipse will continually update the index, so you do not need to re-compile each time the code is edited.
A complete rebuild of all the code can be forced at any time by:
Congratulations. You've just loaded and compiled your first project bit of Verilog code!!!
Terminology Note: SVEditor stores the compiled code in an Index, hence the fact that index is used somewhat interchangeably with compile.
Editing in Eclipse with the default keybindings is the same as editing in any Microsoft product (no, don't run away screaming, it isn't that bad, there are alternatives. Just go with it for now.)
Here are some common key bindings that will get you around for now:
There are many ways of opening files in Eclipse. The obvious one is to use the mouse! The mouse can be used to traverse through the hierarchy in the "Project Explorer" view that comes up on the left hand side of the screen, expanding and collapsing directories. Double clicking on a file will open it.
Now for something fun. Type Ctrl+Shift+R, and start typing the name of the file you are looking for (in this case type "*mod").
Note that eclipse will filter all files in the project, narrowing the choices down as additional information is entered. Wildcarding etc makes finding a file anywhere in the design a breeze. No longer do you have to traverse the hierarchy to open a file. Naming conventions often dictate that module/class names match the file name. This makes opening up any module or class in the design a breeze.
Command Line: The command line also works believe it or not: eclipse <filename>
This portion of the tutorial will introduce you to the outline view and covers:
The outline view is a birds-eye view of items within a given file. There are a number of icons on the top of the view that allow filtering of various constructs. For instance, always blocks are typically not named, so including these in an outline view is just clutter. Module instantiations on the other hand are useful. Clicking on items within the outline view will take you to that location in the file.
The goal of this exercise is to instantiate a sub-module (called sub_module) in the design. To instantiate a sub-module:
sub_module1 sub_module1 (clk, rst, a, b, y);
sub_module1 sub_module1 (.clk (clk), .rst (rst), .a (a), .b (b), .y (y));
sub_module1 sub_module1 (
.clk (clk ),
.rst (rst ),
.a (a ),
.b (b ),
.y (y ));
The way modules, tasks & functions are instantiated as specified in the SVEditor preferences: Window>Preferences>SVEditor>ContentAssist.
Ctrl+Space supports all common constructs (if, else, always_ff etc.). Try instantiate an always_ff block.
These templates can be modified in the code templates selection of the preferences.
These can be edited/removed pretty easily as follows:
SVEditor is also class aware, and is able to instantiate class members (functions and variables) for you using Ctrl+Space.
Another way to do code completion, similar to Ctrl+Space is to hit Alt+/. This differs from code completion in that the index isn't searched, but text is extracted from anywhere in the current file.
A good place to use Alt+/ is to save time on typos. Using Alt+/ like you use the Linux command line Tab completion when typing variable names that are local to the file. This will ensure that variable names are correctly spelled, saving valuable debug time.
Commenting Code (Ctrl+/)Code can easily be commented out.
This is so awesome it deserves it's own chapter!!!
This is one area where Eclipse starts differentiating itself from a "normal" Editor. Because Eclipse parses the entire design that is loaded, it is able to navigate through the design. The following sections describe the primary means of navigating a design.
Open Declaration (F3)
Source code browsing is done using the F3 button. Open "top_module.sv" (Ctrl+Shift+R). Find where the module "sub_module1". Put the cursor in on the module name and hit F3. The file containing "sub_module1" will open up. Hitting F3 on any signal name, class instance etc. will take you to it's declaration.
F3 works on most items:
Hit Alt+Left Arrow which will bring the cursor "back in history", the same way as Firefox/Internet Explorer allow you to go back and forward through web pages.
Ctrl+Q will take the cursor to the last edit location, which is a huge timesaver.
Class Hierarchy (F4)
This feature is awesome for verification engineers. You can browse class hierarchy as follows.
While the class hierarchy view is open, you can click up and down any class hierarchy that exists, double click on any of the class names, will open up the class. Clicking on any of the functions will take you to that function in the class.
Design Hierarchy
System Verilog Editor can show the complete design hierarchy. To open the design hierarchy view:
Now that you have opened the second project, you'll note that due to some poor coding there is an error in top_module. The "x's" in the Project
Explorer window highlight files that have issues. This makes it easy to find issues when in the design.
The error checking isn't exhaustive, and at this point there are still some false errors, error misses etc. That said, it is pretty good and
will catch most syntax errors saving you a 5 minute compile to find a missing semicolon.
If you find issues with the parser, please [https://sourceforge.net/p/sveditor/bugs/|file a bug] on Sourceforge. The parser is continually being improved.
One of the things that you'll need to get used to when you first start using Eclipse is that you don't launch Eclipse to "Quickly edit a file". Eclipse is launched, a project is imported and Eclipse is left running permanently. File / buffer management in Eclipse is superb. You'll quickly find you have > 20 files open.
Before starting this exercise open up lots of .sv files
Buffer switching can be accomplished in any of the following ways:
Splitting Windows
Duplicating Editors
An editor can be duplicated (opened twice). Once cloned, these are viewed as seperate entities, and can be move around the screen independently. Editing in one, will impact the other. An editor can be cloned as follows:
Eclipse supports column editing.
Firstly the default key-binding is pretty much never available... so it needs to be re-bound.
Window>Preferences>General>Keys. Re-bind Toggle Block Selection to Alt+C
Trying it out:
The font in the editor probably changed when column mode was enabled. The column mode font can be changed in the preferences:
Eclipse will auto-indent code as it is typed. Type in the initial block below, watching how Eclipse moves begin / end etc as you type (most leading whitespace will work out without having to Tab or Shift+Tab to fix it).
i.e. Don't indent / out-dent as you type. You'll find that as you type the "d" in "end" the end statement will out-dent automatically.
Indentation of pasted code
Try pasting this un-indented code into top_module. Eclipse will fix the indentation for you.
initial
begin
if (j=1) begin
k=6;
end
end
Fixing Indentation (Ctrl+I)
Code that is poorly indented can be easily fixed. Select the block of code (mouse or keyboard) that is poorly indented and type Ctrl+I. Eclipse will fix the indentation.
If Ctrl+I is typed with nothing selected, the indentation of the entire file will be fixed. You can try this out as follows:
This is pretty awesome. No longer do you have to go to the command line to do a search through the directory tree of a project to find the file containing a cryptic log message. Hit Ctrl+H. This will bring up a very complicated dialog box that looks something like this:
Every language installed probably has its own search dialog. Search boxes that you don't use can be hidden by clicking on the "Customize..." button in the lower left.
The in-editor diff feature is convenient. Eclipse keeps a history of the file as it is edited. To diff a file against an earlier edit, or against a version in the repository is easy. Just Right-Click the file being edited, Compare With> Local History (or repository version if enabled) which will give the following screen. Click on the saved of choice and the diff will appear. In this case between 3:36pm and December 12, 2011, a comma was removed after "out2".
A Project is the equivalent of a chip or a design you are working on.
A Workspace, is an Eclipse concept which specifies:
A common question is "Should I have multiple Workspaces with a single project per Workspace or a single Workspace with multiple Projects loaded. For most scenarios it doesn't matter. The following table highlights some of the pros and cons of each usage model.
Usage Tip: On larger projects you can speed Eclipse up by making sure that your workspace local to the computer you are running on. i.e. Not on the network.
Once in a while you may choose to do things outside of the workspace (copy in a directory tree etc). F5 is used througout Eclipse refresh, in this
case refresh the data on the disk. For example, if you refresh your design from the revision control system on the command line, outside of Eclipse. Go to the Project
Explorer, and hit F5. Eclipse will refresh the file tree.
At times like this it is also worth re-building the System Verilog Database. Note that this is a separate activity from a file-system refresh.
Eclipse will automatically "Rebuild the SV Index" from time to time (when file system differences are detected). You can disable this in the SV Preferences Screen: Window>Preferences>SVEditor>Enable Index Auto-Rebuild
Eclipse preferences are managed in Window>Preferences. It can be somewhat difficult to find a specific preference. The search box is invaluable. Here are some of the commonly used preferences:
If code is documented using a "Natural Docs" style of coding, pop-ups will appear as the mouse moves over documented constructs. If the mouse is held over the mult function in top_module as shown, a pop-up will appear showing a description of the function.
How is this done? Jump to the mult function by putting the cursor on the mult instantiation and hitting F3. Look at the comment above the mult function, you'll see that this code has been replicated in this pop-up. The syntax is pretty intuitive. The long term benefit to people unfamiliar with the code base will pay huge dividends in the longer term.
Natural docs allows you to document variables, functions, tasks, modules etc. this way.
A Natural Docs compliant comment can be generated above Modules, Packages, Classes, Functions Tasks etc. by typing "/**<Enter>" on the line above one of these elements, or by simply typing Shift+Alt+J with the cursor in one of these elements.
Preferences are stored in the workspace. Switching between workspaces or creating new ones doesn't port preferences (key-bindings, colors etc.) automatically. This is both good and bad. On the one had it allows a different color scheme for each workspace, on the other they need to be managed. Fortunately this is really simple. It is also a good idea to back up preferences as you customize Eclipse.
Exporting preferences is easy:
Importing preferences in a new workspace is just as easy:
Eclipse does an excellent job of connecting to various revision control systems.
Below is a short list of keyboard shortcuts to get you going.
Like any good editor, key bindings can be remapped. For the EMACS & VI users (which is pretty much all of us) there are plugins that give Eclipse a EMACS/VI keybindgs and feel.
Keybindings can be changed at:
The SVEditor plugin is being actively developed. Updates based on user feedback are released fairly frequently. To update both the Eclipse installation and all installed plugins:
To update a specific plug-in:
Last updated April 2017, 1.9.9