The untold secrets of Sublime and Verilog

1. A brief introduction to SublimeText3

1.1 Charging issues

Although Sublime charges nominally, it officially supports unlimited trials. If the pop-up window prompts you to pay, just close it, so it's free.

1.2 compatibility

Sublime supports cross-platform, and supports Windows, Linux, Mac OS X and other operating systems. No compatibility issues have been encountered in current use.

1.3 Functionality

Sublime has a beautiful user interface and powerful features, such as code thumbnails, Python plug-ins, code snippets, etc. You can also customize the key bindings, menus and toolbars. Relevant enhanced functions are added by means of plug-ins, which is very extensible. Other more powerful editors, although powerful, but the ease of use deviation, need to learn. Sublime finds a balance between ease of use and functionality.

2. How to use Sublime Text3

-------------------As a Verilog programming worker, open Sublime in the correct posture

2.1 Software installation

Just log in to the official website and download it. Just like ordinary software, double-click the exe file to install it. But the point of using Sublime is plug-ins, so you need to install a plug-in "Package Control" to manage plug-ins.

2.1.1 The easiest way to install Package Control

method one:

Open Sublime Text3 and use the shortcut key ctrl + ~ to bring up the console. Paste the following code in the console:

import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

The Package Control plug-in can be automatically installed, which is used to manage other plug-ins. Or you can refer to the official website to install the plug-in in other ways.

Figure 1 Install Package Control

Method Two:

Open Sublime Text3, press the shortcut key Ctrl+Shift+P, enter package, and select Install Package Control to install, as shown in Figure 1.

Then, press the shortcut key Ctrl+Shift+P on the main interface of Sublime, enter install, select Install Package in the drop-down menu, as shown in Figure 2, and then another input box will pop up, and enter the name of the plug-in that needs to be installed. You can start installing other plug-ins.

 

Figure 2 Install Package menu bar

 

Figure 3 Operation status indication

After selecting Install Package, there will be a running animation shown in Figure 3 in the lower left corner of the Sublime software, indicating that it is connected to the official server. Please wait a moment and a second input box will pop up.

 

Figure 4 How to uninstall the plug-in

 

In the same way, press the shortcut key Ctrl+Shift+P on the main interface of Sublime, and enter remove, as shown in Figure 4. After selecting Remove Package, select the plug-in that needs to be uninstalled in the second input box.

2.2Sublime basic functions

2.2.1 File directory and window control

 

Figure 5 File directory

 

This function is very simple, just drag the source code folder in the project you need to view directly into the Sublime window, and the directory tree diagram will be displayed on the left side of the software, which is convenient for opening the corresponding *.v file .

 

Figure 6 Window division

Window control is to display codes in columns, and other software also has basic functions. Its shortcut key is ALT+SHIFT+2, and the number represents the number of columns.

2.2.2 Global Search

 

Figure 7 Global search

The function is very simple. You can search globally by using the shortcut key CTRL+SHIFT+F, which is different from the CTRL+F search method, which can search across files and display it in a window. Double-click it to display the corresponding place in the file. As shown in Figure 7, the left half is the search result, displayed in a window, and the right half is the corresponding place of the corresponding specific file.

2.3 One of the recommended plug-ins: Verilog syntax highlighting and automatic completion

After selecting Install Package in the above steps, wait to connect to the server, enter Verilog in the second input box, select Verilog, of course, you can also select System Verilog, as shown in Figure 8.

 

Figure 8 Verilog plugin

 

Wait a few seconds for the plug-in to be installed.

Functions supported by the "Verilog" plugin:

1. Syntax highlighting

2. Automatic completion (you can modify the completion method yourself)

3. Open the module file:

 

Figure 9 file opening

This function can easily open instantiated files . After opening the file directory, as shown on the left side of Figure 9, place the mouse on the module name, the blue name of the file will be displayed, and click the blue file name to directly open the module code.

2.3 Recommended plug-in two: ConvertToUTF8 Chinese display

