2010年5月23日 星期日

如何增進工程師效率 - command line option

Scripting language 大多有內建的 command line option 的支援。相對之下,C 的內建只有 argc 和 argv。善用 command line option 可以讓 script language (1) 根據不同的 option 改變程式的行為而不用重改程式;(2) 可以傳參數進程式而不是在程式中設死。

Ex1: convert_netlist.rb -s => 產生 spice netlist;  convert_netlist -l => 產生 lvs netlist

Ex2: cap_filter -c 1.5 -o output.cdl => 移除 cap 值小於 1.5fF, 並存於 output.cdl

 

本文比較 ruby 和 python 的 command line option 的用法及比較不同

 

Ruby

Ruby 有好幾個不同的 command line option parser.  我們主要 focus 在內建的 optparse, 這是在標準的 library 內,不需要再用 gem.

#!/usr/bin/env ruby
require 'optparse'

# This hash will hold all of the options
# parsed from the command-line by
# OptionParser.
options = {}

optparse = OptionParser.new do |opts|
  # Set a banner, displayed at the top
  # of the help screen.
  opts.banner = "Usage: #{$0} [options] <in.cdl> <out.cdl>"
  # Define the options, and what they do
  options[:force] = false
  opts.on( '-f', '--force', 'Force to overwrite output file' ) do
    options[:force] = true
  end
  options[:capval] = 0.0
  opts.on( '-c', '--cap value', Float, 'CPP -> MOMCAPS' ) do|f|
    options[:capval] = f
  end
  options[:bracket] = false
  opts.on( '-b', '--bracket', 'Bracket <> -> []' ) do
    options[:bracket] = true
  end
  options[:dummy] = false
  opts.on( '-d', '--dummy', 'Dummy cap and resistor removal' ) do
    options[:dummy] = true
  end
  options[:logfile] = nil
  opts.on( '-l', '--logfile FILE', 'Write log to FILE' ) do|file|
    options[:logfile] = file
  end
  # This displays the help screen, all programs are
  # assumed to have this option.
  opts.on( '-h', '--help', 'Display this screen' ) do
    puts opts
    exit
  end
end

# Parse the command-line. The 'parse' method simply parses
# ARGV, while the 'parse!' method parses ARGV and removes
# any options found there, as well as any parameters for
# the options. What's left is the list of files to resize.

begin optparse.parse!(ARGV)

 

rescue OptionParser::InvalidOption => e

puts e

puts optparse

exit

end

puts "Force to overwrite output file" if options[:force]
puts "CPP -> MOMCAPS #{options[:capval]}" if options[:capval]
puts "Bracket <> -> []" if options[:bracket]
puts "Dummy cap & resistor removal" if options[:dummy]
puts "Logging to file #{options[:logfile]}" if options[:logfile]

 

說明如下:

* require 'optparse'   使用內建的 option parser

* 需要用到兩個 class: options (Hash class) 和 optparse (OptonParser class)

optparse 負責 command line 訊息的顯示和處理。以及 handle 例外的情況。

options = {"force"=>true, "calval"=>1.5, "bracket"=>false,"dummy"=>true,"logfile"=>"kkk"}

這是我們熟悉的 Hash class, 儲存 option parser 處理過後的結果。

* ARGV 則是儲存移除 option 後留下的 command line 參數。

 

Python 

from optparse import OptionParser

parser = OptionParser()

parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")

parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help="don't print status messages to stdout")

parser.add_option("-s", "--sample", dest="sample", default=900,
type="int", help="measurement samples, 3x")

parser.add_option("-t", "--turn", dest="turn", default=5,
type="int", help="high Q transition turn sample")

parser.add_option("-r", "--rho", dest="rho", default=0.99,
type="float", help="Adaptive rate rho between 0.95 to 1.0")

(options, args) = parser.parse_args()

print options.filename
print options.turn
print options.sample
print options.rho
print options.q_dot

print options
print args

說明如下:

* from optparse import OptionParse

 

* 主要的處理是在 parser (OptionParser class) 完成。如 Ruby 同樣包含 command line 訊息的顯示和處理。以及 handle 例外的情況。

 

