登录 免费注册 首页 | 行业黑名单 | 帮助
维库电子市场网
技术交流 | 电路欣赏 | 工控天地 | 数字广电 | 通信技术 | 电源技术 | 测控之家 | EMC技术 | ARM技术 | EDA技术 | PCB技术 | 嵌入式系统
驱动编程 | 集成电路 | 器件替换 | 模拟技术 | 新手园地 | 单 片 机 | DSP技术 | MCU技术 | IC 设计 | IC 产业 | CAN-bus/DeviceNe

IC设计的脚本设计之旅

作者:rickyice 栏目:IC设计
IC设计的脚本设计之旅
Scripting Tutorial
This Scripting tutorial was added to help new engineers to learn bascis of scripting, Makefile, CVS and jump start with Unix OS.  

* - 本贴最后修改时间:2006-5-31 16:00:25 修改者:rickyice

2楼: >>参与讨论
rickyice
Introduction
In ASIC world real work is done in Unix OS, (earlier it was Sun and HP unix, now it is Linux.). In Unix we have lot powerfull tools to make life easier. This basically help in automating routines jobs. Like Makefile helps in automating the compiling PROCESS, one need to type the command LINE options eveytime one wants compile. Take another example, CVS helps to KEEP track of changes in files, helps in tagging files for release. This are ONLY few examples, but the list is LONG.

    

  In next few pages, I will make a effort to share  experience in how to use scritping, Makefiles, CVS in ASIC world. After reading these SHORT tutorials, one should be in a position to use them in real projects.

    

  As usual, you may find mistakes in what I have written, or you have better way to put this tutorial, or you think I need to know about something. Please add it.



3楼: >>参与讨论
rickyice
Unix Basics Part-I
Introduction  
  UNIX is a COMPUTER operating SYSTEM.An operating SYSTEM is the program that CONTROLs all the other PARTs of a COMPUTER SYSTEM, both the HARDWARE and the SOFTWARE. It allocates the COMPUTER's resources and schedules tasks. It allows you to make use of the facilities provided by the SYSTEM. Every COMPUTER requires an operating SYSTEM.UNIX is a multi-user, multi-tasking operating SYSTEM. Multiple users may have multiple tasks running simultaneously. This is very different than PC operating SYSTEMs.

    

  UNIX is a machine independent operating SYSTEM. Not specific to just one type of COMPUTER HARDWARE. Designed from the beginning to be independent of the COMPUTER HARDWARE. UNIX is a SOFTWARE development environment. Was born in and designed to function within this type of environment.

    

  The "UNIX" trademark, previously owned by AT&T and then deeded to UNIX SYSTEMs Laboratories (USL), an AT&T subsidiary, passed to Novell when it acquired USL. After a brief period of negotiations with rival Unix vendors Sun MicroSYSTEMs, Santa Cruz Operation, International Business Machines, and HEWLETT-PACKARD, Novell granted exclusive licensing rights to the UNIX trademark to X/Open Co. Ltd., an Open SYSTEMs industry STANDARDs branding agent based in the United Kingdom.

History of Unix  
  UNIX has been a popular OS for more than two decades because of its multi-user, multi-tasking environment, stability, portability and powerful networking capabilities. What follows here is a simplified history of how UNIX has developed.

    

  Date
DESCRIPTION

1969
Developed at AT&T Bell Labs in Murray Hill, New Jersey, one of the largest research facilities in the world. Created in an environment when most COMPUTER jobs were fed into a batch SYSTEM.

1975
AT&T makes UNIX widely available - offered to educational institutions at minimal cost. Becomes popular with UNIVERSITY COMPUTER science programs. AT&T distributes STANDARD versions in source form, Version 6 (1975), Version 7 (1978), SYSTEM III (1981).

1984 to date
UNIVERSITY of California, Berkeley adds major enhancements, creates Berkeley STANDARD Distribution (BSD)

1984 to date
Many Berkeley features incorporated into new AT&T version, SYSTEM V


  UNIX has become the operating SYSTEM of choice for ENGINEERING and scientific workstations.

    

  Two variations maintain popularity today, Solaris and Linux. Linux seems to be the future.

