2008年10月19日星期日

Verilog学习笔记1

1.Verilog支持在不同抽象层建模,一个电路行为可以有多种不同的描述方式,但是,并不是每一种描述方式都是可被综合的。不可综合,也就是说,在物理上不可实现。
2.行为级描述方式不可综合。
3.RTL级建模是面向综合的设计,需要有实际的硬件电路与之对应。所以,对于RTL层次上的建模,最基本的思想就是"硬件意识"。即:在写代码的时候,大脑里要先想好完成的具体功能应该用什么样的物理电路去实现,然后用verilog语言将该电路描述出来,而不能凭空地去写代码,只有存在的电路才是可物理实现的。RTL级编码的过程原理:心中先有电路,再将它翻译成verilog代码。
4.电路在物理上是并行工作的。这个大家都知道,但是还是要注意:C语言程序的先后顺序是靠语句的排列顺序执行;但电路只要一上电,芯片内部各部分将同时工作。电路行为的先后顺序通过时钟节拍的顺序来体现。
5.人们常说的"输出三态"并不是指信号的输出除了0和1以外还有第三种状态(数字信号只有0和1),而是指芯片内外断开,互不影响。若总线上所有驱动源均停止驱动且无上拉or下拉电阻,则总线悬空,总线对地相当于一电容:如果关闭总线之前的输出为高电平,则有电容放电现象(总线残留的电荷流入地):如果关闭总线之前的输出为低电平,则用总线一直为低电平。若总线有上拉或者下拉电阻,则可以较快地被上拉到高电平or下拉到低电平,从而避免因电容缓慢放电而处于电平漂浮不定的情况。
当前主流FPGA结构中,除了I/O端口外,一般不支持内部三态,内部三态将被综合工具忽略。FPGA内部不允许对一个信号有多个驱动源,or一个驱动源输出为高电平而其他驱动源输出为低电平时将可能导致短路。
6.与三态端口相类似,FPGA内部没有双向端口,内部信号均为单一流向,输入输出需要用单独的信号表示,不能复用在一起;只有对应芯片接口的信号才能定义为双向端口。
7. RTL级编码中,正确使用阻塞与非阻塞的4个原则:
(1)带时钟的always模块使用非阻塞赋值;
(2)不带时钟的always模块使用阻塞赋值;
(3)连续赋值语句使用阻塞赋值;
(4)同一个always模块中不能同时出现阻塞赋值和非阻塞赋值;

PS:Modelsim的testbench仿真,一定要去掉优化,否则可能把信号优化没了
,显示不出你要观察的信号来。为此折腾了好几天,弱!

solve problems in the linux way

个人认为学习linux最重要的是要学会:1. linux是怎么解决问题的; 2.
用linux思考方式来解决使用中或实际中遇到的问题,想想linux下是怎么处理问题的,然后自己再想办法解决。而不是看windows下怎么解决,然后找linux下的对应版本or替代软件,尽量不要使用wine来解决问题。
但有2个问题我还没彻底解决:
1. linux下如何下载迅雷链接?
因为迅雷链接中查看不到具体下载链接,无法直接用wget下载。经研究,发现迅雷链接地址是对原始下载链接经过base64编码而成,相当于加密。既然加密,就有破密,而BASE64算法又是一个可逆的算法,因此就可以经过反编码得到真实的下载地址,然后用wget直接下载。
BASE64算法加密解密算法的转换工具,网上很多,下载使用即可。
也有在线加解密的,如:http://md5.mmkey.com/base64.php

但是,没那么简单,迅雷速度会是因为它搜索服务器上一切可用的种子/下载源来使用。其他工具都难望其项背。
so
linux下虽可下载使用迅雷链接,但速度都不太理想。linux下面缺乏一个彪悍的下载工具。

2.
linux下面没有可以比肩becky的邮件软件,用wine来运行becky,效果也不太理想。

Buy American. I Am. (Warren E. Buffett)

THE financial world is a mess, both in the United States and abroad. Its
problems, moreover, have been leaking into the general economy, and the
leaks are now turning into a gusher. In the near term, unemployment will
rise, business activity will falter and headlines will continue to be
scary.

So ... I've been buying American stocks. This is my personal account I'm
talking about, in which I previously owned nothing but United States
government bonds. (This description leaves aside my Berkshire Hathaway
holdings, which are all committed to philanthropy.) If prices keep looking
attractive, my non-Berkshire net worth will soon be 100 percent in United
States equities.

Why?

A simple rule dictates my buying: Be fearful when others are greedy, and
be greedy when others are fearful. And most certainly, fear is now
widespread, gripping even seasoned investors. To be sure, investors are
right to be wary of highly leveraged entities or businesses in weak
competitive positions. But fears regarding the long-term prosperity of the
nation's many sound companies make no sense. These businesses will indeed
suffer earnings hiccups, as they always have. But most major companies
will be setting new profit records 5, 10 and 20 years from now.

Let me be clear on one point: I can't predict the short-term movements of
the stock market. I haven't the faintest idea as to whether stocks will be
higher or lower a month — or a year — from now. What is likely, however,
is that the market will move higher, perhaps substantially so, well before
either sentiment or the economy turns up. So if you wait for the robins,
spring will be over.

A little history here: During the Depression, the Dow hit its low, 41, on
July 8, 1932. Economic conditions, though, kept deteriorating until
Franklin D. Roosevelt took office in March 1933. By that time, the market
had already advanced 30 percent. Or think back to the early days of World
War II, when things were going badly for the United States in Europe and
the Pacific. The market hit bottom in April 1942, well before Allied
fortunes turned. Again, in the early 1980s, the time to buy stocks was
when inflation raged and the economy was in the tank. In short, bad news
is an investor's best friend. It lets you buy a slice of America's future
at a marked-down price.

Over the long term, the stock market news will be good. In the 20th
century, the United States endured two world wars and other traumatic and
expensive military conflicts; the Depression; a dozen or so recessions and
financial panics; oil shocks; a flu epidemic; and the resignation of a
disgraced president. Yet the Dow rose from 66 to 11,497.

You might think it would have been impossible for an investor to lose
money during a century marked by such an extraordinary gain. But some
investors did. The hapless ones bought stocks only when they felt comfort
in doing so and then proceeded to sell when the headlines made them queasy.

Today people who hold cash equivalents feel comfortable. They shouldn't.
They have opted for a terrible long-term asset, one that pays virtually
nothing and is certain to depreciate in value. Indeed, the policies that
government will follow in its efforts to alleviate the current crisis will
probably prove inflationary and therefore accelerate declines in the real
value of cash accounts.

Equities will almost certainly outperform cash over the next decade,
probably by a substantial degree. Those investors who cling now to cash
are betting they can efficiently time their move away from it later. In
waiting for the comfort of good news, they are ignoring Wayne Gretzky's
advice: "I skate to where the puck is going to be, not to where it has
been."

I don't like to opine on the stock market, and again I emphasize that I
have no idea what the market will do in the short term. Nevertheless, I'll
follow the lead of a restaurant that opened in an empty bank building and
then advertised: "Put your mouth where your money was." Today my money and
my mouth both say equities.