* 最後的結果有二個。 options 是處理過後的結果。options.filenames 和 options.verbose (定義在 dest 後).

 

* args 則是儲存移除 option 後留下的 command line 參數。



2009年12月21日 星期一

KPI 用於 Analog Circuit Design

Analog circuit desing is not an art (or only partly is an art).

Majority day-to-day life is normal.  How come it is so difficult????

Because there is a big gap between device level and final result!!!

這是一個認知的間題

 

3 layers of knowledge in analog circuit

 

1. Device level

gm, rout, Cc

ft = gm/Cc;   gain = gm * rout

 

 

 

3. Result and 現象

Oscillator: oscillate or not and lock time, frequency detune

PLL: lock or not and lock time, spur, phase noise

ADC: ENOB, SNDR

 

Problem ==>

1. Need lot of simulation time: garbage in; garbage out!!

2. No physical insight!!!!

Because a big gap between device parameter and result/現象

 

Solution ==> Bridge the gap using KPI

What is KPI?

between device parameters and final results

only a few (2-4 parameters)

A clear coorelation between KPI and final results (best if there is a math formula)

2009年12月18日 星期五

CentOS 常用軟體

Use VMware to install CentOS 4.8 on windows 7

 

Step 1: Install vmware-toolbox on linux, not sure what this toolbox is useful??

network --> bridged mode, very slow?  How about hostonly and NAT?  What's the tradeoff?

Now using bridged mode and works OK.

Step 1.1: Make sure sshd service is on.  And install putty in PC so that can remote control.

 

Step 1a: If need to install the latest update, do “yum update”.  However, this may not be necessary

Step 1b: Some rpm package is NOT in the default repo (check /etc/yum.repo.d).  Need to install other rpm repo.

Some popular rpm repo:   rpmforge (e.g. mercurial),  Ruby.repo (Ruby jam)

==> rpmforge:  http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

A.   Get http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

B.   rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt   (get the GPG key)

C.   rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm  (verify the package A)

D.  rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm  --> check /etc/yum.repo.d/rpmforge.repo exist

 

Step 2: Install VNC server on linux, very useful tool.  However, need to change default twm to gnome-session.  Install ultravnc or realvnc on PC.

Very useful tool:  Host: need to change /etc/sysconfig/vncservers;  Make sure vncserver serivce is running, and editing .vnc/xstartup file.

Can use netstat -lt to check the tcp port status.

It's very useful that pc copy and paste can use directly on linux.   Just run "vncconfig" in linux and make sure all options are checked and keep the vncconfig ON ALL TIME then it works!!

(make sure the correct setting on unltravnc and realvnc are checked, too)

 

2a: Editing /etc/sysconfig/vncservers file to support multiple users, window size, and resolutions:

### /etc/sysconfig/vncservers #################

VNCSERVERS="1:root 2:alu 3:atd"
VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[2]="-geometry 1024x768 -depth 24"
VNCSERVERARGS[3]="-geometry 800x600"

###########################################

 

2b: Use putty login as root, alu, atdl; setting password for each users (very important!! Otherwise service won’t start).

2c:  Start the vnc service as root ==> service vncserver restart

2d: Check system->Administration->Security Level and Firewall->other ports –> add 5901,5902,5903

2d: use putty login, editing /home/alu/.vnc/xstartup as follows:

##################################################

centos4:~/.vnc> more xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

#[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &

##################################################

 

One annoying thing is hostname doesn't seem to work.  Need to use IP address for putty and vnc.  However, the IP address is dynamically changed because it's from DHCP server.  How to set hostname instead of using IP address? 

I did the following but not working.  How PC can know the hostname?

First, set the hostname, e.g. : centos5  system->administration->network->DNS->Hostname->centos5

This is corresponding to /etc/sysconfig/network: HOSTNAME

Then, system->administration->network->Devices->Edit->Hostname (optinal): –>centos5

This is corresponding to /etc/sysconfig/network-script/ifcfg-eth0: DHCP_HOSTNAME –> centos5

Then, system->administration->network->Devices->Edit->DNS:192.168.1.1

This is corresponding to /etc/resolv.conf

 

Step 3: Install Samba server on centos.  Samba server is not default on in centos.  Need to use yum install samba first. 