Unix Components  
  Unix OS consists of three main components

    

  Kernel
Shell
Utilities

  Each of this, I will be covering in DEEP.

    

   Kernel  
  Kernel is the core of the UNIX SYSTEM is Loaded at SYSTEM start up (boot) and is Memory-resident CONTROL program. Kernel manages the entire resources of the SYSTEM, presenting them to you and every other user as a coherent SYSTEM. Provides service to user applications such as DEVICE management, PROCESS scheduling, etc.

    

  Example functions performed by the kernel are:

  managing the machine's MEMORY and allocating it to each PROCESS.
scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible.
accomplishing the transfer of data from one PART of the machine to another
interpreting and executing instructions from the shell
enforcing file access permissions

  You do not need to know anything about the kernel in order to use a UNIX SYSTEM. These details are provided for your information ONLY.

    

   Shell  
  Whenever you login to a Unix SYSTEM you are placed in a shell program. The shell's prompt is usually visible at the cursor's position on your screen. To get your work done, you enter commands at this prompt. The shell is a command interpreter; it takes each command and passes it to the operating SYSTEM kernel to be acted upon. It then displays the results of this operation on your screen. Several shells are usually available on any UNIX SYSTEM, each with its own strengths and weaknesses.

    

  Different users may use different shells. Initially, your SYSTEM adminstrator will supply a default shell, which can be overridden or changed. The most commONLY available shells are:

    

  Bourne shell (sh)
C shell (csh)
Korn shell (ksh)
TC Shell (tcsh)
Bourne Again Shell (bash)

  Each shell also includes its own PROGRAMMING language. Command files, called "shell scripts" are used to accomplish a series of tasks.

    

   Utilities  
  UNIX provides several hundred utility programs, often referred to as commands.

    

  Accomplish universal functions

  editing
file maintenance
printing
sorting
PROGRAMMING SUPPORT
online info

  Modular: SINGLE functions can be grouped to perform more complex tasks



4楼: >>参与讨论
rickyice
Part-II
Getting Started  
  Before you can begin to use the SYSTEM you will need to have a valid userNAME and a password. Assignment of userNAMEs and initial passwords is typically handled by the SYSTEM Administrator. Your userNAME, also called a userid, should be unique and should not change. Initial passwords can be anything and should be changed after your first login.

    

   Logging into Unix  
  When you connect to a UNIX COMPUTER remotely (using telnet) or when you log in locally using a text-ONLY terminal, you will see the prompt:

    

  login:

    

  At this prompt, type in your useNAME and press the enter/return/ key. Remember that UNIX is case sensitive (i.e. ASIC and asic are all different logins). You should then be prompted for your password:

    

  login: deepak

  password:

    

  Type your password in at the prompt and press the enter/return/ key. Note that your password will not be DISPLAYed on the screen as you type it in.

    

  If you mistype your userNAME or password you will get an appropriate message from the COMPUTER and you will be presented with the login: prompt again. Otherwise you should be presented with a shell prompt which looks something like this:

    

  $

    

  To log out of a text-based UNIX shell, type "exit" at the shell prompt (or if that doesn't work try "logout"; if that doesn't work press ctrl-d).

    

  This days all the Unix SYSTEMs are GUI based and are very easy to start with them.

    

   Changing password  
  Your password is important, it stops other users from gaining access to your account. Never give your password to anyone. You should change your initial password very soon after your first login. To change your password: enter the command passwd and then respond to the prompts by entering your old password followed by your new one. You are then asked to retype your password for confirmation.

    

  Note that what you type will not appear on the screen for security reasons. For example:

    

   %passwd  