When opening a file, many times the Chinese will display garbled characters, because it is not opened with a specific encoding method. This plug-in is designed to solve this problem.

As with the above method, use the shortcut key Ctrl+Shift+P, enter install, select Install Package, and enter ConvertToUTF8 in the second input box to install.

This plug-in can support GB2312, GBK, BIG5, EUC-KR, EUC-JP these coded fonts, especially the first two, which will be used when displaying in Chinese.

2.4 Three of the recommended plugins: SublimeLinter-contrib-vcom syntax check

The plugin has been renamed SublimeLinter-contrib-modelsim

This software can check grammatical problems and bit-width matching problems when entering codes. The basic principle is to use the grammar check function in modelsim, so the error checking function is similar to modelsim. But it needs to be based on another plug-in-SublimeLinter.

PS: There are other Verilog grammar check plugins in Sublime, but they are more complicated to use, need to compile third-party plugins, and there is a problem when checking errors, instantiation problems. When the top-level module instantiates other modules, other grammar check plugins will report an error, prompting that the instantiated file cannot be found, which is inconvenient to use. At present, this plugin has no problem in using it.

 

Figure 10 SublimeLinter plug-in installation

As with the above method, use the shortcut key Ctrl+Shift+P, enter install, select Install Package, enter SublimeLinter in the second input box, and then use the same method to install SublimeLinter-contrib-vcom, you can use it.

Functions supported by the "Sublimelinter" plugin:

1. Verilog syntax check, after rewriting the file, after saving the file with CTRL+S, if there is a syntax error, the software will automatically report an error.

2. Bit width matching error. After saving with CTRL+S, if there is a similar problem of 1'h23, the software will automatically prompt WARNING.

2.5 Recommended plug-in four: Sublimerge 3 file comparison

 

Figure 11 Sublimerge 3 plug-in installation

In the same way, use the shortcut key Ctrl+Shift+P, enter install, select Install Package, enter Sublimerge 3 in the second input box, and then use the same method to install Sublimerge 3, you can use it. It is recommended to use this plug-in for lightweight comparison, and it is better to use BeyondCompare for a large number of comparisons.

"Sublimerge 3" plug-in support function: code comparison (similar to BeyondCompare)

 

Figure 12 Comparison method between files

In the file directory, hold down CTRL and select 2 files at the same time, right-click and select Sublimerge->Compare Selected Files, you can compare, as shown in Figure 12.

 

Figure 13 Comparison within the file

Right-click in the file, you can also compare, select the corresponding menu to achieve the corresponding function, as shown in Figure 13.

2.6 Five of the recommended plug-ins: Verilog Gadget practical small plug-ins

 

Figure 14 VerilogGadget plug-in installation

Use the shortcut key Ctrl+Shift+P, enter install, select Install Package, and enter Verilog Gadget in the second input box to use.

Functions supported by "VerilogGadget" plugin:

1. Automatically generate TestBench file: Only use it in the module that needs to generate TestBench file, click the right mouse button, select Generate Testbench, and directly generate a Testbench file. Of course, the generated template can be modified by yourself.

2. Insert the file header: Right-click in the file and select Insert Header to insert the file header. You need to write the txt file of the file header in advance, where {DATE} is used for the current date, {YEAR} is used for this year, {TIME} is used for the current time, {FILE} is used for the current file name, and then set in the Sublime setting The path of the txt file in the file header will do.

3. Automatically instantiate the module: Right-click in the module and select Instantiate Module, and use the shortcut key CTRL+V in the top file to instantiate the module.

4. Automatic alignment: select the code to be aligned and use the shortcut key ctrl+shift+x to align.

Automatically repeat code: Right-click in the module and select Repeat Code with Numbers, which can realize the generation of automatic repeating sequence, which is very useful when writing case statements. Please refer to the official instructions for specific usage .

Guess you like

Origin blog.csdn.net/qq_33231534/article/details/107428702