Please refer to vbird's suggestion for configuration.  Samba is based on NetBIOS, not tcp/ip.  It seems to avoid the hostname problem.

step 3(a):  yum install samba   --> rpm –qa  to check samba (samba-common, samba, samba-client)

step 3(b): edit /etc/samba/smb.conf

step 3(c): create smbpasswd:  touch smbpasswd

step 3(d): smbpasswd –a alu  (to add password to smbpasswd)

step 3(e): disable SELinux (important!!!)

step 3(f): /etc/rc.d/init.d/smb restart (start the samba server)

 

Step 4: start license server related service in /etc/rc.local

工具有關軟體

git: Check git during centos installation?  If not pre-installed:

$ rpm -Uvh http://mirror.webtatic.com/yum/centos/5/latest.rpm

$ yum install --enablerepo=webtatic git-all

kompare: Check KDE environment during centos installation.  Or install kompare inside of latest kde rpm.  Do

$ rpm -ivh ... kde ..

kdiff3: same as kompare, but more powerful.  Get the rpm directly from web.

xls2csv: convert Excel file into csv file.  There are two versions.  One is from catdoc; the other from CPAN (perl).   The one from CPAN is better in my opinion.

Ruby:  Check ruby during centos installation. rubygems: gnuplot, fastercsv

Python: Check python during centos installation.  However, the default python of centos or redhat is not the updated version (1.7.x).  For scientific computing or other applications, it is highly recommended to use EPD (Enthought) version instead.  The EPD version is installed in a separate directory, not replacing the default version.  Remember to set the path in .tcshrc or .bashrc to invoke the EPD version.

Perl: Check Perl during centos installation.

 

CAD 有關軟體

* ns3:  http://www.nsnam.org/wiki/index.php/Installation

 

* Composer: make sure to set /etc/sysconfig/vncservers ==> xwindows setting is 24-bits or pseudo 8-bit

* Sanwork: make sure to "yum install openmotif" to avoid the error of not finding libXm.so.3

 

* Vppsim (from MIT MIke Perrott)

do yum install gcc-c++ to install g++

 

To run license of Calibre, Adit,

1. start with host mode

2. Do /tools/ixl_cal_2007.4_21.19/change-hostid.sh  (in bsh, not tcsh) to change mac id

3. Do tcsh to change to tcsh

4. Do source CALIBRE.cshrc

5. Do clic_start to start mentor related license

 

 

Step 5: Script 和 Web 有關軟體

* Ruby: centos comes with default ruby.  However, it is helpful to install rubygems, gnuplot, and other gems.

Please refer to web how to install them.  yun install ruby ruby-gems (?) ruby-devel ..

* RoR (Ruby on Rail): same as above

* Apache2 and CGI.

yum install httpd ruby ruby-devel

* then need to use make install to install mod_ruby to enable the CGI working.  (same for Python and Perl).

* Use amrita for html output generation.  It's easy for viewing purpose

 

Step 6: Support ntfs file system (終於考定, another trouble maker is lib.so…)

CentOS doesn’t support NTFS file system natively, nor extFAT (Microsoft proprietary).   It is troublesome to read external hard drive (mostly NTFS).  Even though most USB drives are still using FAT that centos supports.  However, there is a 2G(?4G) limitation on FAT file size.  It makes things difficult to do external backup in step 7.

Therefore, it is important to make centos to support NTFS file system.  It is particularly troublesome for CentOS4.  Be careful on the following steps.  Reference: http://wiki.centos.org/TipsAndTricks/NTFS

It needs to include the fuse kernel module into kernel.  因此會需要 fuse, fuse-ntfs-3g, dkms, dkms-fuse.  CentOS5.4 and newer has included fuse kernel module.  Therefore, no need for dkms and dkms-fuse.

If you do:    yum install fuse fuse-ntfs-3g dkms dkms-fuse

It will not find anything because these rpm files are not centos default repo.  These rpm files are in rpmforge. 

(1) First, download rpmforge rpm-release from:

i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

(2) After that, run:   rpm –ivh rpmforge-release-xxx

(3)  yum install fuse fuse-ntfs-3g dkms dkms-fuse