Old password: - enter your current password
New password: - enter your new password
Retype new password: - re-enter your new password


    

  If you make a mistake, the message: Mismatch - password unchanged. is DISPLAYed and your password remains unchanged. Try again.

    

   General format of UNIX commands  
  A UNIX command LINE consists of the NAME of a UNIX command (actually the "command" is the NAME of a built-in shell command, a SYSTEM utility or an application program) followed by its "arguments" (options and the target fileNAMEs and/or expressions). The general syntax for a UNIX command is

    

  $ command -options targets

    

  Here command can be though of as a verb, options as an adverb and targets as the direct objects of the verb. In the case that the user wishes to specify several options, these need not always be listed separately (the options can sometimes be listed altogether after a SINGLE dash).

    

   
    

   Special Characters  
  The UNIX shell interprets a NUMBER of characters in special ways. These characters are most often used with UNIX commands - as arguments and for other means. The following list contains most of UNIX's special characters

    

  Character
DESCRIPTION

NEWLINE
initiates command execution

;
separates commands on same LINE

( )
groups commands or identifies a function

&
executes a command in the background

|
pipe

>
redirects STANDARD OUTPUT

>>
appends STANDARD OUTPUT

<
redirects STANDARD input

*
wildcard for any NUMBER of characters in a file NAME

?
wildcard for a SINGLE character in a file NAME

\
quotes the following character

'
quotes a string preventing all substitutions

"
quotes a string allowing variable and command substitution

