2021年8月18日 星期三

【Windows】跳過商用PC螢幕保護程式

採用微軟系統管理方案的公司,出於保護公司資料的目的,螢幕會在設定時間後自動進入螢幕鎖定保護模式,使用者需鍵入密碼才能繼續使用電腦,但是,如果使用者是在家辦公的話,該功能就顯得浪費時間了。

一般而言,通常使用者無權更改螢幕保護程式的相關設定,如何能讓電腦不要進入保護模式呢?網路上有很多方法,包括使用特定軟體程式模擬MOUSE移動等。最後採用的簡易方案是一個POWER SHELL SCRIPT,keepawake.ps1。用POWER SHELL執行,簡單。


$wsh = New-Object -ComObject WScript.Shell
while (1) {
$wsh.SendKeys('+{F15}')
Start-Sleep -seconds 59
}

 

2020年5月11日 星期一

【VIM】以VIM做SV工具


VI(M)的使用經驗起自文字終端機的時代,包括最早的行編輯器,到全螢幕編輯。晚近則是ECO時手動修改NETLIST的經驗,一 般的EDITOR碰到體積龐大的NETLIST(印象好像是幾百MB,或是GB等級),會轉不過來,或轉不動,但是VI卻依然輕鬆自如。VIM號稱是Linux的標準瑞士刀,從小型的EMBEDDED裝置到各式PC(包括MACOS),伺服器,都可見其蹤影。桌面環境,包括Windows,也有GVIM(視窗版)可用。可以說,以此一招,可以闖江湖矣!