(4) check if the running version matches with kernel

uname –r to check the current running kernel

rpm –qa | grep kernel\* | sort to check the kernel and kernel-devel

It may require to do: yum update kernel to make it match.   Make sure to reboot the machine.  Debug: https://www.centos.org/modules/newbb/viewtopic.php?topic_id=26488

(5) do /sbin/modprobe fuse   if there is no error message, it is ok.

(6) From chome VM page, check USB mass storage.  On PC, the external hard drive disappears.

(7) Do   mount –t ntfs-3g /dev/sda1 /export/usb   to mount external drive

(8) Do fdisk –l to check the parition

(9) Do umount /deve/sda1 to un-mount the external hard drive

 

Step 7: setup external backup

Follow bird’s suggestion:

2009年10月23日 星期五

PC 部份常用軟體

本文整理我的 PC 內常用軟體及設定

I. Internet 及網路和雲端軟體

1. Firefox 和 add-on: xmark, IE tab, Wikidiction

2. UltraVNC 取代 Microsoft remote desktop (家用 XP, Windows 7 不支援 remote desktop)。不過 UltraVNC 似乎容易掛掉,網路上有人建議用 WinVNC 或 RealVNC。VNC 的好處是可以用在 linux。

3. Syncplicity 及 Dropbox

4. Evernote 和 Microsoft OneNote

 

G. Google 軟體及 service

1. Google desktop

 

V. 防毒軟體

1. Avira Antivir (小紅傘)

 

T. 工具類軟體

1. Total commander: 支援 unicode,非常好用。Linux 上只有 Konqueror 可用。

2. Free commander: 類似 total commander, 免費且容易使用。不支援 unicode, 會有日文及簡體亂碼。

3. Foxit: PDF reader,比 Adobe 小且快速

4. 7zip: 免費且強大壓縮軟體

 

M. 多媒體

1. Picasa: 最棒的相片 database 軟體

2. GOM player: 最佳的 video player 軟體。取代 Microsoft Media Player, KMplayer.  類似軟體尚有 VLC,MPlayer, 和 KMplayer。說明和下載。

3. iTune: CD ripper 以及 audio database

4. Imgburner: 類似 Nero, 免費且快速,用於燒 DVD 光碟和擷取 DVD -> ISO 軟體。

5. DVDFab HD Decrypter: 擷取 DVD -> ISO 軟體, 同時破除保護。

6. DVD Shrink: 類似 DVDFab HD Decrypter。

7. Daemon Tools: 虛擬光碟機軟體,用於 player ISO 檔案。

 

P. P2P 軟體

1. uTorrent: 小且常用

 

L. Linux 軟體

1. cygwin (1.7.x): gnu+windows+cygnus 簡單的說就是在 windows 上架構 linux,對於習慣在 linux 上工作的人非常方便。

幾點需要注意:change default installation to include: openssh (in Network option), tcsh (in Shell option), xwindows (in X option).

2. VMware/Virtualbox: 除了 cygwin 以外,另外的選擇是 VMware 或 Virtulbox,虛擬的機器。VMware 是商用軟體。Virtualbox 是免費軟體。

2009年10月17日 星期六

免費 RF 軟體及阻抗匹配 (Impedance Matching)

常用的 RF Simulation 軟體如 ADS, Microwave Office, 或是 SpectreRF 動則數十萬。對於大多數 RF 工程師日常的工作實在是大材(財)小用。

本文想要介紹兩個好用而且免費的 RF simulation 軟體,以及如何用這兩個軟體來做阻抗匹配。

第一個軟體是 Smith,是由 Bern 大學的 Fritz Dellsperger 教授所提供。正式版收費 $100 元;demo 版免費,但只能用五個元件而且不能存檔。說實在話這個軟體並不值得花錢買,也只能做一些簡單的事。五個元件也差不多夠用,因此只要用 demod 版就可以了。我先用 Smith 來介紹 Smith Chart 以及幾個阻抗匹配的做法。

Smith Chart 基本介紹

可參考另一篇文章 "Smith Chart"。重點摘要如下:

1.  Open load 位於 (+1, 0), Short load 位於 (-1, 0), 50Ohm load 位於 (0, 0).

