Featured post

Top 5 books to refer for a VHDL beginner

VHDL (VHSIC-HDL, Very High-Speed Integrated Circuit Hardware Description Language) is a hardware description language used in electronic des...

Showing posts with label VLSI scripting. Show all posts
Showing posts with label VLSI scripting. Show all posts

Monday, 7 June 2021

Effective VIM Editor tips, tricks and plugins to improve coding speed in VLSI

One of our colleagues always had to struggle with the Verilog / SystemVerilog syntax. Whenever he opens a .sv file he needs to set the syntax manually as ":set syntax=verilog". This really kills time, especially when you are working on a project with tight schedules. 

So today we are sharing a bunch of good tricks and different plugins that will help you code efficiently, whether Verilog, System Verilog, UVM or scripting languages like Perl. 

VIM editor is so powerful that everything can be modified using the keyboard. No need to raise a hand to reach out to the mouse. Thus the efficiency of working improves a lot and also looks more professional.

By default, vim invokes .vimrc every time a new file is opened. So we may configure any settings upfront in ~/.vimrc for making life easy while working with files.

We will start with basic keyboard shortcuts which will help us to work faster than the actual way.

Opening a fine using GVIM

To open any file from shell type :
gvim <filename>

By default, vim invokes .vimrc every time a new file is opened. So we may configure any settings upfront in ~/.vimrc for making life easy while working with files.

if you want to open multiple files in tab pages
gvim -p <filename1> <filename2> ..

if you want to open multiple files in horizontal windows
gvim -o <filenames>

if you want to open multiple files in vertical windows
gvim -O <filenames>

Shortcuts for moving the cursor:

h - move left
j - move down
k - move up
l - move right

Shortcuts for quick editing:

Letter level
r - quickly replaces the letter under the cursor.
i - change to insert mode. (ready for typing from before the cursor position) Esc to come out of insert mode.
I - change to insert mode at the start of a line.
a - change to append mode. (ready for typing after the cursor position), type ESC to come out of append mode.
A - change to append mode at the end of the line.
x - deletes the alphabet under the cursor and starts deleting the forward direction.
X - exactly like the backspace function.
o - change to insert mode on the next line.
O - change to insert mode on the previous line.
f - find a letter in the forward direction of a line.
F - find a letter in the backward direction of a line.

Word Level
w - move to the start of one word at a time.
      You can put any number upfront to move that many words
      Eg: 5w - From 1st word jumps to the start of 6th word.

b - move to the beginning of the word at a time.
e - move to the end of one word at a time.
y - yanks (that means you can copy a word till the end of a word, or a line, etc by using commands ye, yw, yy, etc)
p - paste whatever is yanked after the cursor
P - paste whatever is yanked before the cursor
d - deletes (that means you can delete a word till the end of a word, or a line, etc by using commands de, dw, dd, etc)
D - deletes from the cursor position to the end of the line.
0 - Go to the start of the Line.

Other General commands with keys
u - undo
gg - Go to the start of the file
G -  Go to the end of the file
ZZ - write, save and close the file
H - Head of the file in the visible pane
M - Middle of the file in the visible pane.
L - Last of the file in the visible pane.
v- enter visual mode from the alphabet under the cursor.
V - enter visual mode from the line under the cursor.
Advanced commands :
q - recording (will explain this in detail)
/ - search a word (eg : /<pattern>)
n- searches any word in forwarding direction
N - searches any word in the backward direction
. - repeats the last done job again.
? - for searching a word backward (more powerful than / )

Other General commands with additional keys
ctrl + e - scroll in forward direction
ctrl + p - scroll in backward direction
ctrl + r - redo
ctrl + a - increment the number in the line.
ctrl + x - decrement the number in the line.
ctrl + q or ctrl + v, enter visual mode in the column.
Shift + ~ - Invert the text case under the cursor
Vu  - if you want to convert the whole line of text under the  cursor to a Lowercase line
VU - if you want to convert the whole line of text under the  cursor to an Uppercase line

In gvim by typing ":" we enter into command line mode, we have a specific set of commands to use at this level.

How do I switch between panes in a split mode in Vim/GVIM ??

In command mode, hit Ctrl-W and then a direction, or just Ctrl-W again to switch between panes.
:b <number>  will open the specified buffer in the current pane.
Example  : UNIX > vim test_1 test_2 ; #  This command opens two test_1 and test_2 files
But in vim, we can see only one file(by default the first file test_1) with this approach.
If want to go to the test_2 file then use :b 2

:ls will show your open buffers
If we opened multiple vim files like above and want to know which are in buffer use this command
and with the help of :b <number>, we can switch between files

