Verilog HDL
维基百科,自由的百科全书
Verilog HDL是一種硬體描述語言(hardware description language),為了製作數位電路(數字電路)而用來描述ASICs和FPGA的設計之用。Verilog 的設計者想要以 C 程式語言(en:C programming language)為基礎設計一種語言,可以使工程師比較熟悉跟容易接受。事實上,它產生與 C 程式語言類似的不嚴謹性質,並且大概與Pascal很相像。
這種語言跟傳統的程式設計語言不同,在於它的程式敘述並非嚴格地線性(循序)執行。Verilog 模式包含不同模組(modules)的階層關係。模組(modules)是輸出(inputs)和輸入(outputs)所定義出來的一個集合。在每個模組中,有一串的電線(wires)、暫存器(registers)和子模組(submodules)的定義。並且在每個模組裡面,語言敘述大部分都被群組成為各種的執行區塊(blocks),用來定義該模組所產生的行為描述。在每個區塊(blocks)內,使用 begin 和 end 的關鍵字來區隔開來,其中的敘述是循序被執行。但是同一個設計,不同的區塊間的執行是平行的。
Verlilog中,僅有部分的敘述稱為可合成的(synthesizable)。如果在一個電路設計的模組中僅包含可合成的敘述,那麼這個電路設計就可以被適當的軟體,轉換合成為電腦晶片的電路layout。
目录 |
[编辑] 歷史
[编辑] 開頭
Verilog 是由en:Gateway Design Automation公司於大約1984年所發展的硬體模型語言。Gateway Design Automation公司後來被 Cadence Design Systems於1990年所購併。現在 Cadence 對於 Gateway 公司的 Verilog 和 Verilog-XL 模擬器擁有全部的財產權。
[编辑] 开放标准
随着en:VHDL,的迅速成功,Cadence公司采取了开放标准的路线。Cadence公司将Verilog转放到公众开放领域Open Verilog International(OVI)组织(现在以en:Accellera)闻名)。随后,Verilog被提交到en:IEEE并成为en:IEEE1364-1995标准。我们通常称这一标准为Verilog-95。
[编辑] Verilog 2001
随后,人们向IEEE提交了一个改善了用户觉得原始的Verilog-95标准缺陷的新的标准。这一扩展版本成为了IEEE1364-2001标准,也就是Verilog 2001。
[编辑] Superlog/System Verilog
随着高级认证语言象OpenVera,en:Verisity's E 语言的出现,en:Co-Design Automation Inc发明了en:Superlog语言。随后,en:Co-Design Automation Inc被en:Synopsys收购,Superlog 和 Vera 的基础被捐献给en:Accellera。之后,superlog转换升级为System Verilog。System Verilog很有可能成为下一代的IEEE标准。
最近的版本支持模拟和混合信号模型。这些可以归诸于verilog系列。
[编辑] 範例
一個計數器的電路如下︰
module Div20x (rst, clk, cet, cep, count,tc); //TITLE 'Divide-by-20 Counter with enables' //enable CEP is a clock enable only //enable CET is a clock enable and enables the TC output // 使用 Verilog 語言描述的一個計數器 parameter size = 5; parameter length = 20; input rst; // 這些輸出/輸入表示這個模組的對外連線 input clk; input cet; input cep; output [size-1:0] count; output tc; reg [size-1:0] count; // 宣告硬體內的暫存器 wire tc; // 連接線 // 下方的 always 敘述是屬於平行執行的敘述,當任何時間 rst 或 clk 訊號 // 有從 low 到 high 的轉變時候就會被執行 always @ (posedge rst or posedge clk) begin if (rst) // 這個模擬計數器的重設 count <= 5'b0; else if (cet && cep) // 這個模擬兩個 enable 訊號都為 true begin if (count == length-1) begin count <= 5'b0; end else count <= count + 5'b1; // 5'b1 是 5 bits 寬度且等於 1 的數值 end end // 後面運算式的值會持續不斷地指定給 tc assign tc = (cet && (count == length-1)); endmodule
Verilog 中的"<="-{運算子}-的是它成為硬體描述語言而跟普通程序語言不同之處。這種敘述稱為 "non-blocking"。當電路模擬執行時候,所有使用 "<=" -{運算子}-的訊號(signals)都是平行被執行。這點跟真的硬體中正反器(Flop-Flops)的行為很相似。
另外一種指定運算的描述是 "=" -{運算子}-,也就是 "blocking" 的給值方式。當使用 "=" -{運算子}-時後,所有的東西都會循序的執行,類似普通的程式語言一樣。
範例: ... reg a, b, c, d; wire e; ... always @(b or e) begin a = b & e; b = a | b; #5 c = b; d = #6 c ^ e; end
上面的 always 句子描述了另外一種使用的方法,例如,任何在表列中的實體,像是 b 或 e 的內容在任何時候有所改變,always 後的就會被執行。當這些值有所改變,a 和 b 就會馬上給上新的值。經過 5 個時間單位的延遲,b 的值才會指定給 c,且 c ^ e 運算的值會藏入看不到儲存的空間中。然後經過 6 單位的時間後,d 才會得到剛才計算的值。
[编辑] 外部連結
- IEEE 1364 Home Page — for historical reference
- Verilog Education and Research Worldwide list of Universities that have Verilog and other Embedded Systems Research Groups
- A TOP-DOWN APPROACH TO IC DESIGN contains useful information about using HDL's such as Verilog for chip design.
- Verilog F.A.Q. Verilog Frequently Asked Questions
- Verilog designers guide
- "The IEEE Verilog 1364-2001 Standard - What's New, and Why You Need It", by Stuart Sutherland, summarizes the differences between Verilog 1995 and Verilog 2001
- The Usenet comp.lang.verilog newsgroup is for discussion of Verilog
- A BNF grammar for Verilog (note that this predates the IEEE 1364 standard)
- Verilog 2001 syntax derived from the BNF grammar using ebnf2annot
- "The C Programmers Guide to Verilog", by Lara Simsic, an introduction to hardware design in Verilog