2. 上半平面為 inductive load; 下半平面為 capacitive load; x-axis 為 resistive load.  因此大多 DC open 電路的 S11 位於第四象限 (如 dipole antenna); DC short 電路的 S11 位於第二象限。

3. VSWR = constant 在 smith chart 上是圓心在 (0, 0) 的圓。 Q=constant 在 smith chart 上是橄欖形,兩端點位於 (-1, 0) 和 (+1, 0)。

 

Smith 軟體介紹

Smith 軟體最大的缺點是只能觀察一個頻點,不過這也讓設計變得簡單而且容易了解。

Step 1: 輸入 ZL (load impedance)

開啟 smith 之後,先鍵入 ZL。有兩種方法輸入 ZL: 如果知道 ZL, 可以直接輸入 ZL 的實部 (resistive load) 和虛部 (reactive load),如圖一;實際的情形大多是 network analyzer 量測出的 S11 參數,也可以選 reflection coefficient 配合 polar 座標輸入,如圖二。  不論是用 ZL 或 reflection coefficient, 都必須提供工作頻率。

copy 1 of smith tutorial 1

圖一: 直接輸入 ZL (load impedance) 的實部和虛部: 實部是 84.8 Ohm (resistive load), 虛部是 -125.1 Ohm (capacitive load)。

 

smith tutorial 2 

圖二: 輸入 S11 參數的 magnitude 和 angle。Magnitude 是 0.706, Angle 部份是 -31.6 度。ZL 值圖一相同。

 

Step 2: L-match with HPF 和 LPF

最簡單的 match 就是 L-match。一般而言 L-match 可以有四種方式如圖三。分別是相交在 R=50 或 G=0.02 circles。除此之外,可以相交在 capacitive 半平面或是 inductive 半平面,一共有四種組合。

image

圖三:L match 的四種組合。

 

實際的情況則多半是在 R>50 (或 G>0.02) 的圓內,如 dipole antenna 和 loop anenna。此時只會有兩種 L-match 。如圖四和圖五所示,RL = 84.8 - 125.1 j, 只能先並聯電感或電容和 R=50 圓相交。再串聯電容或電感完成 input matching.  仔細觀察這兩種 L-match, 圖四是 HPF,因為串聯電容及並聯電感。圖五則是 LPF,因為串聯電感及並聯電容。至於應該用那一種 L-match,由系統決定。例如,如果要濾掉 FM 干擾,應該用 HPF L-match;反之,如果要濾掉 GSM 干擾,則應該用 LPF L-match。

smith tutorial 2 - HPF matching

圖四:L-match 使用 HPF。

 smith tutorial 2 - LPF matching

圖五:L-match 使用 LPF。

 

L-match 理論和應用都簡單,除了達到阻抗匹配之外,還附送了一個 HPF 或 LPF。對於窄頻系統效果相當不錯。

所謂窄頻系統就是頻寬小於載波的 10%。例如藍芽, WiFi 等使用 2.4 GHz ISM band,系統頻寬遠小於 240MHz。相反的,電視所使用的 UHF (或 VHF),頻寬從 470MHz 到 850MHz,遠遠超過載波的10%,因此是寬頻系統。

L-match 的主要缺點是只針對一個頻點做 matching。雖然對於窄頻系統效果不錯,但對寬頻系統遠端頻點的 matching/LPF/HPF 可能就不夠理想。同時在做 L-match 時,系統的 Q 值可能會變大 (寬頻會差異大,group delay 變化會增加,最好 Q=0),對某一些系統不適合。另外有時系統需要 BPF 來濾掉所有的干擾。一個解決之道就是用 Pi 或 T-match。

 

Step 3: Pi-match 和 T-match with BPF

首先把虛部去掉 --> 84.8 - 125.1j ==> 84.8 Ohm。這可以降低 Q 值同時離 50Ohm 更近一步。因為 Zl 是 capacitive loading,一開始只能使用 serial L,限制為 T match 且加上一個 LPF。

接下來再使用 L-match,把 84.8 Ohm map 到 50 Ohm。有 LPF 和 HPF 兩種選擇。

