SESSION#1
- Linux OS
o Electronic system : 5 layers
User (you, me)
Applications
Operating system
Firm ware
Hardware - Linux is best suited for multi user and multi task applications
o Instiutte server
o at same time 30 people login to the same server and run the applications
o 30 : multi user
o each of them running different jobs: multi task
o what happens in Windows?
o logout and log in as new user
o Windows is capable of multiuser and multitask, but not as good as Linux is.
o Summary
o Linux is a better choice for all project execution, since it requires multi user and multi tasking requriements.
o Hence 99% of the project work we do is based on Linux OS.
o where do we use Windows?
o opening PDF and Word docuemtns, XLS, editing those
o checking mails.
o Linux is more attactive becuase it comes free of cost.
o Linux is developed as open source, any one can contribute and any one can use at no cost. - linux and unix are same thing..?
o UNIX is the architectural level description
o Linux is implementaiton of this architecture - Shell scripting
o scripting based on Linux commands - Shell is the place where we are enteirng the vairous Linux commands
ls -ltr
Shell is understanding this command, executing that.
6Q. is this same like c , java coding sir ?
o Linx is not same as C/Java
Apple and Oragen => fruites, different for many reasons
- How to set alias
alias abcd=”ls -ltr”
alias mem_ctrl_top=”cd /home/VLSIGuru/MEM_CTRL/verif/top”
alias mem_ctrl_ref=”cd /home/VLSIGuru/MEM_CTRL/verif/ref”
alias mem_ctrl_ckr=”cd /home/VLSIGuru/MEM_CTRL/verif/ckr”
alias mem_ctrl_sim=”cd /home/VLSIGuru/MEM_CTRL/verif/sim”
alias mem_ctrl_memories=”cd /home/VLSIGuru/MEM_CTRL/verif/memories” - we have multiple bashrc files? is it not unique?
o not possible to have multiple bashrc files - how can we update that file?
o we will not update reference file
SESSION#2
questions
- installed but not coming like ls python ,perl like all
agenda:
- How to list files and directories in a specific directory
- What are the properties of the files and directories.
- How to create and delete(remove) files and directories
- How to move from one directory to another directory
- How to move or copy files and directories.
- How to rename the files and directories
- Change the properties of files and directories
- How to open the file and edit the contents, save the file.
- Hide some of the files.
notes:
- How to list files and directories in a specific directory
ls : just lists the files and directories
ls -l : show all files and directories in long listing format
ls -lt : show all files and directories in long listing format with latest updated file in top of the list
ls -ltr : show all files and directories in long listing format with latest updated file in bottom of the list
we can also create alias for the long commands:
alias ll=”ls -ltr”
how to list only the directories in current directory:
ls -d */
how to list only the files in current directory:
ls -f */
While I am in one directory, we can list the files and directories that are there in different directory.
ls
We don’t need to go to that path to list the directories and files in that path.
We can list only specific type of files by using * and ? meta characters
ls .v Above command lists all .v files in current folder ls tech28*.lib
Above command lists all the files which start with tech, has 28 in between and ends with .lib
ex: tech_28nm.lib will be listed
ex: tech_28nm_lib will not be listed
2Q. how t create alias
- cd
cd : Change Directory
cd . : be in the current folder, this command is not used much
cd .. : takes us to the folder above the current folder
cd – : takes us to the just previous folder we were in, before coming to the current folder
cd : takes us to user home directory
why /home/VLSIGuru? why not /home?
Linux is multi user OS, /home has many other users below it.
/home doesn’t belong to you.
pwd: present working directory - What are the properties of the files and directories.
is it a file or directory?
what is the size?
what are the permissions?
when was it created?
Who created the file?
Who has edited the file last time?
Name of the file or directory?
o this information we get by using long listing format. long listing format:
1st thing: 10 characters
-rwxr-x—
– : first – => it is a file, not a directory
rwx : - Linux based systems
o all the users can be divided in to 3 categories
o user
2nd to 4th: corresponds to user permissions
rwx: as the owner of the file, I have read, write and execute permission to the file.
o group
5th to 7th characters: corresponds to group permissions
r-x : Group has permission to read the file, and execute the file, but no permission to change the content.
o public
8th to 10th characters: corresponds to public permissions
— : Other public don’t have any permission to the file, they can’t read, write or execute the file.
o If I join a company, who is user, who is group and who is public?
o Qualcomm, Snapdragon 851 PD project
Sreenivas joined in to above project
User: Sreenivas
What files he creates, he is primary user(owner) of those files.
Group: Team members make the group
Snapdragon 851 PD project consists of 30 members in total (1 + 29 others)
All those 30 people make a group
As a owner of a file I am creating, I can decide what permission should I give to the group.
Public (If Qualcomm has 10000 employees)
9970 remaining employees are Public
o When a primary user creates a file, he/she can give the required access permissions to that file to various users.
o How to change the permissions?
will be discussed later - What is meant by an executable file?
o these are file which can be run by the user
o how do we run a file
./file_name
the instructions in the file name gets executed. - In this directory(/home/VLSIGuru/A_VERILOG_MAY2021), I want to list all the .v files
o what command should we use
o ls won’t be useful here. Ls only works on once specific directory.
o Our requirement needs to check all the directories below current directory.
o best suited command for that is: find - find . -name “*.v” | wc
find : find files and directories
. : where should I start my search?
. : current folder
.. : previous folder(up)
find . => find things starting from current directory
-name : command options
o what name you want to find
*.v : find all the files names which end with .v, in all teh directory and directories below this.
| wc
| => used to merge two command operations
find command gives us an output
| is called as pipe
output of previous command, becomes input to the next command after the pipe(|)
what is the next command (wc)?
wc : word count Output:
find . -name *.v | wc
41 41 1142
41 lines
41 words
1142 characters - list all the text files
find . -name *.txt | wc - List all the directories below user home directory
find has a option called -type
-type d => list the directories
-type f => list the files
find . -name “*” -type d
* : file or directory with any name
-type d : search only for directories - List all the files below user home directory
find . -name “*” -type f - How to create and delete(remove) files
touch : command used to create a file
rm : remove the file
only the primary user(owner) can remove the file
rm -f : forceful remove
Windows, OS will warn you regarding removal
-f : forcefully remove
Primary user, I may have given only read permission to the file(no w and x), rm will not allow me to remove.
rm -f will remove in this case.
we can create and remove the files in different directories also.
touch directory_path/file_name
rm directory_path/file_name
we need to be careful with file removal
undo is not possible
there is no recycle bin as in Windows.
– There is solution based on Linux OS settings
o Linux has some concept of snapshot, they keep snapshot of the file every day or every week
We should be very careful while using rm command
once deleted, it is gone, difficult to retrive - How to create and remove directories
mkdir : command used to create a directory
make directory
rmdir : remove the directory
only the primary user(owner) can remove the directory
rm -r can also be used in place of rmdir
-r : recursive removal, i.e remove everything in this directory and directories below it.
we can create and remove the directories in different directories also.
mkdir directory_path/directory_name
rmdir directory_path/directory_name
we need to be careful with directory removal
undo is not possible
there is no recycle bin as in Windows.
– There is solution based on Linux OS settings
o Linux has some concept of snapshot, they keep snapshot of the directory every day or every week
creating parent directories:
mkdir -p PD_PROJECT/INPUT_FILES/LIB_FILES/28NM
$ mkdir PD_PROJECT_1/INPUT_FILES/LIB_FILES/28NM
mkdir: cannot create directory ‘PD_PROJECT_1/INPUT_FILES/LIB_FILES/28NM’: No such file or directory
14Q. ls -d
sir can list director by this command?
15Q. while creating directory does it give permission by default? like in SAMPLE_VERILOG – rwx-rx–x–
o every OS will have default permissions with which it creates files and directories
- how to change the properties of files and directories
chmod: change file mode bits
what are these mode bits?
drwxr-x—+ ==> mode bits two ways to use chmod:
chmod 3-NUMBERS
chmod user_based_update - chmod with numbers:
chmod 777(otehr combinations)
chmod can be applied for complete set of files
o it can also be done in recursive manner, it needs to be done very carefully, it can be undone.
chmod -R 755 .
o -R : recursive update
chmod cna only change permissions, it can make a file to directory or vice versa - chmod with used based arguments:
u : primary user
g : group
o : others or public- : give permission
- : remove permission
r : read
w : write
x : execute
chmod g+rw file_name
o don’t change execute permission
o if it was earlier execute permission, let it be
o if it was earlier not-execute permission, let it be chmod o-rw+x ses3_30May.txt
remove rw permission and add execute permission. we can’t run different user permissions in single command, that is the limiation of this option.
chmod g-rwx o-rwx u-rwx ses3_30May.txt
above command won’t work
we need to run individually - among these which oen to use
o user convineince - How to move from one directory to another directory
cd : change directory
Either user should know absolute path or relative path.
absolute path:
cd /bangalore_centre/my_locality/my_main_raod/required_street
relative path:
cd ../new_street_to_go
This is always same command every directory movement, it depedns on where we are and where we want to go.
cd ../../../
takes us 3 directories back - How to move or copy files and directories.
mv : move
cp : copy
copy for directory requires -r option
-r : recursive copy, without -r, directory copy doesn’t work cp NOTES/ LABS
cp: -r not specified; omitting directory ‘NOTES/’
22Q. command to see the history of command?
history
- How to rename the files and directories
mv is used to rename the files and directories
mv course.txt course_new.txt
mv source_dir_name dest_dir_name - mv can be used for two purposes
o moving some files and directories to other directories.
o renaming the files and directories - How to open the file and edit the contents, save the file.
to open a file:
– We need to identify the type of the file.
– choose the right application for that file opening.
for ex: a text file can be opened with vi, vim, notepad, notepad++, nedit
.doc : can we open with notepad? we need to choose right application, in this ooffice
linux has ooffice which is similar to MS office.
one file is opened, we need to understand how the file editing application works, accrodingly we need to edit and save the changes. - Hide some of the files.
create the file with .file_name, it becomes hidden file - Display contents of a File
cat file_name - wc ses4_2Jun.txt
71 353 2083 ses4_2Jun.txt
71 : number of lines in the file
353: number of words
2083 : number of characters in the file
wc *
0 0 0 course_new.txt
259 1551 8967 ses1_25May.txt
237 1299 7467 ses2_27May.txt
107 681 3963 ses3_30May.txt
71 353 2083 ses4_2Jun.txt
133 660 3935 ses5_5Jun.txt
0 0 0 session_24June.txt
807 4544 26415 total
29Q. cd ..,..>>>>/cd ../../../?
No, wrong
30Q. After our project how to move to next file sir
there is nothing like moving from one file to other
SESSION#3
revision:
- How to create and delete(remove) files and directories
- How to list files and directories in a specific directory
- What are the properties of the files and directories.
- How to move from one directory to another directory
- How to move or copy files and directories.
- How to rename the files and directories
- Change the properties of files and directories
- How to open the file and edit the contents, save the file.
- Hide some of the files.
Agenda:
- Copy one directory from a different path in to current directory
- escape, backspace => delete one whole word
- How many files are there in 3 directories all together?
- find . -name “*” -type f | wc
120 120 3650
- find only verilog(.v) files
find . -name “*.v” -type f | wc
97 97 3108
- Size of all these directories?
du -sh file_name or directory_name
du -sh *
o list size of all the things in current directory
why knowing size of files and directories is important?
o every project will have some limitations on file and directory sizes.
o User should always keep track of how much diskspace he is using. - ls -ltr
doesn’t give the size of the directory. - how to remove single file?
rm file_name - List all files in current directory in to a text file
Output direction symbol should be used. - can we restore recently deleted file?
No, it is not possible - ls > file_list.txt
above > symbol is used to redirect all the command output to a text file.
|&tee
10Q. basically it is giving all the details of file in one Txt file?
o we redicrted, it gave
wc * > wc.txt
- how to link gvim with cygwin? so that file can be open in gvim ?
o there is nothing like linking gvim and cygwin
o gvim is a differetn application
o gvim is a text file editor
o cygwin is a differetn application
12Q. like we used vi we can use gvim
GVIM: Graphical VIM
o Graphical: some window should pop out, cygwin doesn’t allow windows to pop out
- While installing Cygwin, choose editor
14Q. how to choose single editor after installed cygwin
that he said we can install editor in just 5 min how we can do without installing whole package again
o Cygwin is download some database from mirror servers
o you have already downloaded all the packages
o editor will require few additional things => 5 minutes to download them
- Linux has important concept called as, which
which
o it gives complete path of that executable
[root@vlsiguru ~]# which vcs
/home/tools/synopsys/new_tools/vcs/P-2019.06-SP2-8/bin/vcs
o this is the path where VCS tool is installed
o which version of VCS used? P-2019.06-SP2-8
This uses some concept called $PATH from where it gets all the paths where it needs to search.
- root has complete authority in the OS
yum install perl
o this command establishes connection with the required server, downloads the files and install them. - GVIM editor
o two modes
o Insert mode
o Escape mode - Linux FIle system
How files and directories are organized in Linux OS Windows:
C:, D:, E, F
C:
Program files
Program files (86)
19Q. what is the use of bin if we cant recover file after rm command? Bin is kind of Recycle Bin or it means different?
o bin : Binaries
o ALl things installed in any OS, they are binary files
20Q. tcl not instld in cygwin sir
which tclsh, not tcl
21Q. how you are getting full name by typing just one alphabet or command is coming automatically with typing it completely
enter initial characters, then do tab, it automatically fills
22Q. can you repeat what is parent directory in our example?
- Environment variables
- There are the special variables in the operating system. OS uses these variables for different requirements.
- 15 to 20 standard environment variables
SESSION#4
revision:
- Environemtn varibales
Agenda
- Environment varibales
- Pipe(|), xargs
- SED
- AWK
Notes:
- PS1
o Prompt Script 1 - Whatever Shell settings I want to take effect in the terminal, we keep them in ~/.bashrc or ~/.tcshrc
- what you did for tcsh in that server login i didn’t got it
o - xargs
./design/CVS/Entries
./design/doc/CVS/Entries
./design/rtl/CVS/Entries
./design/sim/CVS/Entries
./design/sim/CVS/Repository
./design/sim/CVS/Root
- using xargs, we are able to process 100’s of files in few seconds
o Ex:
o in all the files, we replaced dma with cma
find . -name “*” -type f | xargs sed -i -e ‘s/dma/cma/g’
find : listing all the files in current directory and below
xargs: running sed operation on all those
sed : it is replacing dma with cma
s/dma/cma/g : search and substitute dma with cma globally
o sed: Stream editor - SED and AWK
SED: one type of Linux command
AWK: one type of Linux command
- SED is useful for procesisng the text inside the file
- AWK
- find . -name “*” -type f | awk ‘{print “mv “$1” “$1}’ | sed ‘s/dma/cma/3’ | sed ‘s/dma/cma/4’ | grep dma > rename.txt
- above command consists of 5 commands in it, separated by | symbol
- find . -name “*” -type f
o listing all the files - awk ‘{print “mv “$1” “$1}’
8.
sed ‘N; s/\n / /; P; D’ inputFileName
It starts processing from the 1st line
o 1st line it holds
o N : start processing next line also along with the current line
o because of this, it starts processing both the lines together
o each input of sed is separated by ;
o s/\n / /
o search for new line character followed by a space
o Print it
o Once printed, delete the line from hold space.
- sed is useful for text processing
- how sed works
o it opens the target text file
o starts reading each line in to pattern space
SESSION#5
revision:
- Linux commands can be categorized in to 2 things
o simple commands that we use everyday
o complex commands that are used specific to some requirements - Linux gives us option to run multiple commands together
o running them separately in single line
o running them in such a way that one command output becomes input to the next command
Questions:
- doubt regarding Assignment Question which you share earlier for unix what is $LM_LICENSE
o LM_LICENSE
o For each tool to work, we need to set a license file.
o The path of the license file is set in to LM_LICENSE environemtn variable.
o When we invoke the tool, the tool checks for LM_LICENSE path
o it uses that corresponding license file.
Notes:
- Running Linux commands in single line
[Tue Jun 29 15:11:20 LABS]>ls; wc rename.txt; cd ..; pwd
design dma_axi64 rename.txt rtl_new sample.txt UVM_ses2_31May.txt
62 186 4366 rename.txt
/cygdrive/f/VLSIGURU_MATERIAL/UNIX/Linux_Jun2021 - running them in such a way that one command output becomes input to the next command
o pipe (|)
o pipe can’t be randomly used on anything ls| wc rename.txt| cd ..| pwd - grep
- same character can have different meanings
Verilog:
b = a&c; //&: bitwise and operators
b = &c; //& : unary & operator
b = a&&c; //&& : logical & operator
- what LSF, BSUB?
o another session to discuss these
SESSION#6
revision:
- grep
o various options of the grep
o special characters - Linux training
o Linux OS is all about 50 commands
ls, pwd, cd,
questions:
- Question No 15(a) how to make a tcl file, Directly should i make it like touch sample.tcl File then go as per the step or should i need to access it with tclsh then inside them i have to make it ? It is from 1st Assignment
touch print.tcl
tcl has not relation with tcshrc, both are completely different - ping
ex: Google.com must have hosted with some IP address
ping IP_ADDRESS - uname -a
o used to find whether machine is 32 bit or 64 bit - how to create a new user and to set password
Linux terminal
useradd
passwd ram => to change teh password
agenda:
- we will complete all the topics other than Sed, Awk
- LSF, BSUB, sleep, sort
Notes
- will it sort only by comparing 1st word of lines ?
o it compares all the characters starting from 1st characater abcdej
abcdef ==> 1st o anotehr example
abcdej ==> 1st
accdef - grep command is used for?
o searching a string or word inside a file - In .* convention
systemverilog
s.verilog .: ystem - Create Verilog design instance
- one way
o manually code => which is very tedious
dma_axi64 dut(
.clk(clk),
so on);
= other way, is by using functions in GVIM module dma_axi64(clk,reset,scan_en,idle,INT,periph_tx_req,periph_tx_clr,periph_rx_req,periph_rx_clr,pclken,psel,penable,paddr,pwrite,pwdata,prdata,pslverr,pready,AWID0,AWADDR0,AWLEN0,AWSIZE0,AWVALID0,AWREADY0,WID0,WDATA0,WSTRB0,WLAST0,WVALID0,WREADY0,BID0,BRESP0,BVALID0,BREADY0,ARID0,ARADDR0,ARLEN0,ARSIZE0,ARVALID0,ARREADY0,RID0,RDATA0,RRESP0,RLAST0,RVALID0,RREADY0); bring to below format:
//Instinatiing the design
dma_axi64 dut(
.clk(clk),
.reset(rst),
.scan_en(scan_en),
.idle(apb_pif.idle),
.INT(apb_pif.INT),
.periph_tx_req(periph_pif.periph_tx_req),
.periph_tx_clr(periph_pif.periph_tx_clr),
.periph_rx_req(periph_pif.periph_rx_req),
.periph_rx_clr(periph_pif.periph_rx_clr),
.pclken(apb_pif.pclken),
.psel(apb_pif.psel),
.penable(apb_pif.penable),
.paddr(apb_pif.paddr),
.pwrite(apb_pif.pwrite),
.pwdata(apb_pif.pwdata),
.prdata(apb_pif.prdata),
.pslverr(apb_pif.pslverr),
.pready(apb_pif.pready),
.AWID0(axi_pif.awid),
.AWADDR0(axi_pif.awaddr),
.AWLEN0(axi_pif.awlen),
.AWSIZE0(axi_pif.awsize),
.AWVALID0(axi_pif.awvalid),
.AWREADY0(axi_pif.awready),
.WID0(axi_pif.wid),
.WDATA0(axi_pif.wdata),
.WSTRB0(axi_pif.wstrb),
.WLAST0(axi_pif.wlast),
.WVALID0(axi_pif.wvalid),
.WREADY0(axi_pif.wready),
.BID0(axi_pif.bid),
.BRESP0(axi_pif.bresp),
.BVALID0(axi_pif.bvalid),
.BREADY0(axi_pif.bready),
.ARID0(axi_pif.arid),
.ARADDR0(axi_pif.araddr),
.ARLEN0(axi_pif.arlen),
.ARSIZE0(axi_pif.arsize),
.ARVALID0(axi_pif.arvalid),
.ARREADY0(axi_pif.arready),
.RID0(axi_pif.rid),
.RDATA0(axi_pif.rdata),
.RRESP0(axi_pif.rresp),
.RLAST0(axi_pif.rlast),
.RVALID0(axi_pif.rvalid),
.RREADY0(axi_pif.rready)
); steps:
– keep each signal in one-one line - 5 to 10 => 5 lines or 6 lines? 6
- totalyl 45 lines
455 => will it work? it won;t work => totally 5 times it will happen
445, 5 => 44+1 = 45 times
linux is good operating system, which can be mastered by practice.
- Process management
8Q. how to know which PID is for which process like in Windows in Task manager we get running Application Name. How to find it by PID Number?
o ps will give all the details
PID
- bsub, LSF
- How to give priority to any job ?
o If we get check with IT(server admin) team, they will provide following details
o which server farm(LSF) has server freely available
o you launch the jobs on that server
o bsub command some options which cna give priority to speicifc job. - FTP
file transfer protocol- It is used for transferring a file form one server(PC) to another server(PC)
Any File transfer application will require me to login to the server(desitation)
o ftp
o scp
o server copy
- TOpics pending
o CTAGS
o basic linux commands
o sleep
o more, less, head, tail, cat
o sed, awk
SESSION#7
revision:
- GVIM techniques
o Function
o Visual block - ping
- LSF, BSUB
Agenda:
- sleep
- file display commands
- CTAGs
- Some generic commands
- FIle compress and extract
- Makefile
- softlinks
- SED
- AWK
Notes:
- sleep
- ctags
o what are tags
o tags is a file that is created with pointer to the various files where keyword is defined
o how to create tag file
o Go to the top most directory of the project(or the places under which all the project files are present)
o ctags -R .
o we can also select the diretories to tag
o how to map GVIM with tag file
o :set tags=tag_file_name
o how to use tags to navigating the file
o keep the cursor on the keywrod(tag) we want to search
o ctrl+] => will show us available options which are pointing to that tag
o enter the number, that destination file automatically opens
o if there is only one option, it automatically takes us to that file.
o to come back use, ctrl+o - Some generic commands
- What is significance of \ while running Linux command in shell?
o 30/June, I gave 12 questions to complete
o you may not know answers for all 12 questions==> this is not a problem - FIle compress and extract
Windows:
right click, zip or rar
Linux:
commands to do this
tar - Makefile
- sed
- once please explain again \n part how its deciding alternate
- two categories of sed
o delete based on search operation
o search and subsitutte
o display the lines of a file
o delete specific lines of a file
o using different apprach - Important thing about sed is
o it processes informaiton line by line, not a whole file
o if we want to merge multiple lines for processing in single pattern space, use ‘N;’
o all options needs to be separated by ; inside ‘ ‘ - can you please explain how to delete space infront of a specific line
- what to do for undo the last command output? to go to previous output
sed without -i option
output gets displayed to the screen, review that output, if it is proper, then run same command with -i option, the file will get updated.