关于状态机写法的一点看法 FSM Finite State Machine
Labels: AsicDesign
Digital IC design,Verification,FPGA,STB,Video Codec...
Labels: AsicDesign
1/ Capacitors and resistors have parasitic inductance, about 0.4nH for surface mount and 4nH for a leaded component.
2/ If you don"t want a high bandwidth transistor to oscillate place lossy components in at least 2 of the 3 leads. Ferrite beads work well.
3/ When taking DC measurements in a circuit and they don"t make sense, suspect that something is oscillating.
4/ Opamps will often oscillate when driving capacitive loads.
5/ The base-emitter voltage Vbe of a small signal transistor is about 0.65v and drops about 2mV/deg C. Vbe goes down with increasing temp.
6/ Multiply 0.13nV by the square root of the ohmic value of a resistor to find the noise in a 1Hz bandwidth. Then multiply by the square root of the BW in Hz gives the total noise voltage.
7/ Johnson noise current goes down with a increase in resistance.
8/ The impedance looking into the emitter of a transistor at room temp is 26Ohm/Ie in mA
9/ All amplifiers are differential in that they are referenced to ground somewhere.
10/ Typical metal film resistor has a temp coef of about 100 ppm/deg C
11/ The input noise voltage of a quiet op amp is 1nv/sqrt(Hz) but there are plenty available with 20nV/sqrt(Hz). Op amps with bipolar front-ends have lower voltage noise and higher current noise than those with FET front-ends
12/ Using an LC circuit as a power supply filter can actually multiply the power supply noise at the filter"s resonant frequency. Use inductor with low Q to overcome this.
13/ Use comparators for comparing and op amps for amplifying and don"t even think of mixing the two.
14/ Ceramic caps with any other dielectric other than NPO should only be used for bypass applications.
15/ An N-channel enhancement-mode FET needs +ve voltage on the gate-source to conduct form drain-source.
16/ Small signal JFETS work very well as low-leakage diodes by connecting drain & source together in log current-to-voltage converters and low leakage input protection. Small signal bipolars with b-c tied together will also make nice low-leakage diodes.
17/ With low pass filter use Bessel for least amount of overshoot in the time domain, and Cauer (or elliptic) for fastest rolloff in the freq domain.
18/ dB is always 10 times the log of the ratio of 2 powers.
19/ At low frequencies, the current in the collector of a transistor is in phase with the applied current at the base. At high frequencies the current at the collector lags by 90deg. You must appreciate this simple fact to understand high frequency oscillators.
20/ The most common glass-epoxy PCB material (FR4) has a dielectric constant of about 4.3 To make a trace with a characteristic impedance of 100 Ohm, use a trace thickness of about 0.4 times the thickness of the board with a ground plane on the opposite side. For a 50Ohm trace make it 2 times the thickness.
21/ If you need a programmable dynamic current source, find out about operational transconductance amps. Most of the problem is figuring out when you need a programmable dynamic current source.
22/ A CMOS output with an emitter follower can drive a 5V relay nicely as the relays normally have a must-make spec of 3.5V. This saves power and require no flyback components.
23/ Typical thermocouple potential is 30uV/degC. Route signals differentially, along the same path, avoid temp gradients. DPDT latching relays won"t heat up when multiplexing these signals.
24/ You SHOULD be bothered by a design that looks messy, cluttered or indirect. This uncomfortable feeling is one of the few indications that there"s a better way.
25/ Avoid drawing any current from the wiper of a potentiometer. The resistance of the wiper contact will cause problems (local heating, noise offsets etc.)
26/ Most digital phase detectors have a deadband where the analog output does not change over the small range where the 2 inputs are coincident. This often-ignored fact has helped to create some very noisy PLL"s (Use a high val bleeding resistor to always ensure current flow in the deadband)
27/ The phase noise of a phase-locked VCO will be at least 6dB worse than the phase noise of the divided reference for each octave between the comparison frequency and the VCO output frequency. Avoid low-comparison frequencies.
28/ You can almost always determine the leads of a bipolar transistor with an ohm meter. b-e and b-c junctions will measure like a diode with the b-c junction reading slightly lower than the b-e junction when forward biased.
29/ For low distortion, the drains (or collectors) of a differential amp"s front-end should be bootstrapped to the source (or emitter) so that the voltages on the part are not modulated by the input signal.
30/ If your design uses a $3 op amp, and you will be making a thousand of them, you have just spend $3000. Are you smart enough to figure out how to use a $.30 op amp instead?
31/ The Q of an LC tank circuit is dominated by the losses in the inductor in terms of series R. Q=omega.L/R
32/ Leakage current doubles for every 10degC increase in temp.
33/ When inputs to most JFET op amps exceed the common-mode range for the part, the output may reverse polarity. This artifact will haunt the designers of these parts for the rest of their lives, as it should!
34/ Understand the difference between "make-before-break" and "break-before-make" when you specify switches.
35/ 3 Terminal voltage regulators in the TO-220 packages are wonderful parts. They are cheap, rugged, thermally protected and very versatile. Use them virtually any place where you need a protected power transistor. They also make nice AM power-modulators.
36/ Use step recovery diode where you need fast edges under 100pS (hot-carrier is even faster)
37/ The old 723 regulator is still one of the lowest noise regulators around! (2.5uVrms 100Hz-10k)
38/ You can make a very simple oscillator with one diac, cap and a resistor.
39/ NPN transistors are normally superior to their PNP counterpart in performance.
40/ Typical spec in some databooks should read "Seen it once". Always work with the worst spec of the part when doing a design.
41/ Don"t just copy circuits from application notes without understanding completely how it operates, and the reason for the choice of values.
42/ Dealing with crystals, make sure you understand the difference between series and parallel resonant. In a circuit, crystal frequency can generally be slightly lowered by placing a inductor in series and increased by a capacitor in series.
43/ Power MOSFETS on-resistance will have a -ve temp coef and not +ve at low current levels. This is important to remember when paralleling devices.
44/ Lowest noise figure of a RF transistor is not normally where the input is perfectly matched.
45/ Many un-stable RF devices can be made stable by loading the input or the output by a simple resistor, either in series or parallel.
46/ You trade gain for bandwidth.
47/ Push-pull power invertors using bipolars are risky and can saturate the core because of hysteresis stepping (use power fets)
48/ The Al value of a core will increase up to 50% or more under current transients.
49/ Be aware of leakage inductance when switching. V=L(dI/dt)
50/ The harder you turn-on a power transistor, the longer it will take to turn off.( the part where you burn the joules in the device)
51/ Always remember the Miller guy.
52/ In fault-finding a circuit, don"t overlook the obvious. (is there power?)
53/ What is a ground loop, and how to avoid it.
54/ 120 is a better number than 240 when using LM3XX type adjustable regulators.
55/ The lower comparator in the old 555 may have quite a long storage time.
56/ ZERO-ESR caps may do more harm than good.
57/ A correctly configured audio power amplifier will give more distortion in Class-AB, not less, because of the abrupt gain changes inherent in switching from A to B every cycle.
58/ Be a STAR when it comes to ground matters.
59/ Know when you need to use a Zobel network.
60/ Use current mirrors and mirror your current.
61/ Heatsink eff decreases with height above sealevel.
62/ A matt-black heatsink is much better than a shiny one.
63/ Ignoring secondary breakdown can be costly.
64/ Understand fuses and fuse ratings, fast and slow. Do you know when to use a semiconductor-fuse?
65/ Charge balancing resistors are a must when stacking serie-parallel high voltage capacitor banks.
66/ You must understand DC-restoration otherwise you will have a hard time designing Z-modulation in CRT circuits.
67/ Display 6 vert div low freq on a scope, increase the freq (make sure the source is constant amplitude) until display drops to 4.2 div. That is the true 3dB BW of the scope. (scope-source impedance should be matched)
68/ Doing a measurement with your DMM in the ACV position on your DC circuit will give a quick indication of any excess ripple on the supply when you don"t have a scope at hand.
69/ Dly timebase on a scope is very useful once you figured out when, why and how to use it.
70/ Know what to expect before you measure, otherwise any measurement is meaningless.
71/ Op amps. Output will swing in the direction that will force the inv-input level to try come closer to the non-inv input level.
72/ Understand virtual ground, slew-rate, CMRR and PSRR. (CMRR decrease with increase in freq)
73/ Making measurements near a spec-analalyzer"s noise floor will give 3dB errors.
74/ Understand the phase-noise limitations of the analyzer when making such measurements on oscillators.
75/ In a LC oscillator add some C with -ve temp coef to cancel the +ve temp coef of the L for min drift with temp.
76/ Less drift will result from making C with a few parallel caps, to reduce the heating effect of the oscillating current when spread out over a larger plate area.
77/ You will get more tuning range with the same LC combination in a Clapp than in a Colpitts circuit.
78/ High-Q tuned LC filters will have more insertion loss.
79/ Williams"s Rule (Guru at Linear Tech) for precision op amp circuits: " Always invert (except when you can"t)"
80/ Cuk is not a kind of locomotive.
81/ If you don"t know how to make a design better, find out what makes it worse.
82/ Sometimes you know just enough to be dangerous.
83/ Impedance will reflect back as the square of the turns ratio.
84/ If you could design a component with the characteristics of a finger it could cure many design problems and you will be rich.
85/ Get nervous when the customer you are trying to help doesn"t even have a scope.
86/ Specs quoted by reps always exceed those by Engineering.
87/ A bad (Engineer) workman always blames his tools.
88/ Don"t believe everything that a SPICE program spits out.
89/ It is easy to get the color code of a 1kOhm and 12Ohm resistor mixed up when you are in a hurry.
90/ I bet one could write a thesis about the ability of probes to get tangled-up on a bench.
91/ DMM can upset sensitive circuits from noise generated inside it.
92/ When probing directly on a crystal of a uP, use 10kOhm or so resistor in series with the probe tip to prevent loading from stopping the osc.
93/ It is easier to see what is happening on the ports using a scope when you trigger one chan against the cpu clock.
94/ National once made a bad op amp many years ago that some Engineers referred to it as "Jelly Beans"
95/ The moment you can start to notice distortion on an oscilloscope it is already way past being acceptable.
96/ Be big enough to say "I don"t know", people will respect you more.
97/ The best designer is often working in the marketing department.
98/ Some remarkable discoveries/inventions were made by people that knew very little about the subject. Don"t fall into a groove in you thinking process.
99/ The Peter-Principle : Everybody will be promoted up to his own level of incompetence. http://pespmc1.vub.ac.be/PETERPR.html
100/ END-Enjoy
Labels: Analog, AsicDesign
test 文件运算符
Labels: AsicDesign, Script
Table of Contents
1. Sed简介
sed是一种在线编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为"模式空间"(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有改变,除非你使用重定向存储输出。Sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。以下介绍的是Gnu版本的Sed 3.02。
2. 定址
可以通过定址来定位你所希望编辑的行,该地址用数字构成,用逗号分隔的两个行数表示以这两行为起止的行的范围(包括行数表示的那两行)。如1,3表示1,2,3行,美元符号($)表示最后一行。范围可以通过数据,正则表达式或者二者结合的方式确定 。
3. Sed命令
调用sed命令有两种形式:
sed [options] 'command' file(s)
sed [options] -f scriptfile file(s)
<
a\
在当前行后面加入一行文本。
b lable
分支到脚本中带有标记的地方,如果分支不存在则分支到脚本的末尾。
c\
用新的文本改变本行的文本。
d
从模板块(Pattern space)位置删除行。
D
删除模板块的第一行。
i\
在当前行上面插入文本。
h
拷贝模板块的内容到内存中的缓冲区。
H
追加模板块的内容到内存中的缓冲区
g
获得内存缓冲区的内容,并替代当前模板块中的文本。
G
获得内存缓冲区的内容,并追加到当前模板块文本的后面。
l
列表不能打印字符的清单。
n
读取下一个输入行,用下一个命令处理新的行而不是用第一个命令。
N
追加下一个输入行到模板块后面并在二者间嵌入一个新行,改变当前行号码。
p
打印模板块的行。
P(大写)
打印模板块的第一行。
q
退出Sed。
r file
从file中读行。
t label
if分支,从最后一行开始,条件一旦满足或者T,t命令,将导致分支到带有标号的命令处,或者到脚本的末尾。
T label
错误分支,从最后一行开始,一旦发生错误或者T,t命令,将导致分支到带有标号的命令处,或者到脚本的末尾。
w file
写并追加模板块到file末尾。
W file
写并追加模板块的第一行到file末尾。
!
表示后面的命令对所有没有被选定的行发生作用。
s/re/string
用string替换正则表达式re。
=
打印当前行号码。
#
把注释扩展到下一个换行符以前。
以下的是替换标记
g表示行内全面替换。
p表示打印行。
w表示把行写入一个文件。
x表示互换模板块中的文本和缓冲区中的文本。
y表示把一个字符翻译为另外的字符(但是不用于正则表达式)
4. 选项
<
-e command, --expression=command
允许多台编辑。
-h, --help
打印帮助,并显示bug列表的地址。
-n, --quiet, --silent
取消默认输出。
-f, --filer=script-file
引导sed脚本文件名。
-V, --version
打印版本和版权信息。
5. 元字符集
<
^
锚定行的开始 如:/^sed/匹配所有以sed开头的行。
$
锚定行的结束 如:/sed$/匹配所有以sed结尾的行。
.
匹配一个非换行符的字符 如:/s.d/匹配s后接一个任意字符,然后是d。
*
匹配零或多个字符 如:/*sed/匹配所有模板是一个或多个空格后紧跟sed的行。
[]
匹配一个指定范围内的字符,如/[Ss]ed/匹配sed和Sed。
[^]
匹配一个不在指定范围内的字符,如:/[^A-RT-Z]ed/匹配不包含A-R和T-Z的一个字母开头,紧跟ed的行。
\(..\)
保存匹配的字符,如s/\(love\)able/\1rs,loveable被替换成lovers。
&
保存搜索字符用来替换其他字符,如s/love/**&**/,love这成**love**。
\<
锚定单词的开始,如:/\
\>
锚定单词的结束,如/love\>/匹配包含以love结尾的单词的行。
x\{m\}
重复字符x,m次,如:/0\{5\}/匹配包含5个o的行。
x\{m,\}
重复字符x,至少m次,如:/o\{5,\}/匹配至少有5个o的行。
x\{m,n\}
重复字符x,至少m次,不多于n次,如:/o\{5,10\}/匹配5--10个o的行。
6. 实例
删除:d命令
$ sed '2d' example-----删除example文件的第二行。
$ sed '2,$d' example-----删除example文件的第二行到末尾所有行。
$ sed '$d' example-----删除example文件的最后一行。
$ sed '/test/'d example-----删除example文件所有包含test的行。
替换:s命令
$ sed 's/test/mytest/g' example-----在整行范围内把test替换为mytest。如果没有g标记,则只有每行第一个匹配的test被替换成mytest。
$ sed -n 's/^test/mytest/p' example-----(-n)选项和p标志一起使用表示只打印那些发生替换的行。也就是说,如果某一行开头的test被替换成mytest,就打印它。
$ sed 's/^192.168.0.1/&localhost/' example-----&符号表示替换换字符串中被找到的部份。所有以192.168.0.1开头的行都会被替换成它自已加 localhost,变成192.168.0.1localhost。
$ sed -n 's/\(love\)able/\1rs/p' example-----love被标记为1,所有loveable会被替换成lovers,而且替换的行会被打印出来。
$ sed 's#10#100#g' example-----不论什么字符,紧跟着s命令的都被认为是新的分隔符,所以,"#"在这里是分隔符,代替了默认的"/"分隔符。表示把所有10替换成100。
选定行的范围:逗号
$ sed -n '/test/,/check/p' example-----所有在模板test和check所确定的范围内的行都被打印。
$ sed -n '5,/^test/p' example-----打印从第五行开始到第一个包含以test开始的行之间的所有行。
$ sed '/test/,/check/s/$/sed test/' example-----对于模板test和west之间的行,每行的末尾用字符串sed test替换。
多点编辑:e命令
$ sed -e '1,5d' -e 's/test/check/' example-----(-e)选项允许在同一行里执行多条命令。如例子所示,第一条命令删除1至5行,第二条命令用check替换test。命令的执行顺序对结果有影响。如果两个命令都是替换命令,那么第一个替换命令将影响第二个替换命令的结果。
$ sed --expression='s/test/check/' --expression='/love/d' example-----一个比-e更好的命令是--expression。它能给sed表达式赋值。
从文件读入:r命令
$ sed '/test/r file' example-----file里的内容被读进来,显示在与test匹配的行后面,如果匹配多行,则file的内容将显示在所有匹配行的下面。
写入文件:w命令
$ sed -n '/test/w file' example-----在example中所有包含test的行都被写入file里。
追加命令:a命令
$ sed '/^test/a\\--->this is a example' example<-----'this is a example'被追加到以test开头的行后面,sed要求命令a后面有一个反斜杠。
插入:i命令
$ sed '/test/i\\
new line
-------------------------' example
如果test被匹配,则把反斜杠后面的文本插入到匹配行的前面。
下一个:n命令
$ sed '/test/{ n; s/aa/bb/; }' example-----如果test被匹配,则移动到匹配行的下一行,替换这一行的aa,变为bb,并打印该行,然后继续。
变形:y命令
$ sed '1,10y/abcde/ABCDE/' example-----把1--10行内所有abcde转变为大写,注意,正则表达式元字符不能使用这个命令。
退出:q命令
$ sed '10q' example-----打印完第10行后,退出sed。
保持和获取:h命令和G命令
$ sed -e '/test/h' -e '$G example-----在sed处理文件的时候,每一行都被保存在一个叫模式空间的临时缓冲区中,除非行被删除或者输出被取消,否则所有被处理的行都将打印在屏幕上。接着模式空间被清空,并存入新的一行等待处理。在这个例子里,匹配test的行被找到后,将存入模式空间,h命令将其复制并存入一个称为保持缓存区的特殊缓冲区内。第二条语句的意思是,当到达最后一行后,G命令取出保持缓冲区的行,然后把它放回模式空间中,且追加到现在已经存在于模式空间中的行的末尾。在这个例子中就是追加到最后一行。简单来说,任何包含test的行都被复制并追加到该文件的末尾。
保持和互换:h命令和x命令
$ sed -e '/test/h' -e '/check/x' example -----互换模式空间和保持缓冲区的内容。也就是把包含test与check的行互换。
7. 脚本
Sed脚本是一个sed的命令清单,启动Sed时以-f选项引导脚本文件名。Sed对于脚本中输入的命令非常挑剔,在命令的末尾不能有任何空白或文本,如果在一行中有多个命令,要用分号分隔。以#开头的行为注释行,且不能跨行。
比如,如果要打印出含有字串"1024"的行,我就可能会用:
cat filename | sed �Cn '/1024/p'
Labels: Script