T-match LPF

上圖是 T-match 的 LPF (LPF + L-match LPF)。下圖則是 T-match 的 BPF (LPF + L-match HPF)。

Screenshot - 20091107 - 211805

 

究竟用 T-match (或 pi-match) 有什麼好處?主要是能將 matching 和 filter 的 Q 值分開。可以達成更寬頻的 impedance matching。

什麼時候會用 T-match 或 pi-match?當 impedance 實部大於 50-Ohm,原則上使用 T-match。當 admittance 實部大於 20mS,原則上使用 pi-match。 如上圖的黃和藍兩圈之內的部份。之外的部份,似乎用 L-match 就可以,不用做 T-match 或 pi-match。

當然可以做更複雜的變化,如 cascade 幾個 T 或 pi 或混合 T 和 Pi match,最主要的目的是達到多點的 impedance matching,比處不討論。

Smith 的 L-match 和 T-match 都是以單點為基礎,雖然簡單,但很難契合實做的需要。 RFSim99 剛好補足這一點。更重要的是,RFSim99 是一個完全免費的軟體。

 

RFSim99 軟體介紹

Step 1: 輸入 ZL (load impedance)

RFSim99 的 GUI 使用起來相當容易。可以選擇用 1-port 或 2-port 元件來輸入 load impedance。我們載入一個內建的 2-port 例子且設定頻率從 400MHz 到 800MHz (UHF band)。剛好非常類似一個 dipole antenna 如下圖。600MHz 的阻抗為 84.8-125.1j Ohm ,和前面 Smith 的例子一致。

S11 of 2-port

 

Step 2: L-match with HPF 和 LPF

RFSim99 已經把 L-match 自動加在軟體中。只要選 Auto Match,同時勾選 port-1 match 和 LPF (HPF) ,就可以自動產生正確的 L-match 電路。

L-match RFSim99

上圖是用 HPF 的結果,可以看到 L 和 C 值和圖四一致。S11 可以看到 600MHz 有一個很深的 notch。同時 S21 也呈現 HPF 的形狀。下圖是 Smith chart 的結果。除了在 600MHz 附近 match 不錯,大部份的頻率都不好,所以這是窄頻的 match。 L-match 的 LPF 也有一樣的問題。

smith chart

 

Step 3: Pi-match 和 T-match with BPF

接下來是 T-match。不過 RFSim99 沒有 T-match 或 pi-match 的自動 matching 功能。因此,我們必須用圖六或圖七所得到的結果。先看 LPF 的 T-match。

T-match S11

結果好很多,從 440MHz 到 800MHz S11 基本上都在 -10dB 以下。看 Smith chart 更明顯。

 

T-match smith chart

 

接下來是 BPF 的 T-match。結果更好,低頻甚至可以到 -20dB 以下。同時 Smith chart 也十分不錯。

T-match BPF S11

 

t-match BPF smith chart

 

 

附記

Ludwig 的 "RF Circuit Design" 其中有一章專門討論 impedance matching,是我看過 RF 書中最詳細的。

可以把 impedance matching 化簡問題為 R != 50Ohm to 50Ohm matching。是否有其他 optimal matching (e.g. constant Q, etc.)

2009年10月1日 星期四

Kalman Filter and PLL

考慮如 Figure 1 個 burst mode 的 packet (任何 shared media 的傳送方式)。在 packet 最前頭都會有 1010.. 的 preamble 做為 bit/symbol synchronization。緊接在後的是事先定義好的 frame sync word 用來做為確認 lock 到對的 packet 以及 word boundary。最後才是實際的 data。這個應用 focus 在 preamble 部份 (1010..) synchronization,也就是找出 (estimate) preamble 的相位和頻率,同步之後的 data。  我們可以把問題重新定義如下:A [2pft + q]  如何根據接收端的 phase 找出發射端 f (or b = 1/(2pf) or T=1/f) and q ?

[Driessen94] 和 [Christiansen94] 兩人獨立証明了這個問題的最佳解是 Kalman filter,和二階的 PLL (PI filter)有一樣的結構。但是 Kalman filter time variant 特性比 一般 PLL 更快完成 acquistion。[Patapoutian99] 將兩人的 work 作了一個很好的整理。

