1 / 53

Chapter 11 Verilog 硬體描述語言

Chapter 11 Verilog 硬體描述語言. Verilog 硬體描述語言的基本架構 Verilog 模組描述的基本格式 如何開啟進入 Verilog 硬體描述語言編輯器 Verilog 的描述格式 Verilog 的資料型態 Verilog 的事件基礎時間控制 Verilog 的輸入輸出埠描述. Chapter 11 Verilog 硬體描述語言. Verilog 硬體描述語言的基本架構 Verilog 模組描述的基本格式 如何開啟進入 Verilog 硬體描述語言編輯器 Verilog 的描述格式 Verilog 的資料型態

jabari
Télécharger la présentation

Chapter 11 Verilog 硬體描述語言

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 11 Verilog硬體描述語言 • Verilog硬體描述語言的基本架構 • Verilog模組描述的基本格式 • 如何開啟進入Verilog硬體描述語言編輯器 • Verilog的描述格式 • Verilog的資料型態 • Verilog的事件基礎時間控制 • Verilog的輸入輸出埠描述

  2. Chapter 11 Verilog硬體描述語言 • Verilog硬體描述語言的基本架構 • Verilog模組描述的基本格式 • 如何開啟進入Verilog硬體描述語言編輯器 • Verilog的描述格式 • Verilog的資料型態 • Verilog的事件基礎時間控制 • Verilog的輸入輸出埠描述

  3. Verilog硬體描述語言的基本架構 module Switch-level Gate-level Dataflow-level Behavioral-level enmodule

  4. 模組內之四種層次描述電路 • 開關層次(Switch-Level):描述元件開關及儲存點組合而成 • 邏輯層次(Gate-Level):描述邏輯閘的連接形式 • 資料流層次(Data-Level):描述電路的資料如何在暫存器中儲存與傳送 • 行為層次(Behavioral-Level):描述模組之功能

  5. 暫存器轉移層次(Register-Transfer-Level, RTL) • 資料流層次(Data-Level) + 行為層次(Behavioral-Level)經合成而形成暫存器轉移層次(Register-Transfer-Level, RTL)

  6. Chapter 11 Verilog硬體描述語言 • Verilog硬體描述語言的基本架構 • Verilog模組描述的基本格式 • 如何開啟進入Verilog硬體描述語言編輯器 • Verilog的描述格式 • Verilog的資料型態 • Verilog的事件基礎時間控制 • Verilog的輸入輸出埠描述

  7. Verilog模組描述的基本格式 Module <模組名稱><模組輸入輸出埠宣告> 模組四個層次的描述; endmodule

  8. 以開關層次描述一NOT閘之模組 module inv (ina, out); input ina; output out; supply1 vcc; supply0 gnd; pmos (out, vcc, ina); nmos (gnd, out, ina); endmodule

  9. 以邏輯閘層次描述一OR閘之模組 module ORGATE (A, B, F); input A; input B; output F; or u1(F, A, B); endmodule

  10. 以資料流層次描述一AND閘之模組 module ANDGATE (A, B, F); input A; input B; output F; wire F; assign F=A&B; endmodule

  11. 以行為層次描述一NAND閘之模組 module NANDGATE (A, B, F); input A; input B; output F; reg F; always @(A or B); begin F=~(A & B); end endmodule

  12. Chapter 11 Verilog硬體描述語言 • Verilog硬體描述語言的基本架構 • Verilog模組描述的基本格式 • 如何開啟進入Verilog硬體描述語言編輯器 • Verilog的描述格式 • Verilog的資料型態 • Verilog的事件基礎時間控制 • Verilog的輸入輸出埠描述

  13. Create a New Project

  14. Design Entry

  15. Create new document

  16. Design Wizard

  17. Design Wizard---Language

  18. Design Wizard---Name

  19. Design Wizard---Ports

  20. OR Gate HDL Editor

  21. Insert Programs

  22. Check Syntax

  23. Synthesize  Gate level circuit

  24. Create Macro

  25. Update Macro

  26. 在Schematic Editor取出OR GATE

  27. 模擬結果

  28. Chapter 11 Verilog硬體描述語言 • Verilog硬體描述語言的基本架構 • Verilog模組描述的基本格式 • 如何開啟進入Verilog硬體描述語言編輯器 • Verilog的描述格式 • Verilog的資料型態 • Verilog的事件基礎時間控制 • Verilog的輸入輸出埠描述

  29. Verilog 的基本語法規定 • 關鍵字如module, endmodule, assign, wire, always, input, output, begin, end…等必須使用小寫 • 識別字的大小寫是有差別的,第一個字必須是使用英文字母 • 單行註解用//; 多行註解用 /* … */ • 字串以雙引號表示,如 “This is a string”

  30. Verilog 的數字格式(1) • 有規定長度的數字(sized numbers) • <size>’<base format><number> • <size>:位元數 • <base format>:d10進位,h16進位, o 8進位,b 2進位 • Example: F=4’b0101; A=16’h6FA3

  31. Verilog 的數字格式(2) • 不規定長度的數字(unsized numbers) • ’<base format><number> • <base format>:d10進位,h16進位, o 8進位,b 2進位 • 位元數之大小由模擬器或硬體機定值來決定 • Example: b=’ha5; b=a5(32位元之16進位數)

  32. Verilog的運算子

  33. Chapter 11 Verilog硬體描述語言 • Verilog硬體描述語言的基本架構 • Verilog模組描述的基本格式 • 如何開啟進入Verilog硬體描述語言編輯器 • Verilog的描述格式 • Verilog的資料型態 • Verilog的事件基礎時間控制 • Verilog的輸入輸出埠描述

  34. (1)、數值組集(Value Set) • Verilog有四種表示數值,即 0、1、x、z以及八種信號強度

  35. (2) 、接線(net) • 接線(net)表示在硬體元件的接點連接線 • 關鍵字可以分為下列六種 • wire: 內定為一個位元的值,機定值為高阻抗 • wand: Wired-AND型接線 • waor: Wired-OR型接線 • tri • trior • trireg

  36. (3) 、暫存器(reg) • Verilog中reg相當於一個變數,其機定值為x • Example: reg out; 宣告一個out變數, reg所宣告的變數必須在always的區塊描述內使用 reg F; always @(A or B); begin F=~(A & B); end endmodule module NANDGATE (A, B, F); input A; input B; output F;

  37. (4) 、向量(Vectors) • 向量(Vectors)表示多位元的元件,wire及reg都可定義為向量格式 • Examples: • wire A[7:0]; //宣告有一8位元的BUS • reg [0:15] out; //宣告有一16位元寬度的向量暫存器變數out

  38. (5) 、整數(Integer) • 整數之關鍵字為integer,最少要32位元,integer宣告可帶正負號 • Example: integer count; initial count = 0;

  39. (6) 、實數(Real) • 實數之關鍵字為real,可用十進制或帶有指數表示 • Example: real w, x; initial begin w = 5.2; x = 25e6;

  40. (7) 、時間(Time) • 時間之關鍵字為time,主要功能在描述儲存模擬的時間,也就是取得目前的模擬時間,最少為64位元的資料 • Example: time storage_time; initial storage_time=$time

  41. (8) 、陣列(Arrays) • Verilog所提供陣列的儲存內容可以是整數、暫存資料、時間及向量,但不能為實數而且只適用於一維陣列 • 表示格式為<array_name>[<subscript>] • integer A[0:15];16個變數A的陣列 • reg [3:0] B[0:15];16個變數B的陣列,每一個B的位元寬度為4位元

  42. (9) 、記憶體(Memories) • 記憶體是一個暫存器的陣列,而陣列中的每一個物件都視為一個word,每一個word可以是1個位元或是多個位元所組成 • reg [15:0] memory1 [0:1023]/*宣告記憶體memory1為16位元1K word的大小*/ • reg memory2 [0:1023]/*宣告記憶體memory2為1位元1K word的大小*/

  43. (10) 、參數(Parameters) • 主要作用在設定一個固定常數,此常數可在每一次編譯時更改其值 • parameter LGG=100;//宣告一常數LGG等於100

  44. (11) 、字串(Strings) • 字串的作用在指定給暫存器,若長度大於reg的長度,則其左邊的位元會被刪掉,若長度小於reg的長度,則其左邊的位元會以零補之 • Reg [8*16:1] string_value; initial string_value=“good morning”

  45. Chapter 11 Verilog硬體描述語言 • Verilog硬體描述語言的基本架構 • Verilog模組描述的基本格式 • 如何開啟進入Verilog硬體描述語言編輯器 • Verilog的描述格式 • Verilog的資料型態 • Verilog的事件基礎時間控制 • Verilog的輸入輸出埠描述

  46. 事件基礎時間控制(Event-based timing control) • Event就是一個wire • 當暫存器改變時就是事件,此事件可用來觸發一個敘述或包含多個敘述的區塊,且模組的輸入埠接收到一個新值也算是一個事件 • Event-based timing control可包含(1) Regular event control (2) Named event control (3) Event OR control (4) Level-sensitive timing control

  47. Regular event control • 代表符號為@,它是表示當信號產生正緣(posedge),負緣(negedge),轉換(transition)或數值改變時,其相關敘述才會被執行 • always @(clock) Q=J; 當clock信號值改變時就執行 Q=J 敘述 • always @(posedge clock) Q=J; 當clock信號正緣觸發時就執行 Q=J 敘述

  48. Event OR control • 指使用多個信號或事件去觸發一個敘述或含有多個敘述的區塊來執行,因此將這些多個信號或事件以or(或)來表示 • always @(reset or clock or A or B) begin if (reset) F=1’b0; else if (clock) F=A+B; end

More Related