最近的經驗是DDR4 Behavior Model的開發,環境則是 Red Hat Linux 桌面,這次算是比較長時間持續地使用,所以把VIM的一些經驗整理存參。

  • Motion
    • $                    ## end of the line
    • 0                    ## start of the line
    • ^                   ## the 1st none-space char of the line
    • g_                   ## last none-space char of the line
    • w,W               ## next word/WORD start
    • e,E                 ## next word/WORD end
    • b,B                ## prev word/WORD start
    • ge,gE            ## prev word/WORD end

    • G                   ## end of the file
    • gg                 ## start of the file
    • fC                  ## find right occurrence of `C` on the current line
    • FC                  ## find left occurrence of `C` on the current line
    • ;                     ## find again on the current line
    • :set number   ## show line number
    • :100               ## goto line 100
    • 100G             ## goto line 100
    • 3w                 ## next 3 word
    • /pattern        ## search pattern forwardly
    • ?pattern        ## search pattern backwardly
    • /\<word\>   ## search word matched
    • *,#                 ## search word matched at current cursor for/back
    • n                   ## search, next forward one
    • N                  ## search, next backward one
    • ctrl+F           ## page forward
    • ctrl+B           ## page backward

  • text object: chunk of text, word, sentence, and paragraph
    • aw     a word (includes surrounding white space)
    • iw   inner word (does not include surrounding white space)
    • it  Applies to everything in current xml/html tag
    • i{     Applies to everything inside nearest curly brackets
    • as      A sentence
    • is       inner sentence
    • ap    a paragraph
    • ip     inner paragraph


    •    
  • Verbs(Command)
    • x    Delete character under the cursor
    • r    Replace character under cursor with another character
    • s    Delete character under cursor and move to insert mode
    •  
    • d    Delete text specified by motion
    • c    Delete text specified by motion and go into insert mode
    • y    Yank (copy) text specified by motion
    • v    Visual selection(V for line vs. character)

  •  Combining Verbs with Motions
    • d$      delete to the end of the line
    • cf)   change through the next closing parentheses
    • yG      copy everything through the end of the file
    •  
    • ciw    change in word
    • daw  dele a word
    • ci(      change inner ()
    • yit      copy the contents of an html tag
    • yy      yanks the current line
    • dd     deletes the current line
    • cc      changes the current line

  • 一般型式
      • 一次:
      • 移動:
  •  
  •  
  •  
  •  

REF
  1.  Learning Vim in 2014: Vim as Language
  2. Learn vim For the Last Time: A Tutorial and Primer
  3. youtube, Mastering the Vim Language 
  4. MIT missing-semester lectures: Editors (Vim)
  5.  





2017年12月13日 星期三

【SV 學習筆記】multi-dimension associative array

DDR4 有不同的bank group, bank address, Model 以SV之associative array實作


parameter BG=4, BA=4;
logic [15:0] memory[BG][BA][int]; // BG, BA size const

foreach(memory[g, a]) // check array size
  $display(g,"  ", a, memory[g][a].size);

2011年2月27日 星期日

Successful Stories Open Source Business

Open Source Software and Open Source Product Design

How to leverage:
1. open source software, (most of player created some dedicated sw on top of open source sw, besides service and contract business)

2. power of community

3. open source business model, sucessful story


3.1 CollabNet
OpenSource Thought Leader and CollabNet Founder Brian Behlendorf http://www.sramanamitra.com/2008/04/07/distributed-development simplified-collabnet-founder-brian-behlendorf-part-1/


  • 利用OPEN SOURCE SW,低成本優勢,創設新公司
  • Brisbane, Calif.-based CollabNet
    Collaboration software, Subversion, www.collab.net, fund: Benchmark Capital in July of 1999.

    The term free software made it sound like an anti-capitalist movement, yet the reality is we were hardcore capitalists. We liked a lot of the attributes of that type of software and felt a re-branding effort was needed. That is when the term OpenSource was coined.

    "how the community formed, how it accomplished tasks, how it made decisions and what tools were needed to support the effort."

    Appache share: 65%

    Red Hat emerging as support organizations

    to do in more abstract form. My goal was to distill it down to a science, make it repeatable, and take the answer to the rest of the software industry.

    software as a service, charge per user per month

    Product strategy: Any Subversion is all of Subversion, open source. Instead, CollabNet provides another, larger product: CollabNet TeamForge, a product that would be much less valuable without Subversion (which is what justifies our investwith ment), but clearly a different product providing integration with commercial tools.
3.2 SpringSource
enterprise Java
We had five founders, and we bootstrapped the company with consultancy.

  • consulting and training
    Writing the book,  to help build my personal brand as a consultant. 
  • At first with Spring it was the same mentality, but it rapidly became apparent that it was at another level. Downloads went from tens of thousands to hundreds of thousands to millions.
  • Fundamentally our model is one that recognizes that the OpenSource software is great. It is better than any other alternatives, but we provide things around it which make Spring better, and we charge for those additions.
3.3 SugarCRM
From Dyslexia to SugarCRM: John Roberts
http://www.sramanamitra.com/2008/12/11/5178/
  • I started looking at business two ways. There is the traditional way, which is to hire engineers, get product managers, write your MRD, and because you are the smartest people on earth you build it in secret and launch it with an expensive sales force. I started to question that process. Does that manufacturing process really result in the highest quality, most innovative software on the planet?

  • The mentality was that geeks were not going to be interested in things which solved business problems.

  • We all resigned together and started SugarCRM on April 10, 2004, without any angel or VC money. It was the three of us, each in his own house with headphones on, writing and designing code and posting it up on SourceForge.net. We did that for three months.

    We chose to give away everything we wrote from scratch. Meanwhile we had mortgage payments and three pregnant wives. We had no income, and we were giving away everything we were working on.

    When people found out we were OpenSource there was hesitancy.
  • The three editions are Sugar OpenSource, otherwise known as the Community Edition, which is totally free. The second edition is Sugar Professional, which is sold under a subscription similar to RedHat Enterprise Linux. The difference is we own the copyright. We provide a one-page commercial license that says not to redistribute it. We also have our Enterprise Edition, which has about 25% more functionality. It also comes with support and training, both on-site and on-demand.
3.4 XMIND
open source free mind map software with 2 edition
1. free
2. time-limited per user charge

WebCollection

1. Building a standard micro architecture, Cortex Microcontroller Software Interface Standard (CMSIS)
(http://www.embedded-europe.com/showArticle.jhtml;jsessionid=52MYK5GTZ4AGDQE1GHPSKHWATMY32JVN?articleID=220301398ARM's )

2. Embedded Europe, ESD
http://www.embedded-europe.com/

3. FreeOpenEDASW
Fedora Electronic Lab, collection, integration in Fedora with a lot of open software
http://chitlesh.fedorapeople.org/FEL/

4. OpenCores
http://opencores.org/

5. Embedded OS




Ubuntu Altera Free Web Edition Installation


1. problem during install
>>export: 137: 3000.00: bad variable name

2. found a fix at Alter forum(root cause: dual core freq)
modify the following file, line 147
/altera/10.1/quartus/adm/qenv.sh
original:export QTB_CPU_FREQ=`cat /proc/cpuinfo | grep "cpu MHz" | cut -c 12-18 | uniq`
fix: export QTB_CPU_FREQ=`cat /proc/cpuinfo | grep "cpu MHz" | cut -c 12-18 | head -1`

3. install device package
altera/10.1/quartus/bin/quartus_sh  --qinstall -qda "10.1_quartus_free_linux/altera_installer/bin/../../devices/subscription/XXXX.qda" -show_qt_progress

## XXXX.qda, check uncompressed directory "device" 

4. environment variable,  .bashrc
export PATH=${PATH}:/home/tools/altera/10.1/modelsim_ase/bin
export PATH=${PATH}:/home/tools/altera/10.1/quartus/bin
xport QUARTUS_ROOTDIR_OVERRIDE=/home/tools/altera/10.1/quartus

## source
>>> .  ~/.bashrc

ModelSim


##  creates a design library
vlib work
## mapping between a logical library name and a directory by modifying the modelsim.ini file
vmap work work  
## compiles Verilog source code and SystemVerilog extensions into a
## specified working library (or to the work library by default
vlog  -work work tcounter.v 
             
vsim -f sim.f -do sim.do tcounter 
vsim -view counter.wlf 

===============
file: run
===============

vlog -incr  tcounter.v
vsim -f sim.f -do sim.do
===============
file: sim.f

===============

-c
-L  ../resource_library/parts_lib/
-wlf tcounter.wlf
test_counter
===============
file: sim.do
===============

run -all
quit -sim
===============
           
Ref
1. ModelSim User's Manual
2. ModelSim Reference Manual
3. ModelSim Tutorial

輔助殘障科技

【經濟日報╱編譯余曉惠/綜合外電】
2009.09.30
蘋果的語音提示系統VoiceOver可追溯自1980年代末,當時製造商試圖將「通用存取」(universal access)功能引進麥金塔系列電腦。「通用存取」一詞來自工程和設計界,意思是便於所有人使用,不限年齡、不受行動能力限制。

如今VoiceOver被應用在iPod Shuffle上,Shuffle原本因為螢幕太小無法顯示曲目,但去年3月蘋果推出可「唸」出曲目的新款機型,大受歡迎,第一周銷量較舊款上市時大增 51%。VoiceOver也被納入6月推出的第三代iPhone,使用者無須動手、只要開口就能啟動功能,對殘障者、機車騎士還有講求便利性者都大有助 益。

Nuance通訊公司的聲控軟體廣泛應用在個人電腦上,也獲諾基亞、三星、RIM等手機製造商用來生產聲控撥號手機;Nuance另 透過福特和微軟的合資公司Sync,將聲控系統應用在暢銷的GPS衛星導航系統,例如Garmin和TomTom,以及福特、水星(Mercury)與林 肯(Lincoln)汽車。

Google公司也搭上這波熱潮,該公司一名聽障工程師原先為YouTube網站影片發明字幕工具,後來Google靈機一動,在2008年底推出自動翻譯工具,讓使用者可即時翻譯YouTube 影片的字幕,支援多達50種語言,拓展了YouTube的市場。

美泰兒計劃10月推出的Mindflex遊戲,是根據原為協助殘障者用腦波感應器移動物品的技術。玩家只要戴上感應器專心控制動作,就能發動馬達,推動桌面的小塑膠球穿越重重障礙。專家認為,這項科技可望為玩具產業開啟新局。

加州科技諮詢公司創意策略的總裁巴加林(Tim Bajarin)認為,輔助殘障者的科技應用進入主流市場將蔚為風潮,因為「人口老化將帶動易上手的科技興起」。

老人放大鏡,掌上型電子放大鏡

http://www.ez66.com.tw/T5004ShowCmdyData?&y_SketchName=Sketch1-2_Hi178&y_KindId=949308&y_HrefId=156174&y_CompId=216&&y_MuId=


去賣場買東西是否常苦惱看不清產品標示? 拿起藥瓶卻看不清背後的食用說明? 報紙的字實在看得很辛苦?

沒問題,我們推薦一款超輕量的電子放大鏡,超輕量,就像一般PDA大小可以輕易放入口袋,最高可以放大至9倍,再小的字也看得的見,讓您從此不會遺漏重要資訊。


【使用時機】1. 在家時
    - 檢視藥瓶上之說明文字
    - 看書報
    - 看食譜的說明
    - 查電話號碼簿
    - 看手機上的簡訊
   



2. 購物逛街時
    - 檢視價格
    - 查看食品包裝上的營養成份
    - 簽信用卡帳單
    - 選樂透號碼
    - 在餐廳昏黃的燈光下看菜單
    - 閱讀旅遊簡介
    - 看電影院場次資訊



【產品特色】1.  輕巧可攜式設計    
主機僅重140公克(約4.8盎司),可輕易隨身攜帶,而且造型小巧,易於掌握

2. 容易使用   簡易明瞭的功能鍵,讓您第一次使用即上手。放大(+)、縮小(-),只要按一功能鍵即可。

3. 清晰可讀   有
全彩、灰階、正片及負片等四種模式,搭配3.6吋的超大螢幕,無論何種資料皆能輕易閱讀。

4. 超長閱讀時間   
內建充電電池,主機充飽電後可連續使用2.5小時。



【產品規格】

    放大倍率 : 3 - 9倍。可多段式調整倍數(3.6吋液晶螢幕)。
    顯示模式: 全彩、灰階、正片及負片等四種模式。
    提供書寫架/把手,讓您閱讀、書寫更便利。
    內建LED光源,並可控制開關。
    提供畫面定格功能。
    主機僅重140公克(約4.8盎司)。
    主機尺寸:11.5 X 8.0 X 2.0公分 ( 4.6” X 3.2” X 0.8” ).
    內建充電電池,主機充飽電後可連續使用2.5小時。

USB連接線、USB電源供應器、電視訊號連接線、攜帶包及防掉落吊環。

無扇葉電扇

將空 氣擠入一個寬僅1.3公釐的周邊沿 狹縫,當空氣通過圓圈時,運動的 空氣量增加15倍,速度提高至每小 時35公里,產生的氣流比一般電扇 的風更平穩
http://udn.com/NEWS/WORLD/WOR4/5192873.shtml

Electric Uni Cycle

Honda Revealed UniCycle in JP

ENERGY GLOBE World Award

1. ENERGY GLOBE World Award
http://www.energyglobe.com/en/award/latest-winners/nominierte-world-awards/air/


[ some interesting projects]

2010年5月6日 星期四

[Digest] 打造綠建築的5個關鍵技術

工業技術與資訊 2010/05/06
http://mag.udn.com/mag/newsstand/storypage.jsp?f_MAIN_ID=77&f_SUB_ID=4319&f_ART_ID=246618
綠建築的九大指標:生物多樣化、綠化量、基地保水、日常節能、二氧化碳減量、廢棄物減量、水資源、污水與垃圾改善、室內健康與環境。

技術1:高透光太陽能窗發電模組
技術2:晝光導光板
技術3:Smart window(可調光液晶玻璃)
技術4:軟性電致變色製程/軟性節能膜技術
技術5:REDDEX(防火材料)

2009年9月10日 星期四

是軟體、還是硬體設計?SW programmability of FPGA

2009-09-10
        關於FPGA的SOC化,一直是話題不斷,尤其是FPGA Vendors老是鼓吹ASIC設計終將被FPGA超越。的確,因研發成本、設計生產力(軟硬體)、工具等無法趕上先進製程的腳步,使得SOC的投入成本 高不可攀且回收風險充滿了不確定。未來的SOC,是否真的只有少數人能入場,其他人就只能停在成熟製程技術(據說經濟風暴已使得2nd tier foundry fab 產能滿載)或是靠向FPGA。雖然,直到今日FPGA仍然在cost, power, performance等因素上苦苦追趕主流SOC,當然所謂cost並不以單一售價來計算,FPGA仍有其優勢,尤其是非主流的小量開發。我看到也有一 些new startup,希望能做出GHz 的FPGA,可惜恐怕敵不過冰風暴。另外,如Atmel則推出hard core CPU+FPGA array, 客戶可以較低投入成本來設計ASIC。

        EEtimes有一篇文章,作者把SOC做了如下的類分;並給了一個術語,所謂Software Programmable Integrated Circuits。
>> pure porcessor(multi-core)
>> processor+HW accelerators
>> SOC+FPGA companion
>> FPGA+HW accelerators
>> pure FPGA SOC

        所 謂的Software Programmable指的是系統設計技術的變革,ESL?,傳統上所謂HW accelerators是指掛載於SOC bus 上之週邊,是獨立於processor之外的模組,這種設計方法需要做軟硬界面劃分,硬體實現大都使用RTL,軟體則以C語言為主。一般而言,如果不用現 成IP,會非常耗時。作者做了一個類比,說RTL設計相當於組合語言的等級,也就是說那是石器時代的技術了。有一種技術,類似於customized processor design, user定義功能、運算法則,比方用C語言, 工具自動生成對應的新指令及所需的HW accelerators,這將大大改變所謂SOC的設計方法。

        目前已經有一些公司在推廣這一類的工具了。影響所及,未來業界將不需要那麼多硬體工程師。今天的硬體(或系統)工程師未來可能只要使用C語言即可,就像今日只有極少數的軟體工程師會用組合語言一樣。

        當然,FPGA Vendors面臨的挑戰之一是當FPGA越來越大越複雜,在應用面,如何幫助User快速上手,或擴大User的domain base,使今日的軟體工程師或實驗室裡的科學家(量測,大量資料快速運算)或其他領域的工程師,都能利用FPGA的優點。 我注意到National Instrument 已經推出相對應的產品,號稱不用 HDL/RTL,即可做出所需硬體功能。 沒親身體驗過,細節不詳,但NI工具似乎皆以GUI設計,果如此將是一大變革。

        看來,未來不論是SOC 或 FPGA User 皆需要好的軟體工具及平台,幫助他們快速、便利地完成工作。

2009年7月9日 星期四

Measurment Accuracy and Precision

2009-07-09
        所謂 Accuracy and Precision 中文議成準確度與精確度,卻很難望文生義。

參考維基百科,http://en.wikipedia.org/wiki/Accuracy_and_precision,以圖說明較為清楚。

        文字可翻譯為:Accuracy 指與true value接近之程度;Precision 指量測之可重複(製)性。似乎仍不清楚,沒關係,看統計圖說,量測值分佈之平均值與true value之差距表示Accuracy ;而Precision 則是該分佈之偏差(deviation) 。

        另以打靶來比喻,比如說射擊1000發子彈後,觀察其子彈分佈,有幾種可能:
1. accurate and precise: 命中點集中在紅心附近,且集中
2. accurate but not precise: 命中點集中在紅心附近,但分散
3. not accurate but precise: 命中點偏離紅心,且集中
4. not accurate and not precise: 命中點偏離紅心,且分散

        故好的量測需要 accurate and precise。即不要有bias,且隨機性愈小愈好。

DMM規格
==Display Count(與resolution有關)
*3-3/4 digits, 6000 counts, (此地3/4指5, 0-000~5-999)
*4-1/2 digits, 20,000 counts(0-0000~1-9999)

==Accuracy
*±(0.3% + 1) Fluke 77 IV
*±(0.05%+1) Fluke 87 V
(此處±1 位可視為隨機量,%是相對於滿刻度,故訊號遠小於滿刻度時,accuracy將變差,且大檔位,如200V vs 20V,其誤差絕對值將變大)

        實務上,我們會關心accuracy,卻不一定重視precision。

2009年6月15日 星期一

I2C Slave

2009-06-15
/*
modified I2C salve design from
http://www.fpga4fun.com/I2C_2.html
1. Asynchronous design: ASIC or FPGA design option
2. 8 bits CSR RW interface: 0~15, address and control
3. PAD not included
4. Altera CPLD verified

RTL model
Module: i2c_salve, a I2C slave device which only supports sdt mode
Ref spec: Rev 03, 2007
This module is from www.fpga4fun.com

SDA HOLD TIME: ref NXP's spec.
A device must internally provide a hold time of at least 300 ns for the SDA signal (with respect to the
VIH(min) of the SCL signal) to bridge the undefined region of the falling edge of SCL.
*/
`timescale 1ns/10ps
`define D #1

module i2c_slave (porn, SCL, SDAin, SDA_OUT, i2c_writing, i2c_debug, csr_din, csr_dout, i2c_data_ptr, i2c_wr, rstn);

parameter I2C_ADR = 7'h27;

input porn;
input SCL;
input SDAin;
input [7:0] csr_dout;
input rstn;

output SDA_OUT;
output i2c_writing;
output [7:0] i2c_debug;
output [7:0] csr_din;
output [4:0] i2c_data_ptr;
output i2c_wr;

reg [4:0] i2c_data_ptr; // address pointer
reg incycle;
wire I2C_rstn, incycle_rstn, i2c_writing_i;

// Delay Line Here, this has to be taken care by manual
`ifdef FPGA // FPGA
wire SDA_in_d;
assign #300 SDA_in_d = SDAin;
/*
I2C start and stop conditions detection logic
That's the "black magic" part of this design...
We use two wires with a combinatorial loop
to detect the start and stop conditions
making sure these two wires don't get optimized away
*/
wire SDA_shadow /* synthesis keep = 1 */; // FPGA directive
wire start_or_stop /* synthesis keep = 1 */; // FPGA directive

assign #5 SDA_shadow =
(!porn) ? 1'b1 : (~SCL | start_or_stop) ? SDA_in_d : SDA_shadow;

assign start_or_stop =
~SCL? 1'b0 : (SDA_in_d ^ SDA_shadow);

`else // ASIC
i2c_line_det U_i2c_line_det
(.porn(porn), .SDAin(SDAin), .SDA_in_d(SDA_in_d), .SCL(SCL), .start_or_stop(start_or_stop));
`endif

// I2C reset, pure async, note: I2C is not a always-running clock.
assign I2C_rstn = porn & rstn & ~start_or_stop;
// incycle: starting from 1st neg SCL
always @(negedge SCL or negedge I2C_rstn)
if(!I2C_rstn)
incycle <= `D 1'b0; // either S or P or Sr
else if(~SDA_in_d) // detection bits sequence following start bit
incycle <= `D 1'b1;

// Now we are ready to count the I2C bits coming in
reg [3:0] bitcnt;// counts the I2C bits from 7 downto 0, plus an ACK bit
wire bit_DATA = ~bitcnt[3];// the DATA bits are the first 8 bits sent
wire bit_ACK = bitcnt[3]; // the ACK bit is the 9th bit sent
reg data_phase;

always @(negedge SCL or negedge I2C_rstn)
if(!I2C_rstn)
begin
bitcnt <= `D 4'h7; // the bit 7 is received first
data_phase <= `D 0;
end
else
begin
if(bit_ACK)
begin
bitcnt <= `D 4'h7; // reset to 0111 after 1000
data_phase <= `D 1; // 1st bit_ACK followed by data phase
end
else if (incycle)
bitcnt <= `D bitcnt - 4'h1;
end

// and detect if the I2C address matches our own
wire adr_phase = ~data_phase;
reg adr_match, op_read, got_ACK;
reg SDAr, i2c_writing;

// sample SDA on posedge since the I2C spec
// specifies as low as 0us hold-time on negedge

always @(posedge SCL) SDAr<=SDA_in_d;
reg [7:0] mem;
wire op_write = ~op_read;

always @(negedge SCL or negedge I2C_rstn)
if(!I2C_rstn) begin
got_ACK <= 0;
adr_match <= 1;
op_read <= 0;
i2c_data_ptr <= 0;
i2c_writing <= 0; // to aviod combi glitch
end
else if (incycle) begin // only active while incycle
if((adr_phase & bitcnt==7) && (SDAr!=I2C_ADR[6])) adr_match<=0;
if((adr_phase & bitcnt==6) && (SDAr!=I2C_ADR[5])) adr_match<=0;
if((adr_phase & bitcnt==5) && (SDAr!=I2C_ADR[4])) adr_match<=0;
if((adr_phase & bitcnt==4) && (SDAr!=I2C_ADR[3])) adr_match<=0;
if((adr_phase & bitcnt==3) && (SDAr!=I2C_ADR[2])) adr_match<=0;
if((adr_phase & bitcnt==2) && (SDAr!=I2C_ADR[1])) adr_match<=0;
if((adr_phase & bitcnt==1) && (SDAr!=I2C_ADR[0])) adr_match<=0;

if(adr_phase & bitcnt==0) op_read <= SDAr;
/* we monitor the ACK to be able to free the bus
when the master doesn't ACK during a read operation
HOST will send NACK prior to STOP according to spec.
*/
if(bit_ACK) got_ACK <= ~SDAr;
// shift register write
if((adr_match) & bit_DATA & data_phase & op_write)
mem[bitcnt] <= SDAr;
// inc ptr after add phase
if((adr_match) & bit_ACK & data_phase )
i2c_data_ptr <= i2c_data_ptr + 1;

i2c_writing <= i2c_writing_i;
end


assign i2c_wr = adr_match & data_phase & op_write & bit_ACK;
// changed to SCL sync design

assign csr_din = mem;

// and drive the SDA line when necessary.
wire data_bit_low = ~csr_dout[bitcnt[2:0]];
wire SDA_assert_low =
adr_match & bit_DATA & data_phase & op_read & data_bit_low & got_ACK;

wire SDA_assert_ACK = (adr_match ) & bit_ACK & (adr_phase | op_write);
wire SDA_low = SDA_assert_low | SDA_assert_ACK;

assign SDA_OUT = SDA_low;
// PAD Implementation
// assign SDA = SDA_low ? 1'b0 : 1'bz;



assign i2c_writing_i = adr_match & data_phase & op_write & incycle;
// ref spec section, I2C interface. i2c_writing will go back to standby.

assign i2c_debug = {bitcnt[3:0], 2'b00, op_read, start_or_stop};

endmodule

module i2c_line_det ( SDAin, SDA_in_d, SCL, start_or_stop, porn );
input SDAin, SCL, porn;
output SDA_in_d, start_or_stop;
wire SDA_shadow, n2, n3;
wire n2d, n2d1, n2d2, n2dd;

`ifdef _RTL // for RTL sim only, since w/o delay in gate lib
assign #10 SDA_in_d = SDAin;
assign #5 SDA_shadow = (!porn) ? 1'b1 : (~SCL | start_or_stop) ? SDA_in_d : SDA_shadow;
assign start_or_stop = ~SCL? 1'b0 : (SDA_in_d ^ SDA_shadow);

`else

DEL5 U11 ( .A(SDAin), .Y(SDA_in_d1) );
DEL5 U12 ( .A(SDA_in_d1), .Y(SDA_in_d2));
DEL5 U13 ( .A(SDA_in_d2), .Y(SDA_in_d));
// latch with active low preset
LATCH_1X SDA_shadow_reg ( .PRSTN(porn), .D(SDA_in_d), .EN(n3), .Q(SDA_shadow) );
INV_1X U9 (.A(SCL), .Y(SLCn));
NAND2_1X U10 ( .A(SCLn), .B(n2), .Y(start_or_stop) );

// to keep minimum pulse width
DEL5 U1 (.A(n2), .Y(n2d));
BUF1 U2 (.A(n2d), .Y(n2d1));
BUF1 U3 (.A(n2d1), .Y(n2d2));
BUF1 U4 (.A(n2d2), .Y(n2d3));
BUF1 U5 (.A(n2d3), .Y(n2d4));
BUF1 U6 (.A(n2d4), .Y(n2dd));
//
AND2_1X U7 ( .A(n2dd), .B(SCL), .Y(n3) );
NOR2_1X U8 ( .A(SDA_in_d), .B(SDA_shadow), .Y(n2) );

`endif
endmodule

module LATCH_1X(PRSTN, D, EN, Q);
input PRSTN, D, EN;
output Q;

udp_ldlatch_p0 P1 (.q(Q), .d(D), .en(EN), .clear(1'b1), .preset(PRSTN));

endmodule
primitive udp_ldlatch_p0(q, d, en, clear, preset);

output q;
input d, en, clear, preset;
reg q;

table
// d en clear preset : state : q
? ? 0 ? : ? : 0;// clear to 0
? ? 1 0 : ? : 1;// preset to 1
0 1 1 1 : ? : 0;// on enable, transmit d
1 1 1 1 : ? : 1;// on enable, transmit d
? 0 1 1 : ? : -;// not enable, no change
? ? p 1 : ? : -;// ignore positive edge of clear
? ? 1 p : ? : -;// ignore positive edge of preset
endtable
endprimitive



module NOR2_1X (A, B, Y);
input A, B;
output Y;
assign #1 Y=!(A | B);
endmodule

module NAND2_1X (A, B, Y);
input A, B;
output Y;
assign #1 Y=!(A & B);
endmodule


module AND2_1X (A, B, Y);
input A, B;
output Y;
assign #1 Y=A &B;
endmodule

module INV_1X (A, Y);
input A;
output Y;
assign #1 Y=!A;
endmodule

module BUF1 (A, Y);
input A;
output Y;
assign #1 Y=A;
endmodule
module DEL5(A, Y);
input A;
output Y;
assign #5 Y= A;
endmodule

// CSR example
//
// write enable
assign csr_wr = i2c_wr;
assign csr_w_add = i2c_data_ptr;
assign csr_clk = SCL;

assign wr_csr00 = csr_wr & (csr_w_add == 5'h0);

// CSR00
always @(negedge porn or posedge csr_clk)
if (!porn)
csr00 <= `D cr00_iv;
else if (wr_csr00)
csr00 <= `D csr_din;

2009年3月30日 星期一

Dell NB inspiron 1420 換裝 Ubuntu 8.04

2009-03-30
        我的Dell NB inspiron 1420已過保固,裡頭附的是肥大的Vista Home Basic, 160GB HDD, 早想把它踢掉。於是買了個隨身硬碟 Fujitsu Wyvo, 320GB, $2350NT, 帶保固。店員聽我說是要替換NB內之硬碟,力勸我買零售的硬碟, 加USB盒(200NT),買了後才發現他的說法是正確的。第一, Fujitsu隨身硬碟拆了即不保固,第二,還真不好拆。事後,也懶得更換,就用吧。於是,Vista硬碟就被我換到USB盒裡了。

        "Taiwan Ubuntu 正體中文站"提供不少中文資訊,及國內下載點。剛開始裝的是 Kbuntu 8.10 64 bit,試用後發現kde 4 桌面過於華麗,且有軟體相容問題(如Skype官方只提供i386版本)。故還是回到Ubuntu 8.04.2 GNOME。

以下是安裝筆記:

1. System SW Update, 系統自動更新。

2. 取得lazybuntu懶人包,內含中文支援,某些常用軟體,及部份版權軟體(如Skype)。

3. Adobe Flash Player
用火狐進bbc news 看新聞,少 Adobe Flash Player,按連結至官網下載。影音測試ok。

4. 下載文鼎字體
http://www.opendesktop.org.tw/
打開terminal執行如下的命令
>>>
wget ftp://ftp.opendesktop.org.tw/odp/ODOFonts/OpenFonts/opendesktop-fonts-1.4.2.tar.gz
tar xvzf opendesktop-fonts-1.4.2.tar.gz
cd opendesktop-fonts-1.4.2
sudo cp odosung.ttc odokai-ExtB.ttf odokai.ttf odosung-ExtB.ttf /usr/local/share/fonts
sudo fc-cache -v
<<<

5. 選中文為預設語言 system > preference > appearance > font
將語言改成中文後,預設的輸入法會變成scim,欲使用gcin,下指令
im-switch -s gcin

6. Okular
以Synaptic套件管理程式下載 KDE doc reader program:
一個不錯的pdf reader 可畫線,螢光筆功能

7.新同文堂
http://of.openfoundry.org 下載用於firefox內繁簡轉換,碰到簡體中文網頁時很方便的。


8. Intel driver 依Google大仙指示如下:

如何安裝Intel顯示卡最新驅動 下載最新libdrm 2.4.5 (打了patch,不需要在xorg設置DRI了) http://myubuntu.ca/download/libdrm-2.4.5.tar.bz2 和最新Intel Video Driver 2.5.1 (打了patch的) http://myubuntu.dreamhosters.com/download/xf86-video-intel-2.5.1.tar.bz2 編譯準備: sudo apt-get install build-essential xorg-dev mesa-common-dev 編譯: tar xvjf libdrm-2.4.5.tar.bz2 cd libdrm-2.4.5 ./configure --prefix=/usr make sudo make install cd .. tar xvjf xf86-video-intel-2.5.1.tar.bz2 cd xf86-video-intel-2.5.1 ./configure --prefix=/usr make sudo make install 驅動還原: sudo apt-get install libdrm2 --reinstall sudo apt-get install xserver-xorg-video-intel --reinstall P.S. xorg.conf的section "Device"裡,最好有一項Driver "intel",但不一定需要的。(如3d
用不了,就把Driver "intel"加到那個section) 如果glxgears提示DRI問題,就在xorg.conf的最後,加入: Section "DRI" Mode 0666 EndSection 為了防止Ubuntu更新時,更換了驅動。 請在synaptic鎖定xserver-xorg-video-intel和libdrm2的版本!
在編譯準備時碰到依存關係的麻煩:
>> sudo apt-get install build-essential xorg-dev mesa-common-dev
....下列的套件有無法滿足的依存關係:
....

解法是source list 加入deb http://fr.archive.ubuntu.com/ubuntu hardy-updates main
修改/etc/X11/xorg.conf,這樣就可以設定1280*800解析度。


9. Skype 語音輸入
Google 來的:Skype 測試ok
Some of the new Dell Inspiron laptops (the 1420n, 1520, and 1525 are the ones I know of) come with a digital microphone array above the screen, but a fresh install of Ubuntu 8.04 will not have the array enabled by default.

Fortunately, it wasn't too difficult to enable, and now I can use Audacity, Skype, etc., without any peripherals. Although Hardy's usage of the new Pulseaudio system is causing problems with many audio applications, the problem in this case seemed to be alsa-based

Right-click the volume applet in the top-right of your screen and click Open Volume Control.
Click File > Change Device and change the device to the alsa device.
Now click Edit > Preferences and select both Digital and Digital Input Source.
In the Recording tab, make sure the digital device's volume is all the way up and that the device is not muted.
In the Options tab, change Digital Input Source: to Digital Mic 1.

10. Power Management
Modify /etc/X11/xorg.conf

>> Section "Monitor"
>> ...
>> Option "DPMS" "true"

>> Section "ServerLayout"
>> ...
>> Option "BlankTime" "5" # Blank the screen after 5 minutes (Fake)
>> Option "StandbyTime" "10" # Turn off screen after 10 minutes (DPMS)
>> Option "SuspendTime" "20" # Full suspend after 20 minutes
>> Option "OffTime" "30" # Turn off after half an hour

11. Firefox profile copy
還原vista上之firefox bookmark及Scrapbook內容
exit firefox

cd .. ~/.mozilla/firefox
// copy Vista system 內原有的 profile
cp -r /media/OS/Users/ron/AppData/Roaming/Mozilla/Firefox/Profiles/kdor1wuy.default/ .
mkdir test.default // 製作一個新的profile dir
cp -r ../xw41as5s.default/* . // 複製現有的

cd test.default // 合併檔案
for each file { places.sqlite key3.db signons3.txt permissions.sqlite formhistory.sqlite cookies.sqlite cert8.db }
cat $file ../kdor1wuy.default/$file > 111
mv 111 $file

cd Scrapbook // copy original data of Scrapbook
cp -r ../../kdor1wuy.default/ScrapBook/* .

// modify profile.ini so path = test.default

restart firefox // done

12. wine + evernote // 執行windows program 之環境
用Synaptic 加入 wine
mkdir ~/wine-app
cp EverNote_2.2.1.386_Installer.exe
wine EverNote_2.2.1.386_Installer.exe
// 執行 安裝 後桌面產生程式 icon
// copy my original note to ~/
// done
winecfg // wine 環境設定,調大dpi ~ 130

// workaround for preloaderPageZero
sudo gedit /etc/sysctl.conf
change "vm.mmap_min_addr = 65536" to vm.mmap_min_addr = 0

12. freemind on linux, mind manager
用Synaptic 加入 sun-java6-jre, javahelp2, freemind
> 系統 > 偏好設定 > 主選單 // 加入 Freemind 到 選單 應用程式 > 辦公
mkdir ~/MyMap
cp original data
// done


13. VMWARE 至VMWARE.COM register and download vmware workstation 32bit rpm ver
alien -k pkg.rpm //用alien 轉換 rpm to deb
dpkg -i // install the deb package
// not yet ready, use synaptic to see where the file is, /var/cache/vmware
cd /var/cache/vmware // to start the installer
sh VMware-Workstation-6.5.1-126130.i386.bundle

// 如果要固定MAC address 要修改 *.vmx configuration file
ethernet.addressType="static"
ethernet.address = 00:50:56:3F:FF:FF
// 去掉以下兩項
#ethernet0.generatedAddress = "00:0c:29:c1:73:9a"
#ethernet0.generatedAddressOffset = "0"
// done

14. Edraw Mind Map
download the free ver from edrawsoft.com
got trouble while installed by Wine
放棄吧!

15. XMIND installation 聽說不錯,介面功能似乎更勝 freemind

16. 升級Openoffice 3.0.0
// 取得 OOo_3.0.0_LinuxIntel_install_zh-tw_deb.tar.gz
tar xvfz OOo_3.0.0_LinuxIntel_install_en-US_deb.tar.gz

cd OOO300_m9_native_packed-1_zh-TW.9358
sudo dpkg -i *.deb

// 修改啟動程式,系統 > 偏好設定> 主選單 >
// 從 /opt/openoffice.org3/program 加入 soffice, swriter, simpress, scalc

// done

這樣 2.4 與 3.0 將共存。

2008年10月1日 星期三

Simulation Time

        In short, simulation is only a simulation which reflects the efforts we make to model the physical world. Many varieties of modeling approach exist, ex mathematical  behavioral, transaction.....etc. That is to say that we can only make it approximately correct in the sense we can aim the target, but never be exact.

        Not unusual, with the constraints of our tools such as computational power, it just takes too long, in some case even in the extent of our life time, to get the end results of some simulation case. Imaging a high definition video source, how long the simulation will take to proceed only one second real time for a codec design in a RTL level. In such case, engineer has to do some tweaks to complete the task in a reasonable time.

        Another example is about the initial settings of system variable. There was a case when engineer was complaining that he needed one day long to do a simulation run for a small design, actually a oscillator.  Without appropriate initial value, the simulator was trying to estimate a initial condition which was happening to be half or middle point of the equilibrium state. Oscillator like a seesaw, it would stay at its balanced state if no external force in the sense of mathematics. So the solution was to give a initial value to make the seesaw starting from a unbalanced state, then the simulation run completed in some minutes.
      
        A joke here, but real case, an engineer was  confused why the waveforms shown in the scope just didn't look like those in simulation software. As an engineer  we always need a sense to tell simulated or logical case from physical real world.