This is a combination usage of:
iterator
callback
yield
image processing
Created/updated by BA43B09F0725,qunshan@newsmth
import os, sys, time
import Image, ImageDraw, ImageFont
def findfiles(path, *callbacks):
for root, dirs, names in os.walk(path):
for name in names:
filename = os.path.join(root, name)
info = tuple(x(filename) for x in callbacks)
yield (filename,)+info
def addString(filename, timestr):
font = ImageFont.truetype(os.path.join(os.environ['windir'], 'Fonts', 'AGENCYB.TTF'), 108)
im = Image.open(filename)
x, y = im.size
draw=ImageDraw.Draw(img)
#draw.ink = 0 + 255*256 + 0*256*256
draw.text((x-640,y-128), timestr, font=font)
img.save(filename)
def addTimeString(filename, mtime):
timestr = time.strftime("%Y-%m-%d %H:%M", time.localtime(mtime))
addString(filename, timestr)
os.utime(filename, (time.time(), mtime))
if __name__ == '__main__':
for filename, mtime in findfiles(sys.argv[1], os.path.getmtime):
if filename.lower().endswith(('.jpg', '.jpeg')):
addTimeString(filename, mtime)
Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts
Thursday, June 30, 2011
Thursday, June 23, 2011
停车技巧
停车技巧:
非字形停车位:右侧车身 距离车位线1.5m,向后倒车; 在驾驶位位于隔一个停车位正中央时,向内侧打满轮,至车正,回正。
一字形停车: 右侧车身 距离车位线0.5m,向后倒车;在后视镜和前车B柱平行时,向内侧打满轮,继续倒车,至车呈45度角,反向打满轮,至车正,回正。
斜线停车位:后视镜对停车位近端边线时,向外侧打满轮,至车身和车位平行,回正,入车位。
非字形停车位:右侧车身 距离车位线1.5m,向后倒车; 在驾驶位位于隔一个停车位正中央时,向内侧打满轮,至车正,回正。
一字形停车: 右侧车身 距离车位线0.5m,向后倒车;在后视镜和前车B柱平行时,向内侧打满轮,继续倒车,至车呈45度角,反向打满轮,至车正,回正。
斜线停车位:后视镜对停车位近端边线时,向外侧打满轮,至车身和车位平行,回正,入车位。
自动档驾驶学习
N档的作用:
转自http://club.autohome.com.cn/bbs/thread-c-413-824998-1.html
1、被拖车时用: (拖行距离不超过50公里)。
2、长时间(超过1分钟至数分钟内)等红灯时用: (在我们这里,红绿灯都有数字递减显示。就可以根据上述原则,采取“①挂N,拉手闸。②保持D档,拉手闸。”)
3、汽车启动、熄火时: (所有汽车说明书都是讲点火要挂在P档,但问题在于: 当在P档点火后,要挂入D档前,是一定要经过R(倒车档)档,当经过R档时,车辆会自然震动一下,这是挂R档的缘故,从P档到D档过程中,等于先入了R档再入D档,无形中多了一次入R档的组合和磨擦,
我的做法是:踩着刹车打开钥匙第一级--挂N档--打火--挂D档--松手刹、放脚刹起步。
自动档熄车也有讲究,我是这样操作的: 熄火前踩着刹车挂N档--拉手刹--放开脚刹--关钥匙第一级--入P档--关钥匙第二级并取出钥匙。 其道理是:停车时,当踩着刹车入P档,拉手刹放开脚刹时,车辆会惯性地向前或向后移动一点位置,这是因为停车场不平整或有少许斜坡而造成的,不要小看这一点点移动,它会对自动变速箱中的锁止栓有一定的冲击,日积月累会对锁止栓有损害,就会出现过锁止栓断开的故障)。
转自http://club.autohome.com.cn/bbs/thread-c-413-824998-1.html
1、被拖车时用: (拖行距离不超过50公里)。
2、长时间(超过1分钟至数分钟内)等红灯时用: (在我们这里,红绿灯都有数字递减显示。就可以根据上述原则,采取“①挂N,拉手闸。②保持D档,拉手闸。”)
3、汽车启动、熄火时: (所有汽车说明书都是讲点火要挂在P档,但问题在于: 当在P档点火后,要挂入D档前,是一定要经过R(倒车档)档,当经过R档时,车辆会自然震动一下,这是挂R档的缘故,从P档到D档过程中,等于先入了R档再入D档,无形中多了一次入R档的组合和磨擦,
我的做法是:踩着刹车打开钥匙第一级--挂N档--打火--挂D档--松手刹、放脚刹起步。
自动档熄车也有讲究,我是这样操作的: 熄火前踩着刹车挂N档--拉手刹--放开脚刹--关钥匙第一级--入P档--关钥匙第二级并取出钥匙。 其道理是:停车时,当踩着刹车入P档,拉手刹放开脚刹时,车辆会惯性地向前或向后移动一点位置,这是因为停车场不平整或有少许斜坡而造成的,不要小看这一点点移动,它会对自动变速箱中的锁止栓有一定的冲击,日积月累会对锁止栓有损害,就会出现过锁止栓断开的故障)。
Wednesday, May 25, 2011
cshell redirection
Character Action
>
Redirect standard output
>&
Redirect standard output and standard error
<
Redirect standard input
>!
Redirect standard output; overwrite file if it exists
>&!
Redirect standard output and standard error; overwrite file if it exists
|
Redirect standard output to another command (pipe)
>>
Append standard output
>>&
Append standard output and standard error
>
Redirect standard output
>&
Redirect standard output and standard error
<
Redirect standard input
>!
Redirect standard output; overwrite file if it exists
>&!
Redirect standard output and standard error; overwrite file if it exists
|
Redirect standard output to another command (pipe)
>>
Append standard output
>>&
Append standard output and standard error
Tuesday, May 10, 2011
[python] Parameters: pass by value or ref?
C is pass-by-value.
Java is pass-by-value.
Python passes references-to-objects by value (like Java), and everything in Python is an object.
Some objects, like strings, tuples, and numbers, are immutable. Altering them inside a function/method will create a new instance and the original instance outside the function/method is not changed.
Other objects, like lists and dictionaries are mutable, which means you can change the object in-place. Therefore, altering an object inside a function/method will also change the original object outside. Assigning a separate object (e.g. creating a new instance) to the input parameter will also not change the original instance.
def no_change0(val)
val *= 2 #original val is not changed.
def no_change1(inst)
inst = {}
inst['anything'] = 'something' #original inst is not changed!!!
def change1(inst)
inst['anything'] = 'something' #original inst is changed this time.
Java is pass-by-value.
Python passes references-to-objects by value (like Java), and everything in Python is an object.
Some objects, like strings, tuples, and numbers, are immutable. Altering them inside a function/method will create a new instance and the original instance outside the function/method is not changed.
Other objects, like lists and dictionaries are mutable, which means you can change the object in-place. Therefore, altering an object inside a function/method will also change the original object outside. Assigning a separate object (e.g. creating a new instance) to the input parameter will also not change the original instance.
def no_change0(val)
val *= 2 #original val is not changed.
def no_change1(inst)
inst = {}
inst['anything'] = 'something' #original inst is not changed!!!
def change1(inst)
inst['anything'] = 'something' #original inst is changed this time.
[python] How to iterate through a list
- basic iteration
colours = ["red","green","blue"]
for colour in colours:
print colour
- enumerate
colours = ["red","green","blue"]
for i, colour in enumerate(colours):
print i, colour
- Remove elements as you traverse a list
for c in colors[:]:
if c == 'green':
colors.remove(c)
Hereby colors[:] is a copy (a weird but, sigh, idiomatic way to spell list(colors)) so it doesn't get affected by the .remove calls
Monday, November 15, 2010
short summary of package
Packages are explicitly named scopes appearing at the outermost level of the source text (at the same level as top-level modules and primitives). Types, variables, tasks, functions, sequences, and properties may be declared within a package.
Packages must not contain any processes. Therefore, wire declarations with implicit continuous assignments are not allowed.
Items within packages are generally type definitions, tasks, and functions. Items within packages cannot have hierarchical references. It is also possible to populate packages with parameters, variables, and nets.
One way to use declarations made in a package is to reference them using the class scope resolution operator ::.
ComplexPkg::Complex cout = ComplexPkg::mul(a, b);
Explicit import allows control over precisely which symbols are imported:
import ComplexPkg::Complex;
An alternate method for utilizing package declarations is via the import statement.
Packages must not contain any processes. Therefore, wire declarations with implicit continuous assignments are not allowed.
Items within packages are generally type definitions, tasks, and functions. Items within packages cannot have hierarchical references. It is also possible to populate packages with parameters, variables, and nets.
One way to use declarations made in a package is to reference them using the class scope resolution operator ::.
ComplexPkg::Complex cout = ComplexPkg::mul(a, b);
Explicit import allows control over precisely which symbols are imported:
import ComplexPkg::Complex;
An alternate method for utilizing package declarations is via the import statement.
Thursday, November 11, 2010
ansi color (with python)
#! /magnum/oss/bin/python
def printC(bg,fg):
print "\033[05;"+bg+";"+fg+"mABC"+"\033[0m"
mystr=""
attrib=[0,1,4,5,7,8]
for i in attrib:
mystr+="\033[%dm%d\033[0m " % (i,i)
print mystr
mystr="\n\n"
for i in range (40,48):
mystr="%d:" % i
for j in range (30,38):
fg=str(j)
mystr= mystr + (" \033[1;%d;%dm%d\033[0m" % (i,j,j))
print mystr
#EOF
%color.py
0 1 4 5 7 8
40: 30 31 32 33 34 35 36 37
41: 30 31 32 33 34 35 36 37
42: 30 31 32 33 34 35 36 37
43: 30 31 32 33 34 35 36 37
44: 30 31 32 33 34 35 36 37
45: 30 31 32 33 34 35 36 37
46: 30 31 32 33 34 35 36 37
47: 30 31 32 33 34 35 36 37
def printC(bg,fg):
print "\033[05;"+bg+";"+fg+"mABC"+"\033[0m"
mystr=""
attrib=[0,1,4,5,7,8]
for i in attrib:
mystr+="\033[%dm%d\033[0m " % (i,i)
print mystr
mystr="\n\n"
for i in range (40,48):
mystr="%d:" % i
for j in range (30,38):
fg=str(j)
mystr= mystr + (" \033[1;%d;%dm%d\033[0m" % (i,j,j))
print mystr
#EOF
%color.py
0 1 4 5 7 8
40: 30 31 32 33 34 35 36 37
41: 30 31 32 33 34 35 36 37
42: 30 31 32 33 34 35 36 37
43: 30 31 32 33 34 35 36 37
44: 30 31 32 33 34 35 36 37
45: 30 31 32 33 34 35 36 37
46: 30 31 32 33 34 35 36 37
47: 30 31 32 33 34 35 36 37
Thursday, November 4, 2010
how to change color of "ls" command
use "man dir_colors" for detailed help.
copy "/etc/DIR_COLORS" to "~/.dir_colors" to create user-defined color file.
to ease visibility of folder color with blackground, change default setting
on line 59:
"DIR 01;34 # directory" #i.e. darkblue
to
"DIR 04;36 # directory" #i.e. darkcyan, underline
This is enough.
copy "/etc/DIR_COLORS" to "~/.dir_colors" to create user-defined color file.
to ease visibility of folder color with blackground, change default setting
on line 59:
"DIR 01;34 # directory" #i.e. darkblue
to
"DIR 04;36 # directory" #i.e. darkcyan, underline
This is enough.
Wednesday, August 4, 2010
advanced regular expression 高级正则表达式
断言
零宽度正预测先行断言 and 零宽度正回顾后发断言
(1)零宽度: 这表示匹配是一个位置(Loaction)而不是子表达式。
(2)预测先行 vs 回顾后发
预测先行:仅当子表达式在此位置的右侧匹配时才继续匹配。返回与子表达式匹配的前面位置,从做左到右匹配。
回顾后发:仅当子表达式在此位置的左侧匹配时才继续匹配。返回与子表达式匹配的后边位置,从右到左匹配。
(3)正向 vs 负向:
正向:当子表达式满足时才匹配。
负向:当子表达式不满足时才匹配。
总共四种断言:
零宽度正预测先行断言
vim: \@=
vim例:\w\+\(ing\)\@= 匹配以ing结尾的单词的前面部分(除了ing以外的部分)
如果用magic, 则为 \v\w+(ing)@\=
零宽度正回顾后发断言
vim: \@<=
vim例:\(re\)\@<=\w+ 匹配以re开头的单词的后半部分(除了re以外的部分)
如果用magic, 则为 \v(re)@\<\=\w+
零宽度负预测先行断言
vim: \@!
vim例:foo\(bar\)\@! 匹配后面不带 "bar" 的 "foo"
零宽度负回顾后发断言
vim: \@<!
vim例:\(foo\)\@<!bar 匹配前面不带 "foo" 的 "bar"
PCRE 对应的格式为:
(?= 子表达式), (?<= 子表达式)
(?! 子表达式), (?<! 子表达式)
for perl help:
# perldoc perlre
.NET Framework中支持有名RE, 并支持注释:
(?<myname>expression) 如果遇到匹配,则把匹配的内容命名为myname,并压入堆栈
(?<-myname>expression') 如果遇到匹配,则从堆栈中弹出 名为myname的匹配内容。
(?(myname)yes|no) 如果堆栈上存在命名为myname的匹配的内容,则去继续匹配yes部分的表达式,否去继续匹配no部分。
注释
注释一般通过表达式(?#注释)实现。
以下正则表达式在第一个分组中中添加了注释“不能以数字开头”。
(?<!\d+(?#不能以数字开头))[a-z_A-Z]+
如果要在正则表达式中包含注释,最好打开IgnorePatternWhitespace选项,即忽略模式里的空白字符。
零宽度正预测先行断言 and 零宽度正回顾后发断言
(1)零宽度: 这表示匹配是一个位置(Loaction)而不是子表达式。
(2)预测先行 vs 回顾后发
预测先行:仅当子表达式在此位置的右侧匹配时才继续匹配。返回与子表达式匹配的前面位置,从做左到右匹配。
回顾后发:仅当子表达式在此位置的左侧匹配时才继续匹配。返回与子表达式匹配的后边位置,从右到左匹配。
(3)正向 vs 负向:
正向:当子表达式满足时才匹配。
负向:当子表达式不满足时才匹配。
总共四种断言:
零宽度正预测先行断言
vim: \@=
vim例:\w\+\(ing\)\@= 匹配以ing结尾的单词的前面部分(除了ing以外的部分)
如果用magic, 则为 \v\w+(ing)@\=
零宽度正回顾后发断言
vim: \@<=
vim例:\(re\)\@<=\w+ 匹配以re开头的单词的后半部分(除了re以外的部分)
如果用magic, 则为 \v(re)@\<\=\w+
零宽度负预测先行断言
vim: \@!
vim例:foo\(bar\)\@! 匹配后面不带 "bar" 的 "foo"
零宽度负回顾后发断言
vim: \@<!
vim例:\(foo\)\@<!bar 匹配前面不带 "foo" 的 "bar"
PCRE 对应的格式为:
(?= 子表达式), (?<= 子表达式)
(?! 子表达式), (?<! 子表达式)
for perl help:
# perldoc perlre
.NET Framework中支持有名RE, 并支持注释:
(?<myname>
(?<-myname>expression') 如果遇到匹配,则从堆栈中弹出 名为myname的匹配内容。
(?(myname)yes|no) 如果堆栈上存在命名为myname的匹配的内容,则去继续匹配yes部分的表达式,否去继续匹配no部分。
注释
注释一般通过表达式(?#注释)实现。
以下正则表达式在第一个分组中中添加了注释“不能以数字开头”。
(?<!\d+(?#不能以数字开头))[a-z_A-Z]+
如果要在正则表达式中包含注释,最好打开IgnorePatternWhitespace选项,即忽略模式里的空白字符。
Sunday, July 4, 2010
中国高速铁路
CRH:中国高速铁路,英文全称(CHINA RAILWAY HIGH-SPEED)目前已知有CRH1,CRH2,CRH3,CRH5。据称,由于中国人忌讳“4”谐音“死”故没有CRH4的型号。
CRH2和CRH5具备提速至300KM/H的条件。
CRH1庞巴迪-四方-鲍尔(BSP)生产,原型是庞巴迪为瑞典AB提供的Regina。200公里级别(营运速度200KM/h,最高速度250KM/h)。
编组型式:8辆编组,可两编组连挂运行动力配置:2(2M+1T)+(1M+1T)车种:一等车、二等车、酒吧坐车合造车定员(人):670
客室布置:一等车2+2、二等车2+3
最高运营速度(km/h):200
中间车辆长度(mm):26600
车辆宽度(mm):3328
车辆高度(mm):4040
牵引电动机:265kW
CRH1共有三个派生车型,它们分别是CRH1A、CRH1B和CRH1E。
CRH2
南车四方(联合日本川崎)生产。
是以日本新干线的E2-1000型电动车组为基础,是继台湾高铁的700T型电联车后,第二款出口国外的新干线列车。供中国使用的CRH2型虽使用与E2-1000相同的电动机,由于其编组方式是4节动车配4节拖车,动力比日本的6M2T编组E2系小,因此在营运速度方面会比日本本土的E2系有所下调,最高营运时速为200公里。
CRH2系列有4个派生车型,它们分别是CRH2A、CRH2B、CRH2C和CRH2E。
编组型式:8辆编组,可两编组连挂运行(重联运行)
CRH2型电动车组,全部为8节或16节编组,动力分配形式各不相同;2A为4M+4T,2B为8M+8T,2C为6M+2T,2E为8M+8T。
车种:一等座车、二等座车、二等座车餐车。
车辆宽度(mm):3380
车辆高度(mm):3700
CRH3
北车唐山机车厂(联合西门子)生产,原型ICE3。编组形式为,8M0T。轴功率550kW,全车共16根动轴,平均分布于8辆车上,每车两台转向架,每台转向架均有一根动轴。
动力配置:全部为8节或16节编组,动力分配形式各不相同;3A/3C为4M+4T,3D目前暂不清楚。
车种:一等座车、二等座车、二等座车餐车
定员:601人
车辆宽度(mm):3265
车辆高度(mm):3890
CRH5
北车长春客车厂(联合阿尔斯通)生产,原型阿尔斯通为芬兰国铁提供的SM3型。200公里级别(营运速度200KM/h,最高速度250KM/h)。
在CRH5中,CRH5-001A为原装进口车,CRH5-004A为散件组装车,CRH5-010A/011A/012A为采用部分进口部件的国产车。
编组型式:全部为8辆编组,可两编组连挂运行动力配置:(3M+1T)+(2M+2T)车种:一等车、二等车、酒吧坐车合造车定员(人):602+2(残疾人)客室布置:一等车2+2、二等车2+3
最高运营速度(km/h):200(具备提速到300km/h的条件)最高试验速度(km/h):250
车辆宽度(mm):3200
车辆高度(mm):4270
中国高铁建设规划
四纵:
北京-上海:全长1318公里,纵贯京津沪和冀鲁皖苏四省,连接环渤海 和长江三角洲两大经济区 。
北京-武汉-广州-深圳:全长约2260公里,连接华北和华南地区。武 汉至广州段全长995公里,2005年6月开工 。
北京-沈阳-哈尔滨(大连):全长约1700公里,连接东北和关内地区 。秦皇岛至沈阳段400 公里已于2003年建成 。
杭州-宁波-福州-深圳:全长约1600公里,连接长江、珠江三角洲 和东南沿海地区。
四横:
徐州-郑州-兰州:全长约1400公里,连接西北和华东地 区。已开工建设郑州至西安段455公里 。
杭州-南昌-长沙:全长约880公里,连接华中和华东地 区 。
青岛-石家庄-太原:全长约770公里,连接华北和华东 地区。已开工建设建设石家庄至太原段205公里。
宁汉蓉(南京-武汉-重庆-成都):全长约1600公里, 连接西南和华东地区。已开工建设南京至合肥段、武汉至 合肥段、宜万段、成遂渝段
CRH2和CRH5具备提速至300KM/H的条件。
CRH1庞巴迪-四方-鲍尔(BSP)生产,原型是庞巴迪为瑞典AB提供的Regina。200公里级别(营运速度200KM/h,最高速度250KM/h)。
编组型式:8辆编组,可两编组连挂运行动力配置:2(2M+1T)+(1M+1T)车种:一等车、二等车、酒吧坐车合造车定员(人):670
客室布置:一等车2+2、二等车2+3
最高运营速度(km/h):200
中间车辆长度(mm):26600
车辆宽度(mm):3328
车辆高度(mm):4040
牵引电动机:265kW
CRH1共有三个派生车型,它们分别是CRH1A、CRH1B和CRH1E。
CRH2
南车四方(联合日本川崎)生产。
是以日本新干线的E2-1000型电动车组为基础,是继台湾高铁的700T型电联车后,第二款出口国外的新干线列车。供中国使用的CRH2型虽使用与E2-1000相同的电动机,由于其编组方式是4节动车配4节拖车,动力比日本的6M2T编组E2系小,因此在营运速度方面会比日本本土的E2系有所下调,最高营运时速为200公里。
CRH2系列有4个派生车型,它们分别是CRH2A、CRH2B、CRH2C和CRH2E。
编组型式:8辆编组,可两编组连挂运行(重联运行)
CRH2型电动车组,全部为8节或16节编组,动力分配形式各不相同;2A为4M+4T,2B为8M+8T,2C为6M+2T,2E为8M+8T。
车种:一等座车、二等座车、二等座车餐车。
车辆宽度(mm):3380
车辆高度(mm):3700
CRH3
北车唐山机车厂(联合西门子)生产,原型ICE3。编组形式为,8M0T。轴功率550kW,全车共16根动轴,平均分布于8辆车上,每车两台转向架,每台转向架均有一根动轴。
动力配置:全部为8节或16节编组,动力分配形式各不相同;3A/3C为4M+4T,3D目前暂不清楚。
车种:一等座车、二等座车、二等座车餐车
定员:601人
车辆宽度(mm):3265
车辆高度(mm):3890
CRH5
北车长春客车厂(联合阿尔斯通)生产,原型阿尔斯通为芬兰国铁提供的SM3型。200公里级别(营运速度200KM/h,最高速度250KM/h)。
在CRH5中,CRH5-001A为原装进口车,CRH5-004A为散件组装车,CRH5-010A/011A/012A为采用部分进口部件的国产车。
编组型式:全部为8辆编组,可两编组连挂运行动力配置:(3M+1T)+(2M+2T)车种:一等车、二等车、酒吧坐车合造车定员(人):602+2(残疾人)客室布置:一等车2+2、二等车2+3
最高运营速度(km/h):200(具备提速到300km/h的条件)最高试验速度(km/h):250
车辆宽度(mm):3200
车辆高度(mm):4270
中国高铁建设规划
四纵:
北京-上海:全长1318公里,纵贯京津沪和冀鲁皖苏四省,连接环渤海 和长江三角洲两大经济区 。
北京-武汉-广州-深圳:全长约2260公里,连接华北和华南地区。武 汉至广州段全长995公里,2005年6月开工 。
北京-沈阳-哈尔滨(大连):全长约1700公里,连接东北和关内地区 。秦皇岛至沈阳段400 公里已于2003年建成 。
杭州-宁波-福州-深圳:全长约1600公里,连接长江、珠江三角洲 和东南沿海地区。
四横:
徐州-郑州-兰州:全长约1400公里,连接西北和华东地 区。已开工建设郑州至西安段455公里 。
杭州-南昌-长沙:全长约880公里,连接华中和华东地 区 。
青岛-石家庄-太原:全长约770公里,连接华北和华东 地区。已开工建设建设石家庄至太原段205公里。
宁汉蓉(南京-武汉-重庆-成都):全长约1600公里, 连接西南和华东地区。已开工建设南京至合肥段、武汉至 合肥段、宜万段、成遂渝段
Saturday, July 3, 2010
地铁系统
地铁和轻轨
为了增强轨道的稳定性,减少养护和维修的工作量,增大回流断面和减少杂散电流,地铁和轻轨都选用轨距为1435毫米的国际标准双轨作为列车轨道,与国铁列车选用的轨道规格相同,并没有所谓的钢轨重量轻重之分。
划分两者区别的依据是所选用列车的规格。按照国际标准,城市轨道交通列车可分为A、B、C三种型号,分别对应3米、2.8米、2.6米的列车宽度。凡是选用A型或B型列车的轨道交通线路称为地铁,采用5~8节编组列车;选用C型列车的轨道交通线路称为轻轨(上海轨道交通8号线除外),采用2~4节编组列车,列车的车型和编组决定了车轴重量和站台长度。在我国的规范中是指,轴重相对较轻,单方向输送能力在1万~3万人次的轨道交通系统,称为轻轨;每小时客运量3万~8万人次的轨道交通系统,称为地铁。
通常一个轨道交通网络,由三个等级的线网有机组合而成:区域快线系统(R线)、城区干线系统(M线)和辅助联络系统(L线)。区域快线系统,类似于美国的通勤铁路和日本的JR通勤铁路,起终点通常在郊县,有的经过主城区,有的不经过主城区。城区干线系统,则是主要为主城区交通服务的,起终点通常在城市建成区的边缘或城市外围城镇组团中。辅助联络系统,顾名思义,就是在整个线网中起到辅助和沟通作用的线路,他们通常采用比M线稍低一些的制式,运能相对也较小。
R线追求的是高速,因此站间距大,对列车速度的要求高,通常采用电力机车,而M线追求的是便捷,因此站间距比较小,对列车运行速度的要求不高,通常采用城轨车辆。
容量(车型)
地铁通常采用A型车和B型车,这两种车的区别在于几何尺寸和载客量。A型车通常长22米,宽3米(当然也有南京地铁使用的3.2米宽体A车),B型车通常长19米,宽2.8米,因此同样节数的一列列车,使用A车的载客量要大于B车。例如,6节编组A车的额定载客量可以达到1830人,而B车就只有1440人。
编组
以无锡轨道交通1号线为例。客流预测远期高峰小时单向客流量为31300人次,也就是说高峰小时在同一方向上,最大通过的客流量有31300人次之多。地铁设计规范规定,新建地铁的服务水平不得低于每小时开行30对的指标,也就是说,每个小时在同一方向上至少要发30班列车。一列4B,5B,6B列车的载客量分别为950人、1195人、1440人。用31300分别除以这三个数字,得到32.94、26.19和21.73。可以看出,如果采用4B编组,则必须每小时开行33对才能达到客流需要,也就是说系统长期将处在高强度满负荷状态,这显然是极其不利于安全的,因此4节B车编组无法满足无锡1号线的需要。而如果采用6B编组,则每小时只需要开行22对,相比较起来,发车间隔要比采用5B编组来的大,这也有些不利于提高服务水平。所以,初步看来选取5B是合适的。进一步验算,采用5B编组,假设每小时开行30对,则一小时单向可以输送35850人次,将它除以31300,得到1.145,意味着运能储备达到14.5%。
轨道交通列车通常只采用偶数节编组,比如2节,4节,6节,8节,很少有采用奇数节的(请注意是很少有,而不是没有,例如高雄地铁初期采用3节A车编组)。
众所周知,地铁列车分为动车和拖车,一节带受电弓或者受流器的动车和一节带空气压缩机的动车为一个单元,再加上一头一尾两节拖车,这就是为什么绝大多数城市的快轨列车编组都是偶数节的道理。我国通常用A代表拖车,用B代表带受电弓或授流器的动车,用C代表只带空气压缩机的动车。因此上海地铁1号线的6编,就是4动2拖A-B-C-B-C-A,8编就是6动2拖A-B-C-B-C-B-C-A。偶数节的好处,简直不言而喻。例如调配组合方便,购车方便,动力均衡,不同线路的车辆互换性好,可以增加系统运营的稳定性和可靠性,降低成本等等。
奇数节就不同的,如果是5编,按照无锡这次上报的方案,就是3动2拖A-B-C-B-A。这将会带来几个比较显著的问题:首先,动车不成单元,先是给购车带来了不便,带受电弓的动车数是带空气压缩机的动车数的一倍,无形中又增加了以后调配的难度和维护的成本。其次,动力不均衡,牵引和辅助系统的配备有区别。采用偶数节编组,例如6节,只需要配置2个辅助系统,而采用5节可能就要配置更多的辅助系统,无论是造价还是运营成本都显然是后者大于前者。可能这也就是为什么鲜有城市采用奇数节编组的道理。
动力
电气化铁路常用的两种供电网络方式包括接触网供电和第三轨供电。第三轨供电的概念就是在列车行走的两条路轨以外,再加上带电的钢轨。这条带电钢轨通常设于两轨之间或其中一轨的外侧。电动列车的集电装置在带电路轨上接触并滑行,把电力传到列车上。这种集电装置在英语称为 shoe,中译为集电靴(取流靴)。第三轨安装在轨道梁上,电动车辆取流靴与第三轨接触面大且对其磨损极小。采用第三轨式接触网的优点是工程易于安装,检修方便、维护简单,寿命长。从技术角度来讲,由于集电靴在高速之下难以准确地抓紧带电轨,故采用第三轨供电的线路速度不能太高。理论上来讲,采用轨道供电系统的列车的时速上限是 160 公里。另外,第三轨有触电的风险,只能用于封闭线路,因此不适用于以地面线路为主的铁路运输系统中。另一方面,地面重型铁路系统为了高速客运和货运重载的需要,会使用更高的电压,如25千伏的供电系统,这也是第三轨系统所不能承受的。
在铁路和城市轨道交通系统中,架空接触网只有导线的一个电极,电力机车通过集电弓取电,再通过金属轮轨回流到电网中。在无轨电车等使用胶轮的系统中,架空接触网有两根互不接触的两根接触导线(简称触线),通过两个集电杆取电。架空接触网的悬挂类型大致为三种:简单悬挂,链式悬挂,刚性悬挂。刚性悬挂是以硬质的金属条(通常是铜条)代替软质的导线的新型悬挂方式。刚性悬挂使用集电弓,没有使用集电靴的第三轨容易脱落的缺点,可以达到更高的运行速度。
为了增强轨道的稳定性,减少养护和维修的工作量,增大回流断面和减少杂散电流,地铁和轻轨都选用轨距为1435毫米的国际标准双轨作为列车轨道,与国铁列车选用的轨道规格相同,并没有所谓的钢轨重量轻重之分。
划分两者区别的依据是所选用列车的规格。按照国际标准,城市轨道交通列车可分为A、B、C三种型号,分别对应3米、2.8米、2.6米的列车宽度。凡是选用A型或B型列车的轨道交通线路称为地铁,采用5~8节编组列车;选用C型列车的轨道交通线路称为轻轨(上海轨道交通8号线除外),采用2~4节编组列车,列车的车型和编组决定了车轴重量和站台长度。在我国的规范中是指,轴重相对较轻,单方向输送能力在1万~3万人次的轨道交通系统,称为轻轨;每小时客运量3万~8万人次的轨道交通系统,称为地铁。
通常一个轨道交通网络,由三个等级的线网有机组合而成:区域快线系统(R线)、城区干线系统(M线)和辅助联络系统(L线)。区域快线系统,类似于美国的通勤铁路和日本的JR通勤铁路,起终点通常在郊县,有的经过主城区,有的不经过主城区。城区干线系统,则是主要为主城区交通服务的,起终点通常在城市建成区的边缘或城市外围城镇组团中。辅助联络系统,顾名思义,就是在整个线网中起到辅助和沟通作用的线路,他们通常采用比M线稍低一些的制式,运能相对也较小。
R线追求的是高速,因此站间距大,对列车速度的要求高,通常采用电力机车,而M线追求的是便捷,因此站间距比较小,对列车运行速度的要求不高,通常采用城轨车辆。
容量(车型)
地铁通常采用A型车和B型车,这两种车的区别在于几何尺寸和载客量。A型车通常长22米,宽3米(当然也有南京地铁使用的3.2米宽体A车),B型车通常长19米,宽2.8米,因此同样节数的一列列车,使用A车的载客量要大于B车。例如,6节编组A车的额定载客量可以达到1830人,而B车就只有1440人。
编组
以无锡轨道交通1号线为例。客流预测远期高峰小时单向客流量为31300人次,也就是说高峰小时在同一方向上,最大通过的客流量有31300人次之多。地铁设计规范规定,新建地铁的服务水平不得低于每小时开行30对的指标,也就是说,每个小时在同一方向上至少要发30班列车。一列4B,5B,6B列车的载客量分别为950人、1195人、1440人。用31300分别除以这三个数字,得到32.94、26.19和21.73。可以看出,如果采用4B编组,则必须每小时开行33对才能达到客流需要,也就是说系统长期将处在高强度满负荷状态,这显然是极其不利于安全的,因此4节B车编组无法满足无锡1号线的需要。而如果采用6B编组,则每小时只需要开行22对,相比较起来,发车间隔要比采用5B编组来的大,这也有些不利于提高服务水平。所以,初步看来选取5B是合适的。进一步验算,采用5B编组,假设每小时开行30对,则一小时单向可以输送35850人次,将它除以31300,得到1.145,意味着运能储备达到14.5%。
轨道交通列车通常只采用偶数节编组,比如2节,4节,6节,8节,很少有采用奇数节的(请注意是很少有,而不是没有,例如高雄地铁初期采用3节A车编组)。
众所周知,地铁列车分为动车和拖车,一节带受电弓或者受流器的动车和一节带空气压缩机的动车为一个单元,再加上一头一尾两节拖车,这就是为什么绝大多数城市的快轨列车编组都是偶数节的道理。我国通常用A代表拖车,用B代表带受电弓或授流器的动车,用C代表只带空气压缩机的动车。因此上海地铁1号线的6编,就是4动2拖A-B-C-B-C-A,8编就是6动2拖A-B-C-B-C-B-C-A。偶数节的好处,简直不言而喻。例如调配组合方便,购车方便,动力均衡,不同线路的车辆互换性好,可以增加系统运营的稳定性和可靠性,降低成本等等。
奇数节就不同的,如果是5编,按照无锡这次上报的方案,就是3动2拖A-B-C-B-A。这将会带来几个比较显著的问题:首先,动车不成单元,先是给购车带来了不便,带受电弓的动车数是带空气压缩机的动车数的一倍,无形中又增加了以后调配的难度和维护的成本。其次,动力不均衡,牵引和辅助系统的配备有区别。采用偶数节编组,例如6节,只需要配置2个辅助系统,而采用5节可能就要配置更多的辅助系统,无论是造价还是运营成本都显然是后者大于前者。可能这也就是为什么鲜有城市采用奇数节编组的道理。
动力
电气化铁路常用的两种供电网络方式包括接触网供电和第三轨供电。第三轨供电的概念就是在列车行走的两条路轨以外,再加上带电的钢轨。这条带电钢轨通常设于两轨之间或其中一轨的外侧。电动列车的集电装置在带电路轨上接触并滑行,把电力传到列车上。这种集电装置在英语称为 shoe,中译为集电靴(取流靴)。第三轨安装在轨道梁上,电动车辆取流靴与第三轨接触面大且对其磨损极小。采用第三轨式接触网的优点是工程易于安装,检修方便、维护简单,寿命长。从技术角度来讲,由于集电靴在高速之下难以准确地抓紧带电轨,故采用第三轨供电的线路速度不能太高。理论上来讲,采用轨道供电系统的列车的时速上限是 160 公里。另外,第三轨有触电的风险,只能用于封闭线路,因此不适用于以地面线路为主的铁路运输系统中。另一方面,地面重型铁路系统为了高速客运和货运重载的需要,会使用更高的电压,如25千伏的供电系统,这也是第三轨系统所不能承受的。
在铁路和城市轨道交通系统中,架空接触网只有导线的一个电极,电力机车通过集电弓取电,再通过金属轮轨回流到电网中。在无轨电车等使用胶轮的系统中,架空接触网有两根互不接触的两根接触导线(简称触线),通过两个集电杆取电。架空接触网的悬挂类型大致为三种:简单悬挂,链式悬挂,刚性悬挂。刚性悬挂是以硬质的金属条(通常是铜条)代替软质的导线的新型悬挂方式。刚性悬挂使用集电弓,没有使用集电靴的第三轨容易脱落的缺点,可以达到更高的运行速度。
Sunday, May 30, 2010
perl vs python (hash and list/array)
| perl | python | |||
| hash | array | hash | array (tuple for constant, and list for variable) | |
| symbol (whole, ele) | {},{} | (),[] | {},[] | []/() (list/tuple), [] |
| declare | my %hash = ("foo", 35) my %last_name = ( "fred" => "flintstone", …) | my @var = (11, 27.1 , "a string"); my @var = qw/ hello my god / | some_dict = { "fred": "flintstone", …} | list = ['milk', 1, 'lettuce'] |
| clear | %hash = () | @var = () $#array = -1; | dict={} | list = [] |
| retain the size | my $count = keys %hash; | $scalar = @array; $scalar = scalar @array; | count = len(hash) | l=len(L) |
| add/use element | $last_name{'wilma'} = "flintstone"; | $array[3] = 5 @list2 = (1, @list1, 5); #nesting is not supported @subarray2 = @array[0,1..3] | some_dict['wilma'] = "flintstone" | a = (1, 2); b = (3, 4); c = (a, b) => ((1,2),(3,4)) c=a+b => (1,2,3,4) L[i:j] = J; |
| use keys/values | my @k = keys %hash; my @v = values %hash; while ( ($key, $value) = each %hash ) … | k = hash.keys() v = hash.values() for (key, value) in hash.items(): ... | ||
| check existence of an ele | if (exists $books{'dino'}) | exists $array[ $index ] -> existence defined $array[ $index ] -> defined | if books.has_key('dino'): | |
| add an ele to the end | push(@coins, "Penny"); | list.append(x) | ||
| add an ele to the beginning | shift(@coins, "First"); | list.insert(0, x) | ||
| remove an ele | delete $books{$person}; | del books[person] | ||
| from the beginning | $var=unshift(@coins); | a=list.pop([i]) | ||
| from the end | $var=pop(@coins); | a=list.pop() | ||
| sort | sort { $a <=> $b } keys(%hash) | @array2 = reverse sort (@array); | sorted([5, 2, 3, 1, 4]) list.sort() list.reverse() | |
| sort (unique value) | my @s = uniq sort @a; | |||
| join/split | $firststring = join(", ",@array); @array = split('-',$astring); | |||
| index | list.index(var) #find the first ele that match var | |||
| ref | my $hash_ref = {}; $href->{ $key } = $value; | ref_list=true_list | ||
Tuesday, May 26, 2009
perl vs xml vs excel
use Spreadsheet::ParseExcel;
use XML::DOM;
my $doc = XML::DOM::Document->new;
my $xml_pi = $doc->createXMLDecl ('1.0',"UTF-8","yes");
$doc->setXMLDecl($xml_pi);
my $root = $doc->createElement('tests');
$root->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
my $parser = Spreadsheet::ParseExcel->new(
CellHandler => \&cell_handler,
NotSetCell => 1
);
my $workbook = $parser->Parse($filename);
$root->printToFile ($outFile);
use XML::DOM;
my $doc = XML::DOM::Document->new;
my $xml_pi = $doc->createXMLDecl ('1.0',"UTF-8","yes");
$doc->setXMLDecl($xml_pi);
my $root = $doc->createElement('tests');
$root->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
my $parser = Spreadsheet::ParseExcel->new(
CellHandler => \&cell_handler,
NotSetCell => 1
);
my $workbook = $parser->Parse($filename);
$root->printToFile ($outFile);
exit(0);
sub cell_handler {
my $workbook = $_[0];
my $sheet_index = $_[1];
my $row = $_[2];
my $col = $_[3];
my $cell = $_[4];
my $myTag;
my $myText;
$testName=$cell->value();
if ($testName !~ m{\w+\.sv}) {$testName = ""; $lastCol = -1; return;}
$test = $doc->createElement('Test');
$myTag = $doc->createElement('Name');
$myText = $doc->createTextNode($cell->value());
$myTag->appendChild($myText); #set text content for this tag
$test->appendChild($myTag);
if ($implemented == 1) { $root->appendChild($test); } # add new entry only if it's new line
}
Monday, May 25, 2009
install perl module as non-root
perl Makefile.PL, make, make test, make install
The standard way to install a Perl module on Unix is to change into the directory that was created when you unpacked the .tar.gz file, and then type the following sequence of commands:
perl Makefile.PL
make
make test
make install
This will create a makefile for you, then compile the module, test it, and put it in the correct location for you. This requires that you are logged in as root, so that you can copy files to the Perl library directory, and various other places on your system where the installation will put files.
If you do not have root permissions on the machine where you want to install the module, such as if you wish to install a module in your home directory, just change one of those commands. Instead of
perl Makefile.PL
type
#perl Makefile.PL PREFIX=/path/to/where/you/want/it
perl Makefile.PL INSTALL_BASE=/path/to/where/you/want/it
make install
That will put all the files in that directory. In order to use modules that are stored in that location, you will need to add the following like to your Perl programs:
use lib "/path/to/where/you/want/it/perl5"
and, yes, thanks for the comment, local::lib might be easier to install a new module.
use local::lib "/path/to/where/you/want/it/perl5"
The standard way to install a Perl module on Unix is to change into the directory that was created when you unpacked the .tar.gz file, and then type the following sequence of commands:
perl Makefile.PL
make
make test
make install
This will create a makefile for you, then compile the module, test it, and put it in the correct location for you. This requires that you are logged in as root, so that you can copy files to the Perl library directory, and various other places on your system where the installation will put files.
If you do not have root permissions on the machine where you want to install the module, such as if you wish to install a module in your home directory, just change one of those commands. Instead of
perl Makefile.PL
type
#perl Makefile.PL PREFIX=/path/to/where/you/want/it
perl Makefile.PL INSTALL_BASE=/path/to/where/you/want/it
make install
That will put all the files in that directory. In order to use modules that are stored in that location, you will need to add the following like to your Perl programs:
use lib "/path/to/where/you/want/it/perl5"
and, yes, thanks for the comment, local::lib might be easier to install a new module.
use local::lib "/path/to/where/you/want/it/perl5"
Tuesday, December 30, 2008
systemverilog wordfile
copied from http://avm-users.googlegroups.com/web/systemverilog.txt?hl=en&gsc=Lb4u6AsAAADWzOiV2TvclJOPyNlia6Gs
/L20"Verilog 1364-2001" Line Comment = // Block Comment On = /* Block Comment Off = */ String Chars = " File Extensions = SV SVL/Delimiters = ~!@%^&*()-+=|\/{}[]:;"<> , .?#/Function String = "%[a-z0-9]+[ ^t]+[a-z_0-9]+[ ^t]+("
/Indent Strings = "begin" "fork" "specify" "config"
/Unindent Strings = "end" "join" "join_any" "join_none" "endspecify" "endconfig"
/C1"Keywords"
alias always always_comb always_ff always_latch and assert assign assume automatic
before begin bind bins binsof bit break buf bufif0 bufif1 byte
case casex casez cell chandle class clocking cmos config const constraint context continue cover covergroup coverpoint cross
deassign default defparam design disable dist do
edge else end endcase endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event expect export extends extern
final first_match for force foreach forever fork forkjoin function
generate genvar
highz0 highz1
if iff ifnone ignore_bins illegal_bins import incdir include initial inout input inside instance int integer interface intersect join
join_any join_none
large liblist library local localparam logic longint
macromodule matches medium modport module
nand negedge new nmos nor noshowcancelled not notif0 notif1 null
or output
package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect pure
rand randc randcase randsequence rcmos real realtime ref reg release repeat return rnmos rpmos rtran rtranif0 rtranif1
scalared sequence shortint shortreal showcancelled signed small solve specify specparam static string strong0 strong1 struct super supply0 supply1
table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef
union unique unsigned use
var vectored virtual void
wait wait_order wand weak0 weak1 while wildcard wire with within wor
xnor xor
/C2"System"
** 'b 'B 'o 'O 'd 'D 'h 'H 'sb 'sB 'so 'sO 'sd 'sD 'sh 'sH 'Sb 'SB 'So 'SO 'Sd 'SD 'Sh 'SH
** _
$assertkill $assertoff $asserton $async$and$array $async$nand$array $async$or$array $async$nor$array $async$and$plane $async$nand$plane $async$or$plane $async$nor$plane
$bits $bitstoreal $bitstoshortreal
$cast $comment $countdrivers $countones
$date $dimensions $display $displayb $displayh $displayo $dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t $dist_uniform $dumpall $dumpflush $dumpfile $dumplimit $dumpoff $dumpon $dumpports $dumpportsall $dumpportsflush $dumpportslimit $dumpportsoff $dumpportson $dumpvars
$enddefinitions $error $exit
$fatal $fdisplay $fdisplayf $fdisplayb $fdisplayh $fdisplayo $fell $feof $ferror $fflush $fgetc $fgets $finish $fopen $fmonitor $fmonitorb $fmonitorf $fmonitorh $fmonitoro $fclose $fread $fscanf $fseek $fsscanf $fstrobe $fstrobeb $fstrobef $fstrobeh $fstrobeo $ftell $fullskew $fwrite $fwriteb $fwritef $fwriteh $fwriteo
$get_coverage $getpattern
$high $hold $history
$increment $incsave $info $input $isunbounded $isunknown $itor
$key
$left $list $load_coverage_db $log $low
$monitor $monitorb $monitorh $monitoro $monitoron $monitoroff
$nochange $nokey $nolog $onehot $onehot0
$past $period $printtimescale
$q_add $q_exam $q_full $q_initialize $q_remove $q_random
$random $readmemb $readmemh $realtime $realtobits $recovery $recrem $removal $reset $reset_count $reset_value $restart $rewind $right $root $rose $rtoi
$sampled $save $scale $scope $sdf_annotate $set_coverage_db_name $setup $setuphold $sformat $shortrealtobits $showvariables $showscopes $showvars $signed $size $skew $sreadmemb $sreadmemh $sscanf $stable $stime $stop $strobe $strobeb $strobeh $strobeo $swrite $swriteb $swriteh $swriteo $sync$and$array $sync$nand$array $sync$or$array $sync$nor$array $sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane
$test$plusargs $time $timeformat $timescale $timeskew $typename $typeof
$ungetc $unit $unpacked_dimensions $unsigned $upscope $urandom $urandom_range
$value$plusargs $var $vcdclose $version
$warning $width $write $writeb $writeh $writeo $writememb $writememh
/C3"Operators"
->
+:
-:
@
@*
*>
,
;
.*
{
}
+
-
// /
*
**
%
>
>=
>>
>>>
<
<=
<<
<<<
!
!=
!==
&
&&
|
||
=
==
===
^
^~
~
~^
~&
~|
?
:
|->
|=>
/C4"Directives"
** `
`begin_keywords
`accelerate `autoexepand_vectornets
`celldefine
`default_nettype `define `default_decay_time `default_trieg_distributed `default_trireg_strength `delay_mode_distributed `delay_mode_path `delay_mode_unit `delay_mode_zero
`else `elsif `endcelldefine `endif `end_keywords `endprotect `endprotected `expand_vectornets
`file
`ifdef `ifndef `include
`line
`noaccelerate `noexpand_vectornets `noremove_gatenames `noremove_netnames `nounconnected_drive
`pragma `protect `protected
`remove_gatenames `remove_netnames `resetall
`timescale
`unconnected_drive `undef `uselib
/C5"DelaysAndParameters"
#
##
/L20"Verilog 1364-2001" Line Comment = // Block Comment On = /* Block Comment Off = */ String Chars = " File Extensions = SV SVL/Delimiters = ~!@%^&*()-+=|\/{}[]:;"<> , .?#/Function String = "%[a-z0-9]+[ ^t]+[a-z_0-9]+[ ^t]+("
/Indent Strings = "begin" "fork" "specify" "config"
/Unindent Strings = "end" "join" "join_any" "join_none" "endspecify" "endconfig"
/C1"Keywords"
alias always always_comb always_ff always_latch and assert assign assume automatic
before begin bind bins binsof bit break buf bufif0 bufif1 byte
case casex casez cell chandle class clocking cmos config const constraint context continue cover covergroup coverpoint cross
deassign default defparam design disable dist do
edge else end endcase endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event expect export extends extern
final first_match for force foreach forever fork forkjoin function
generate genvar
highz0 highz1
if iff ifnone ignore_bins illegal_bins import incdir include initial inout input inside instance int integer interface intersect join
join_any join_none
large liblist library local localparam logic longint
macromodule matches medium modport module
nand negedge new nmos nor noshowcancelled not notif0 notif1 null
or output
package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect pure
rand randc randcase randsequence rcmos real realtime ref reg release repeat return rnmos rpmos rtran rtranif0 rtranif1
scalared sequence shortint shortreal showcancelled signed small solve specify specparam static string strong0 strong1 struct super supply0 supply1
table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef
union unique unsigned use
var vectored virtual void
wait wait_order wand weak0 weak1 while wildcard wire with within wor
xnor xor
/C2"System"
** 'b 'B 'o 'O 'd 'D 'h 'H 'sb 'sB 'so 'sO 'sd 'sD 'sh 'sH 'Sb 'SB 'So 'SO 'Sd 'SD 'Sh 'SH
** _
$assertkill $assertoff $asserton $async$and$array $async$nand$array $async$or$array $async$nor$array $async$and$plane $async$nand$plane $async$or$plane $async$nor$plane
$bits $bitstoreal $bitstoshortreal
$cast $comment $countdrivers $countones
$date $dimensions $display $displayb $displayh $displayo $dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t $dist_uniform $dumpall $dumpflush $dumpfile $dumplimit $dumpoff $dumpon $dumpports $dumpportsall $dumpportsflush $dumpportslimit $dumpportsoff $dumpportson $dumpvars
$enddefinitions $error $exit
$fatal $fdisplay $fdisplayf $fdisplayb $fdisplayh $fdisplayo $fell $feof $ferror $fflush $fgetc $fgets $finish $fopen $fmonitor $fmonitorb $fmonitorf $fmonitorh $fmonitoro $fclose $fread $fscanf $fseek $fsscanf $fstrobe $fstrobeb $fstrobef $fstrobeh $fstrobeo $ftell $fullskew $fwrite $fwriteb $fwritef $fwriteh $fwriteo
$get_coverage $getpattern
$high $hold $history
$increment $incsave $info $input $isunbounded $isunknown $itor
$key
$left $list $load_coverage_db $log $low
$monitor $monitorb $monitorh $monitoro $monitoron $monitoroff
$nochange $nokey $nolog $onehot $onehot0
$past $period $printtimescale
$q_add $q_exam $q_full $q_initialize $q_remove $q_random
$random $readmemb $readmemh $realtime $realtobits $recovery $recrem $removal $reset $reset_count $reset_value $restart $rewind $right $root $rose $rtoi
$sampled $save $scale $scope $sdf_annotate $set_coverage_db_name $setup $setuphold $sformat $shortrealtobits $showvariables $showscopes $showvars $signed $size $skew $sreadmemb $sreadmemh $sscanf $stable $stime $stop $strobe $strobeb $strobeh $strobeo $swrite $swriteb $swriteh $swriteo $sync$and$array $sync$nand$array $sync$or$array $sync$nor$array $sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane
$test$plusargs $time $timeformat $timescale $timeskew $typename $typeof
$ungetc $unit $unpacked_dimensions $unsigned $upscope $urandom $urandom_range
$value$plusargs $var $vcdclose $version
$warning $width $write $writeb $writeh $writeo $writememb $writememh
/C3"Operators"
->
+:
-:
@
@*
*>
,
;
.*
{
}
+
-
// /
*
**
%
>
>=
>>
>>>
<
<=
<<
<<<
!
!=
!==
&
&&
|
||
=
==
===
^
^~
~
~^
~&
~|
?
:
|->
|=>
/C4"Directives"
** `
`begin_keywords
`accelerate `autoexepand_vectornets
`celldefine
`default_nettype `define `default_decay_time `default_trieg_distributed `default_trireg_strength `delay_mode_distributed `delay_mode_path `delay_mode_unit `delay_mode_zero
`else `elsif `endcelldefine `endif `end_keywords `endprotect `endprotected `expand_vectornets
`file
`ifdef `ifndef `include
`line
`noaccelerate `noexpand_vectornets `noremove_gatenames `noremove_netnames `nounconnected_drive
`pragma `protect `protected
`remove_gatenames `remove_netnames `resetall
`timescale
`unconnected_drive `undef `uselib
/C5"DelaysAndParameters"
#
##
System Verilog by example by example
System Verilog by example(constraint, random, covergroup)
module top;
typedef enum bit { BAD_PARITY, GOOD_PARITY } parity_e;
class packet_c;
rand bit [5:0] pkt_length;
bit[63:0][7:0] pkt_payload;
bit[7:0] parity;
rand parity_e parity_type;
function bit [7:0] calc_parity();
calc_parity = { pkt_length, pkt_addr };
for (int i = 0; i calc_parity ^= pkt_payload[i];
endfunction :calc_parity
function void randomize_payload();
pkt_addr = $urandom ;
pkt_length = $urandom ;
for (int i=0; i < pkt_length; i ++)
pkt_payload[i]= $urandom;
endfunction:randomize_payload
function void post_randomize();
randomize_payload();
if (parity_type == GOOD_PARITY)
parity = calc_parity();
else
do
parity = $urandom;
while (parity == calc_parity());
endfunction:post_randomize
endmodule
class packet_c;
typedef enum bit { BAD_PARITY , GOOD_PARITY } parity_e;
typedef enum bit[1:0] { SMALL,MEDIUM, LARGE } payload_e;
constraint c { parity_type == GOOD_PARITY ;}
constraint c1 { payload_type == LARGE ;}
constraint c3 { pkt_addr == 2; }
constraint length_range {
(payload_type == SMALL) -> pkt_length inside { [1 : 20] };
(payload_type == MEDIUM) -> pkt_length inside { [21 : 44]};
(payload_type == LARGE) -> pkt_length inside { [45 : 63]};
}
// Define the Coverage module for the packet defined
covergroup cg @ (pkt_event);
coverpoint pkt_length {
bins usb_range = {[0 : 20]};
bins pci_range = {[21 : 44]};
bins ahb_range = {[45 : 63 ]};
}
coverpoint pkt_addr;
coverpoint parity;
endgroup
module top;
typedef enum bit { BAD_PARITY, GOOD_PARITY } parity_e;
class packet_c;
rand bit [5:0] pkt_length;
bit[63:0][7:0] pkt_payload;
bit[7:0] parity;
rand parity_e parity_type;
function bit [7:0] calc_parity();
calc_parity = { pkt_length, pkt_addr };
for (int i = 0; i
endfunction :calc_parity
function void randomize_payload();
pkt_addr = $urandom ;
pkt_length = $urandom ;
for (int i=0; i < pkt_length; i ++)
pkt_payload[i]= $urandom;
endfunction:randomize_payload
function void post_randomize();
randomize_payload();
if (parity_type == GOOD_PARITY)
parity = calc_parity();
else
do
parity = $urandom;
while (parity == calc_parity());
endfunction:post_randomize
endmodule
class packet_c;
typedef enum bit { BAD_PARITY , GOOD_PARITY } parity_e;
typedef enum bit[1:0] { SMALL,MEDIUM, LARGE } payload_e;
constraint c { parity_type == GOOD_PARITY ;}
constraint c1 { payload_type == LARGE ;}
constraint c3 { pkt_addr == 2; }
constraint length_range {
(payload_type == SMALL) -> pkt_length inside { [1 : 20] };
(payload_type == MEDIUM) -> pkt_length inside { [21 : 44]};
(payload_type == LARGE) -> pkt_length inside { [45 : 63]};
}
// Define the Coverage module for the packet defined
covergroup cg @ (pkt_event);
coverpoint pkt_length {
bins usb_range = {[0 : 20]};
bins pci_range = {[21 : 44]};
bins ahb_range = {[45 : 63 ]};
}
coverpoint pkt_addr;
coverpoint parity;
endgroup
Monday, December 1, 2008
水仙养殖
宝贝名称:水仙种球(别名:凌波仙子、玉玲珑、金盏银台等)
宝贝特点:为石蒜科多年生草本。地下部分的鳞茎肥大似洋葱,卵形至广卵状球形,外被棕褐色皮膜。叶狭长带状,二列状着生。花葶中空,扁筒状,通常每球有花葶数支,多者可达10余支,每葶数支,至10余朵,组成伞房花序。
栽培方法:栽培水仙有水培法和土培法两种方法。
一:水培法:即用浅盆水浸法培养。将水仙直立放入水仙浅盆中,加水淹没鳞茎三分之一的为宜。盆中可用石英砂 、鹅卵石等将鳞茎固定。
阳光:白天要放置在阳光充足的地方,夜晚可放在灯光下;
温度:以10-15度为宜,过低(4度以下)容易发生冻害,过高(20度以上)容易发生徒长;
换水:刚上盆时,水仙可每日换一次水,以后每2-3天换一次,花苞形成后,每周换一次水。为防止叶片徒长,最好是傍晚把盆水倒尽,次日清晨再加清水;
花期调控:一般水仙从上盆到开花约45天,但通过适当调控,可以在28天内至60天左右开花,比如节前10天还未看到饱满花苞,可改用接近体温的温水浸泡,并适当添加营养液催花;若想延长开花时间,则可将水仙放至温度较低处4-5度,适当控水等;
按照以上方法,可使水仙叶短宽厚、茁壮,叶色浓绿,花开香浓。水养水仙,一般不需要施肥,如有条件,在开花期间稍施一些速效磷肥,花可开得更好。
二:土培法:准备肥沃的沙质土壤,将水仙种球栽入一半露出一半,鳞下面应事先垫一些细沙,以利排水。把花盆置于阳光充足、温度适宜的室内。以4至12℃为好,温度过低容易发生冻害,温度过高再加之光照不足,容易陡长,植株细弱,开花时间短暂,降低观赏价值。管理中如果满足光照和温度的要求,则叶片肥大,花莛粗壮,因而能使花朵开得大,芳香持久。土培水仙,可在开花前追施二至三次液肥。
宝贝特点:为石蒜科多年生草本。地下部分的鳞茎肥大似洋葱,卵形至广卵状球形,外被棕褐色皮膜。叶狭长带状,二列状着生。花葶中空,扁筒状,通常每球有花葶数支,多者可达10余支,每葶数支,至10余朵,组成伞房花序。
栽培方法:栽培水仙有水培法和土培法两种方法。
一:水培法:即用浅盆水浸法培养。将水仙直立放入水仙浅盆中,加水淹没鳞茎三分之一的为宜。盆中可用石英砂 、鹅卵石等将鳞茎固定。
阳光:白天要放置在阳光充足的地方,夜晚可放在灯光下;
温度:以10-15度为宜,过低(4度以下)容易发生冻害,过高(20度以上)容易发生徒长;
换水:刚上盆时,水仙可每日换一次水,以后每2-3天换一次,花苞形成后,每周换一次水。为防止叶片徒长,最好是傍晚把盆水倒尽,次日清晨再加清水;
花期调控:一般水仙从上盆到开花约45天,但通过适当调控,可以在28天内至60天左右开花,比如节前10天还未看到饱满花苞,可改用接近体温的温水浸泡,并适当添加营养液催花;若想延长开花时间,则可将水仙放至温度较低处4-5度,适当控水等;
按照以上方法,可使水仙叶短宽厚、茁壮,叶色浓绿,花开香浓。水养水仙,一般不需要施肥,如有条件,在开花期间稍施一些速效磷肥,花可开得更好。
二:土培法:准备肥沃的沙质土壤,将水仙种球栽入一半露出一半,鳞下面应事先垫一些细沙,以利排水。把花盆置于阳光充足、温度适宜的室内。以4至12℃为好,温度过低容易发生冻害,温度过高再加之光照不足,容易陡长,植株细弱,开花时间短暂,降低观赏价值。管理中如果满足光照和温度的要求,则叶片肥大,花莛粗壮,因而能使花朵开得大,芳香持久。土培水仙,可在开花前追施二至三次液肥。
Wednesday, November 19, 2008
led vs ccfl
。在视频领域,人们一般用NTSC作为衡量视频设备的色彩还原特性的标准。这个指标是指在整个色彩空间内,显示设备能在各种色彩上显示到何种饱和度,就是能够显示显眼到什么程度的蓝色、绿色、红色。对于传统的液晶电视和显示器而言,能够覆盖的色域范围只有NTSC标准的65%~75%。如果我们仔细观察其色域曲线,就会发现在绿色、黄色和红色部分和标准距离较远。因此,传统液晶电视的色彩范围较小,难以完美呈现绿草、大海等自然场景。
我们知道,液晶显示器本身不会发光,它依靠背光源将光线穿过显示面板,展现图形图像。因此,背光源的技术直接影响到液晶电视的画质。传统的液晶显示器通常采用冷阴极荧光灯(cold cathode fluorescent lamps,CCFL)作为光源,而正是CCFL造成了液晶显示器颜色不够丰富,色彩还原度差。我们再看Sony QUALIA005系列电视机,它把液晶电视的色域范围扩展到NTSC标准的105%,基本上可以重现我们所有观察到的自然界场景。其核心就是使用LED背光源替代传统的CCFL背光源。
LED背光技术领先优势
LED作为LCD的背光源,与传统背光技术相比,除了在色域范围的优势外,还有很多独特的优点,归纳为十个方面:
1)LED背光源有更好的色域。其色彩表现力强于CCFL背光源,可对显示色彩数量不足的液晶技术起到很好的弥补作用,色彩还原好;
2)LED的使用寿命可长达10万小时。即使每天连续使用10个小时,也可以连续用上27年,大大延长了液晶电视的使用寿命,可获得对等离子技术压倒性的优势;
3)亮度调整范围大。实现LED功率控制很容易,不像CCFL的最低亮度存在一个门槛。因此,无论在明亮的户外还是全黑的室内,用户都很容易把显示设备的亮度调整到最悦目的状态;
4)完美的运动图像。传统CCFL灯管的闪烁发光频率较低,表现动态场景可能产生画面跳动。LED背光可以灵活调整发光频率,而且频率大大高于CCFL,因此能完美地呈现运动画面;
5)实时色彩管理。由于红绿蓝3色独立发光,很容易精确控制目前的显示色彩特性;
6)可以调整的背光白平衡,同时保证整体对比度。当用户的视频源在计算机和DVD机间切换时,可以轻松在9600K和6500K间调整白平衡,而且不会牺牲亮度和对比度;
7)可以为大尺寸屏幕提供连续面阵光源。LED是一种平面状光源,最基本的发光单元是3~5mm边长的正方形封装后,极容易组合在一起成为既定面积的面光源,具有很好的亮度均匀性,如果作为液晶电视的背光源,所需的辅助光学组件可以做得非常简单,屏幕亮度均匀性更为出色;
8)安全。LED使用的是5~24V的低压电源,十分安全,供电模块的设计也颇为简单;
9)环保。LED光源没有任何射线产生,也没有水银之类的有毒物质,可谓是绿色环保光源;
10)抗震。平面状结构让LED拥有稳固的内部结构,抗震性能很出色。
表1、LED与CCFL对比
CCFL LED
色域 72% 105%
色温 固定 可变
频闪驱动 需要 不需要
上升/下降沿时间 500毫秒 20纳秒
寿命 5万小时 10万小时
功耗 110瓦 415瓦
厚度 32.5毫米 45毫米
灯/LED数量 16 455
(数据来源 :Samsung Electronics)
在液晶显示器已经成为主流显示器的今天,LED背光源凭借其独特、压倒性的优势,逐渐显示出强大的应用前景。
LED背光源现在存在的问题
LED背光技术就象许多新型技术一样拥有许多诱人的优点,但LED要想占据大尺寸LCD背光源的主流,目前还需要解决一些技术难点。通过表1的对比,我们已经发现LED在功耗方面处于劣势,除此之外还存在成本高、一致性差等问题。
1)LED的发光效率较低,与同等尺寸CCFL背光源相比耗电量高。目前CCFL的输出光通量多在5000~7000lm范围,实际屏幕的输出光通量高于300lm,而多数LED背光都还无法达到这一指标。不过,现在全球有大量的企业从事相关研究,LED发光效率提升相当之快,目前光通量达到10000lm 的高亮型LED背光也已经出现,相信离成熟仅是咫尺之遥。
2)成本太高、价格昂贵,同等尺寸的背光源,LED是CCFL价格的4倍。对于目前价格竞争激烈的市场而言,让厂家有些望而却步。只有索尼为了图像质量不计成本。当然,随着工艺的成熟和生产规模的增加,LED背光的成本会逐步下降。
3)用LED作为背光源存在白光的一致性问题,这比起CCFL是个劣势。
4)LED在网点设计上较线性光源CCFL难,需考虑LED辐射状的光强衰减。
5)RGB LED背光源时间一久会产生色移波长会随温度变化,产生不同颜色。
我们知道,液晶显示器本身不会发光,它依靠背光源将光线穿过显示面板,展现图形图像。因此,背光源的技术直接影响到液晶电视的画质。传统的液晶显示器通常采用冷阴极荧光灯(cold cathode fluorescent lamps,CCFL)作为光源,而正是CCFL造成了液晶显示器颜色不够丰富,色彩还原度差。我们再看Sony QUALIA005系列电视机,它把液晶电视的色域范围扩展到NTSC标准的105%,基本上可以重现我们所有观察到的自然界场景。其核心就是使用LED背光源替代传统的CCFL背光源。
LED背光技术领先优势
LED作为LCD的背光源,与传统背光技术相比,除了在色域范围的优势外,还有很多独特的优点,归纳为十个方面:
1)LED背光源有更好的色域。其色彩表现力强于CCFL背光源,可对显示色彩数量不足的液晶技术起到很好的弥补作用,色彩还原好;
2)LED的使用寿命可长达10万小时。即使每天连续使用10个小时,也可以连续用上27年,大大延长了液晶电视的使用寿命,可获得对等离子技术压倒性的优势;
3)亮度调整范围大。实现LED功率控制很容易,不像CCFL的最低亮度存在一个门槛。因此,无论在明亮的户外还是全黑的室内,用户都很容易把显示设备的亮度调整到最悦目的状态;
4)完美的运动图像。传统CCFL灯管的闪烁发光频率较低,表现动态场景可能产生画面跳动。LED背光可以灵活调整发光频率,而且频率大大高于CCFL,因此能完美地呈现运动画面;
5)实时色彩管理。由于红绿蓝3色独立发光,很容易精确控制目前的显示色彩特性;
6)可以调整的背光白平衡,同时保证整体对比度。当用户的视频源在计算机和DVD机间切换时,可以轻松在9600K和6500K间调整白平衡,而且不会牺牲亮度和对比度;
7)可以为大尺寸屏幕提供连续面阵光源。LED是一种平面状光源,最基本的发光单元是3~5mm边长的正方形封装后,极容易组合在一起成为既定面积的面光源,具有很好的亮度均匀性,如果作为液晶电视的背光源,所需的辅助光学组件可以做得非常简单,屏幕亮度均匀性更为出色;
8)安全。LED使用的是5~24V的低压电源,十分安全,供电模块的设计也颇为简单;
9)环保。LED光源没有任何射线产生,也没有水银之类的有毒物质,可谓是绿色环保光源;
10)抗震。平面状结构让LED拥有稳固的内部结构,抗震性能很出色。
表1、LED与CCFL对比
CCFL LED
色域 72% 105%
色温 固定 可变
频闪驱动 需要 不需要
上升/下降沿时间 500毫秒 20纳秒
寿命 5万小时 10万小时
功耗 110瓦 415瓦
厚度 32.5毫米 45毫米
灯/LED数量 16 455
(数据来源 :Samsung Electronics)
在液晶显示器已经成为主流显示器的今天,LED背光源凭借其独特、压倒性的优势,逐渐显示出强大的应用前景。
LED背光源现在存在的问题
LED背光技术就象许多新型技术一样拥有许多诱人的优点,但LED要想占据大尺寸LCD背光源的主流,目前还需要解决一些技术难点。通过表1的对比,我们已经发现LED在功耗方面处于劣势,除此之外还存在成本高、一致性差等问题。
1)LED的发光效率较低,与同等尺寸CCFL背光源相比耗电量高。目前CCFL的输出光通量多在5000~7000lm范围,实际屏幕的输出光通量高于300lm,而多数LED背光都还无法达到这一指标。不过,现在全球有大量的企业从事相关研究,LED发光效率提升相当之快,目前光通量达到10000lm 的高亮型LED背光也已经出现,相信离成熟仅是咫尺之遥。
2)成本太高、价格昂贵,同等尺寸的背光源,LED是CCFL价格的4倍。对于目前价格竞争激烈的市场而言,让厂家有些望而却步。只有索尼为了图像质量不计成本。当然,随着工艺的成熟和生产规模的增加,LED背光的成本会逐步下降。
3)用LED作为背光源存在白光的一致性问题,这比起CCFL是个劣势。
4)LED在网点设计上较线性光源CCFL难,需考虑LED辐射状的光强衰减。
5)RGB LED背光源时间一久会产生色移波长会随温度变化,产生不同颜色。
Tuesday, November 18, 2008
systemverilog keywords supported by synplify
Supported SystemVerilog Keywords:
always_comb, always_ff, always_latch, assert, bit byte, const, do, endinterface, enum, import, int, interface, logic, longint, modport, packed, priority, shortint, struct, typedef, unique.
Unsupported SystemVerilog Keywords:
assume, break, continue, endproperty, endsequence, expect, property, return, sequence, timeprecision, timeunit, union, void.
always_comb, always_ff, always_latch, assert, bit byte, const, do, endinterface, enum, import, int, interface, logic, longint, modport, packed, priority, shortint, struct, typedef, unique.
Unsupported SystemVerilog Keywords:
assume, break, continue, endproperty, endsequence, expect, property, return, sequence, timeprecision, timeunit, union, void.
Subscribe to:
Posts (Atom)