`
performs command substitution

[ ]
denotes a character class in a file NAME

$
references a variable

{ }
command grouping within a function

.
executes a command (if at beginning of LINE)

#
begins a comment


    

   Example : *  
  Use the * character in file NAMEs to match any NUMBER of characters. The following command:

  ls *.txt

  Will match the following files:

  chapter1.txt doc.txt memo.txt a.txt

  Will not match the following files:

  doctxt txt.memo

    

   Example : ?  
  Use the ? character in file NAMEs to match any SINGLE character. The following command:

  ls ???.txt

  Will match the following files:

  one.txt doc.txt two.txt

  Will not match the following files:

  chap1.txt doctxt

    

   Terminal CONTROL Keys  
  Several key combinations on your KEYBOARD usually have a special effect on the terminal.

    

  These "CONTROL" (CTRL) keys are accomplished by holding the CTRL key while typing the second key. For example, CTRL-c means to hold the CTRL key while you type the letter "c".

    

  The most common CONTROL keys are listed below:

    

  Keys
DESCRIPTION

CTRL-u
erase everything you've typed on the command LINE

CTRL-c
stop/kill a command

CTRL-h
backspace (usually)

CTRL-z
suspend a command

CTRL-s
stop the screen from scrolling

CTRL-q
continue scrolling

CTRL-d
exit from an interactive program (signals end of data)


    

   Getting Information  
  The "man" command man gives you access to an on-LINE manual which potentially contains a complete DESCRIPTION of every command available on the SYSTEM. In practice, the manual usually contains a subset of all commands.man can also provide you with one LINE DESCRIPTIONs of commands which match a specified keyword

    

  man "command"

    

   Example : man  
  To DISPLAY the manual page for the cp (copy files) command:

    

  man cp

    

  --More--11% at the bottom left of the screen means that ONLY 11% of the man page is DISPLAYed. Pres
5楼: >>参与讨论
rickyice
Part-III
The UNIX fileSYSTEM  
  The UNIX fileSYSTEM is laid out as a hierarchical tree structure which is anchored at a special top-level directory known as the root (designated by a slash '/'). Because of the tree structure, a directory can have many child directories, but ONLY one parent directory. Fig. below illustrates this layout.

   
    

   UNIX directory structure  
    

  Directory
Typical Contents

/
The "root" directory

/bin
Essential low-level SYSTEM utilities

/usr/bin
Higher-level SYSTEM utilities and application programs

/sbin
Superuser SYSTEM utilities (for performing SYSTEM administration tasks)

/lib
Program libraries (collections of SYSTEM calls that can be included in programs by a compiler) for low-level SYSTEM utilities

/usr/lib
Program libraries for higher-level user programs

/tmp
Temporary file storage space (can be used by any user)

/home or /homes
User home directories containing personal file space for each user. Each directory is NAMEd after the login of the user.

/etc
UNIX SYSTEM configuration and information files

/dev
HARDWARE DEVICEs

/proc
A pseudo-fileSYSTEM which is used as an interface to the kernel. Includes a sub-directory for each active program (or PROCESS).


    

   Directory and file HANDLING commands  
  This section describes some of the more important directory and file HANDLING commands.

    

  pwd (print [current] working directory)

    

  pwd DISPLAYs the full absolute path to the your current location in the fileSYSTEM. So

    

  $ pwd

  /usr/bin

    

  implies that /usr/bin is the current working directory.

    

  ls (list directory)

    

  ls lists the contents of a directory. If no target directory is given, then the contents of the current working directory are DISPLAYed. So, if the current working directory is /,

    

  $ ls

  bin dev home mnt share usr var

  boot etc lib proc sbin tmp vol

    

  Actually, ls doesn't show you all the entries in a directory - files and directories that begin with a dot (.) are hidden (this includes the directories '.' and '..' which are always present). The reason for this is that files that begin with a . usually contain important configuration information and should not be changed under normal circumstances. If you want to see all files, ls supports the -a option:

    

  $ ls -a

    

  Even this listing is not that helpful - there are no hints to properties such as the size, type and ownership of files, just their NAMEs. To see more detailed information, use the -l option (LONG listing), which can be combined with the -a option as follows:

    

  $ ls -a -l

  (or, equivalently,)

  $ ls -al

    

    

  Each LINE of the OUTPUT looks like this:

    

   
  where:

    

  Field
DESCRIPTION

type
type is a SINGLE character which is either 'd' (directory), '-' (ordinary file), 'l' (symbolic LINK), 'b' (block-oriented DEVICE) or 'c' (character-oriented DEVICE).

permission
permissions is a set of characters describing access rights. There are 9 permission characters, describing 3 access types given to 3 user categories. The three access types are read ('r'), write ('w') and execute ('x'), and the three users categories are the user who owns the file, users in the GROUP that the file beLONGs to and other users (the general public). An 'r', 'w' or 'x' character means the corresponding permission is present; a '-' means it is absent.

LINKs
LINKs refers to the NUMBER of fileSYSTEM LINKs pointing to the file/directory (see the discussion on hard/soft LINKs in the next section).

owner
owner is usually the user who created the file or directory.

GROUP
GROUP denotes a collection of users who are allowed to access the file according to the GROUP access rights specified in the permissions field.

size
size is the length of a file, or the NUMBER of bytes used by the operating SYSTEM to store the list of files in a directory.

date
date is the date when the file or directory was last MODIFIED (written to). The -u option DISPLAY the time when the file was last accessed (read).

NAME
NAME is the NAME of the file or directory.


    

  ls supports more options. To find out what they are, type:

    

  $ man ls

    

  man is the onLINE UNIX user manual, and you can use it to get help with commands and find out about what options are supported. It has quite a terse style which is often not that helpful, so some users prefer to the use the (non-standard) info utility if it is installed:

    

  $ info ls

    

  cd (change [current working] directory)

    

  $ cd path

    

  changes your current working directory to path (which can be an absolute or a relative path). One of the most common relative paths to use is '..' (i.e. the parent directory of the current directory).

    

  Used without any target directory

    

  $ cd

    

  resets your current working directory to your home directory (useful if you get lost). If you change into a directory and you subsequently want to return to your original directory, use

    

  $ cd -

    

  mkdir (make directory)

    

  $ mkdir directory

    

  creates a subdirectory called directoryin the current working directory. You can ONLY create subdirectories in a directory if you have write permission on that directory.

    

  rmdir (remove directory)

    

  $ rmdir directory

    

  removes the subdirectory directory from the current working directory. You can ONLY remove subdirectories if they are completely empty (i.e. of all entries besides the '.' and '..' directories).

    

  cp (copy)

    

  cp is used to make copies of files or entire directories. To copy files, use:

    

  $ cp source-file(s) destination

    

  where source-file(s) and destination specify the source and destination of the copy respectively. The behaviour of cp depends on whether the destinatio
6楼: >>参与讨论
rickyice
待续。。。
待续。。。待续。。。

7楼: >>参与讨论
windover
建议直接perl 和tcl
shell script 没有必要。

8楼: >>参与讨论
rickyice
re
ok

9楼: >>参与讨论
rickyice
Perl Part-I
 Introduction  
  Perl is a "Practical Extraction and Report Language" freely available for Unix, MVS, VMS, MS/DOS, Macintosh, OS/2, Amiga, and other operating systems. Perl has powerful text-manipulation functions. It eclectically combines features and purposes of many command languages. Perl has enjoyed recent popularity for PROGRAMMING World Wide Web electronic forms and generally as glue and gateway between systems, databases, and users.

    

   
    

   Perl vs Sed/Awk  
    

   Writing and Running Perl Programs  


10楼: >>参与讨论
rickyice
Part-II
Perl basics  
  This section is about simple things in perl.

    

   Comments  
  Perl has ONLY one type of comments - one LINE comments. Everything what starts with # and up to the end of the LINE is considered as comment.

    

  print "Hello!"; # print out one word

    

   Variables  
  To use variables in Perl all you need to do is to initialize them. The NAMEs of scalar variables are to start with $ sign:

    

  $counter = 0;

  $amount = 15.20;

  $NAME = "Daniel";

  print "amount = $amount\n";

    

  As you can see from the example above we don't describe variables we just use them. You can also notice that we do not need to specify a type of a variable. Perl automatically chooses the right type based on the VALUE assigned to a variable. Thus, one variable can store different types of data:

    

  $a = 100;

  print "\$a = $a is a NUMBER\n";

  $a = 'is a text now';

  print "\$a $a\n";

    

  Scalar variables in Perl may hold the following types of VALUEs:

  Integers (decimal, octal, or hexadecimal)
Floating point NUMBERs
Strings

  Please notice that Perl does not give any error message if we are trying to use an unitialized variable. For example, the following code

    

  print "\$a = $a\n";

    

  will print

  $a =

  If you want to get such messages we would suggest to use option -w for the perl interpreter and PACKAGE strict in the scripts. The following code

    

  # file: warning.pl

  use strict;

  print "\$a = $a\n";

    

  if executed by

  ...> perl -w warning.pl

  will produce the OUTPUT:

    

  NAME "main::a" used ONLY once: possible typo at comments.pl LINE 3.

  Use of uninitialized VALUE in concatenation (.) or string at comments.pl LINE 3.

  $a =

    

  To correct this error we need to declare the variable $a by using the my function:

    

  # file: nowarning.pl

  use strict;

  my $a = 12;

  print "\$a = $a\n";

Strings  
  String literals can be created with either SINGLE quotes or double quotes. To illustrate difference between them let's consider the following code:

    

  use strict;

  my $NAME = "Bob";

  print "Hello, $NAME\n";

  print 'Hello, $NAME\n';

    

  This code generates the OUTPUT:

    

  Hello, Bob

  Hello, $NAME\n

    

  As you can see double quotes strings substitute variable NAMEs with their VALUEs and also treat backslashes as an escape character, which allows to print special characters like new LINE character (\n) or a dollar sign (\$). SINGLE quoted strings don't do that.

    

   Array variables  
  Arrays in Perl are ordered collection of scalars. Perl allows these scalars to have different types. Array NAMEs begin with the @ character:

    

  # an array of data

  my @collection = ("My NAME", 123, 'string', 3.97);

    

  Perl also allows us to print all elements of the array at once. The following example shows how to do that, please also pay attention to the difference between double and SINGLE quotes and also array printed outside of any quotes:

    

  use strict;

  my @collection = ("My NAME", 123, 'string', 3.97);

  print "Within double quotes: @collection\n";

  print "Outside any quotes: ", @collection, "\n";

  print 'Within SINGLE quotes: @collection', "\n";

    

  Within double quotes: My NAME 123 string 3.97

  Outside any quotes: My NAME123string3.97

  Within SINGLE quotes: @collection

    

  As in C++, Perl arrays start at element 0. For @collection, the elements are:

    

  0: "My NAME"
1: 123
2: 'string'
3: 3.97

    

   NAME Conventions  
    

   Literals and Operators  
    

   Example  


11楼: >>参与讨论
rickyice
Part-III
Loops and I/O  
    

   Example : STANDARD I/O
Pipe I/O and SYSTEM Calls  
    

   Matching  
    

   Parsing  


12楼: >>参与讨论
rickyice
re
....................

13楼: >>参与讨论
rickyice
TCL
Part-I  
    

   TCL Basics  
    

   
    

   Scripts, commands, and words  
    

   Evaluating a command  
    

   Variable,command and backslash substitutions  
    

   Quoting and comments  
Part-II
Variables  
    

   Expressions  
    

   Operators  
    

   Substitutions  
    

   String Manipulation  
Types and conversions  
    

   Lists  
    

   CONTROL Flow  
    

   Procedures  
    

   Arguments  
    

   Call by reference  
    

   Creating new CONTROL structures  
Part-III
String Manipulation  
    

   Glob-style pattern matching  
    

   Pattern matching with regular expressions  
    

   Using regular expressions for substitutions  
Formatted OUTPUT  
    

   Parsing strings with scan  
    

   Character functions  
    

   Seaching and comparison  
    

   Length, case conversion, and trimming  


14楼: >>参与讨论
rickyice
Shell PROGRAMMING
Introduction  
    
Part-I

   Simple Commands  
    

   Input out redirection  
    

   
    

   Pipelines and filters  
    

   File NAME generation  
    

   Quoting  
    

   Promting  
Part-II


   Shell Procedures  
    

   CONTROL Flow-for  
    

   CONTROL Flow-case  
    

   CONTROL Flow-while  
    

   CONTROL Flow-if  
    

   
    

   TEST command  
    

   Shell Variables  
    

   Command grouping  
    

   Debugging shell procedures  
    

   The man command  
    

   Command substitution  
    

   Error HANDLING  


15楼: >>参与讨论
zhaosl_996
请高手指点一二.
在下现在用到 SEMEFAB 的 051-8728
在网上查了半天也找不到它的datasheet
有劳那位有他的PDF文件的,请发一份个小弟.感谢!!
zhaosl_996@126.com

16楼: >>参与讨论
nhtabs
改改英语错误吧
第一段:

In ASIC world real work is done in Unix OS, (earlier it was Sun and HP unix, now it is Linux.). In Unix we have lot of powerfull tools to make life easier. This basically helps in automating routine jobs. Like Makefile helps in automating the compile PROCESS, one need to type the command LINE options eveytime one wants compile. Take another example, CVS helps to KEEP track of changes in files, helps in tagging files for release. Theseare ONLY few examples, but the list is LONG.

    

  In the next few pages, I will make an effort to share my or the experience in how to use scritping, Makefiles, CVS in ASIC world. After reading these SHORT tutorials, one should be in a position to use them in real projects.

    

  As usual, you may find mistakes in what I have written, or you have better way to put this tutorial, or you think I need to know about something. Please add it.


17楼: >>参与讨论
rickyice
re
thanks

18楼: >>参与讨论
icfree
vvvvvvvv
haohao

19楼: >>参与讨论
bcf9088
回复


20楼: >>参与讨论
wendalian
#*&^%$#*&^%$#@
#@

21楼: >>参与讨论
shirui
内容
内容呢?

22楼: >>参与讨论
magicchip
接着努力好呀
 
23楼: >>参与讨论
magicchip
好好努力
 
24楼: >>参与讨论
zhyh212
芯片74LS87的外观和功能


  有那位知道有关74LS87的有关资料。如果你你知道请你告诉我好吗,在这里
我对你说一声谢谢。

参与讨论
昵称:
讨论内容:
 
 
相关帖子
推荐一个不错的网站,好多资料。
给大家推荐一个好的网址,国内资料最份丰富的电子论坛
求charge-pump PLL的模型化电路
请帮我分析一下这个电路,谢谢!
哪位大侠能提供一下IDDQ的测试方法
免费注册为维库电子开发网会员,参与电子工程师社区讨论,点此进入


Copyright © 1998-2006 www.dzsc.com 浙ICP证030469号