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)認為,輔助殘障者的科技應用進入主流市場將蔚為風潮,因為「人口老化將帶動易上手的科技興起」。