If we open many windows in vim/gvim  and you want to have equal window size for all split pans
Esc mode  Ctrl+W =
For more info type:
:help window-resize

you can use <ctrl> + w + w To switch the panes in order.
A suggested way is to put these codes in your vimrc file

map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

How to remove blank lines from a file?

Here's a handy one-liner to remove blank lines from a file.
           :g/^$/d
Breaking this down. The "g" will execute a command on lines that match a regular expression.
The regular expression matches blank lines, and the command is "d" (delete).
You can also use
           :v/./d
(v means complementary, so any line that doesn’t have a single character at least will be deleted)

How to implement AUTO-COMPLETION 

Ctrl+p   to insert the previous matching word
Ctrl+n  to insert the next matching word
Ctrl +x  followed by Ctrl+l to complete a whole line from the buffer
(basically ctrl + x pressing will open a sub-mode from there on we can do a lot of stuff.
for example ctrl + l in submodel gives you to complete the whole line )


More content coming soon ....

Monday, 10 August 2020

Useful Vim plug-in for efficient coding in Perl

Think of a plug-in with which you can do the following while coding a Perl script:

  • Auto addition of file header
  • Easy addition of function/frame comment
  • Quick inclusion of default code snippet
  • Performing syntax check
  • Reading documentation about a function
  • Converting a full code block to comment, and vice versa
  • Help to speed up the code writing with consistency in coding.
One-stop solution for all these things is a perl-support vim plug-in

The Perl-Support Vim Plugin – Perl-IDE offers the easiest way to do all of the above, saving a lot of time and keystrokes.

We have already discussed in an earlier article regarding Use of Scripting languages in VLSI

We will be covering the following in this article

1. How to install perl-support plugin to use it with VIM.

2. Powerful features of the Perl-support plugin.


Steps to install Perl-Support VIM Plug-in


1. Download the plugin from the vim.org website.

Click here to download to go to the download page

Alternatively use below command

cd /usr/src/
wget http://www.vim.org/scripts/download_script.php?src_id=9701

2. Copy the zip archive perl-support.zip to $HOME/.vim and run below command

  unzip perl-support.zip

This command will create following files:

  $HOME/.vim/autoload/mmtemplates/...

  $HOME/.vim/doc/...

  $HOME/.vim/plugin/perl-support.vim

3. Loading of plug-in files must be enabled in $HOME/.vimrc. If not use previously

  filetype plugin on

Create .vimrc if there is none or use the files in $HOME/.vim/perl-support/rc as a starting point.


After done with installation lets get to know about

The Powerful Features of Perl-support


1. Add Automatic Header to *.pl file whenever you create a new file

2. Insert statements

3. Insert frequently used statements

4. Insert special variables

5. insert code snippets and manage templates

6. Run a profiler

7.  Run the script, check the syntax, start the debugger

8. Make integration


Details of all these can be found at 



Thursday, 6 August 2020

Use of Scripting languages in VLSI


Very often we come across questions from VLSI engineers that "Which scripting language should a VLSI engineer should learn?".

Well, Shell, Tcl, Perl, and Python are the scripting languages that are commonly used for VLSI front end/back end design automation and related applications. 

TCL: Tcl (pronounced "tickle" or as an initialism) is a high-level, general-purpose, interpreted, dynamic programming language

PERL: Practical Extraction and Reporting Language

PYTHON: Python is a dynamic, object-oriented, high-level programming language that can be used for many kinds of software development/scripting.

Shell Scripting: A shell script is a computer program designed to be run by the Unix/Linux shell which could be one of the following:

The Bourne Shell / The C Shell / The Korn Shell / The GNU Bourne-Again Shell

A shell is a command-line interpreter and typical operations performed by shell scripts include file manipulation, program execution, and printing text.
 
Perl has been in use for several years, but python is increasingly becoming more popular. In the past, we have already shared out views on the advantages of Python. Ref: Advantages of Python over Perl

Tcl is also used mostly for tool interfaces as several EDA tools support that.

If you know any kind of programming, learning a new scripting language will be easy.

Following are some commonly used applications of scripting languages in VLSI:
  • Front end RTL/Testbench code compilation and simulation flows
  • Automation of running tests in regressions, generating reports, analyzing failures, debug automation
  • Connectivity checks, netlist parsing, automatic generation/modification any RTL module/stubs, etc
  • Synthesis, P&R tools interfacing, and back end flow.
  • Several project management utilities - regression pass rates, trends, bug charts, etc - that helps in tracking projects
  • Any other task that is repetitive in workflow and can be automated.
Here is a complete comparison of TCL, PYTHON and PERL.