image

Figure 1: Packet Frame Structure.

Bit Synchronization State Space Model

Figure 2 描述了這個 state-space model: 我們可以定義兩個 state variables 分別為 phase disturbance 和 frequency disturbance.  Output variable, y(k), 是 phase disturbance 加上 observation timing jitter.  同時, state-space model 中還包含了 phase 和 frequency noise.    

kalman_filter

Figure 2: State-Space Model of Bit Synchronization.

 

Kalman Filter of State Space Model

一旦我們建立了 state space model,我們可以根據 y(k) 來估計 b(k) q(k) (Kalman filter), 其解如下:

Kalman_bit_sync

Figure 3: Kalman Filter Solution of Figure 2.

 

光從上面的方程式大概很難看出什麼名堂。K(k) 是所謂的 Kalman Gain, P(k) 是 X(k) 的 covariance matrix。重點是上述的 recursive 方程式和 2nd order PLL 有者一樣的架構 [Drissen94]。

 

Kalman Filter and PLL

Figure 4 是上述 Kalman filter 的等價 block diagram。The model includes a PI time-invariant controller followed by an integrator (remember Alper's work?  PI controller plus a slow VCXO - it's a integrator).  The Kalman filter is shown has the same structure as the 2nd order PLL.

[a(k), b(k)]' 即對應 Kalman gain, K(k).

image

Figure 4: Block diagram of the Kalman filter and a proportional integral PLL.

 

Bit Synchronization PLL 操作分為兩種模式:Acquisition 和 Tracking

在 Acquistion 模式,Phase 和 frequency disturbance 遠大於 process noise,Q 可以忽略不計。Kalman filter 表現如 dynamic loop bandwidth 的 PLL。開始時 loop bandwidth 會增加 ( a(k)/b(k) 變大) 以加快 acquistion 的時間。一旦鎖住 loop bandwidth 會減小 ( a(k)/b(k) 變小) 以減小最終的 phase jitter。下圖顯示這樣的一個例子: P(0|-1) 時同時有 phase 和 frequency disturbance,特別是 phase disturbance 很大 (1/12)。

image

 

在 Tracking 模式,Kalman Gain 會收歛到最終值。因此和 2nd order PLL 是完全等價。藉者 Kalman Gain 的幫助,可以找出最佳的 PLL 設計。

 

Follow Up Task

==> 如何將 continous PLL 和 Kalman filter 連結超來?如何設計最佳 PLL考慮 VCO noise, PFD noise, 和 sigma-delta modulator noise?如何考慮 stability?

==> How about if VCO noise is time variant?  Kalman filter should be better than PLL?

==> If adding the data after the integrator (sigma-delta or just random data), then what's the equation?? can use Kalman filter to explain it?

Analog Simulation Flow

PRESIM

schematic: composer

netlister: composer - cdl (si) : netlist

testbench: tb_dut (PVT)

simulator: hspice

processs model: t350nm, u180nm, u130nm, u110nm, u110nmAL  --> put in /home/atd/tech/...

 

tb_dut.lis  = tb_dut.sp  + netlist.spi

tb_dut.sp does not include process component (nmos, pmos), but need to include PVT, need to include process ==> change tb all the time

> make tb_dut.lis ==> update tb_dut.lis

 

netlist.spi = netlist + convt_model_process ==>  netlist only change in design phase; model_process only change occasionally

 

netlist: hard to make dependency because it's from composer.  ==> make netlist directly

> make netlist    ==> update netlist

> make tb_dut.lis  ==> update netlist.spi ==> update tb_dut.lis

 

POSTSIM

netlister: calibre

testbench: tb_dut (PVT), same as presim

simulator: hspice or Adit

processs model: t350nm, u180nm, u130nm, u110nm, u110nmAL  --> same as presim

 

tb_dut.post.lis = tb_dut.sp + netlist.post.spi

> make tb_dut.post.lis ==> update tb_dut.post.lis

 

netlist.post.spi = netlist.cal + convt_model_process

> make netlist.cal  ==> update netlist.cal

> make tb_dut.post.lis ==> update tb_dut.post.lis

追蹤者