Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

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

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

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

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

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

7 7 Verilog 模組描述的基本格式 Module 模組四個層次的描述 ; endmodule

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

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

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

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

13 13 Create a New Project

14 14 Design Entry

15 15 Create new document

16 16 Design Wizard

17 17 Design Wizard---Language

18 18 Design Wizard---Name

19 19 Design Wizard---Ports

20 20 OR Gate HDL Editor

21 21 Insert Programs

22 22 Check Syntax

23 23 Synthesize  Gate level circuit

24 24 Create Macro

25 25 Update Macro

26 26 在 Schematic Editor 取出 OR GATE

27 27 模擬結果

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

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

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

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

32 32 Verilog 的運算子

33 33

34 34

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

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

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

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

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

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

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

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

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

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

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

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

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

48 48 事件基礎時間控制 (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

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

50 50 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

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

52 52 Verilog 的輸入輸出埠描述 輸入埠 (input) 輸出埠 (output) 雙向埠 (inout) Examples module Addr(F1, F2, D, SUM, C0) input [3:0] F1, F2; output [3:0] SUM; output C0; input D;

53 53 Question & Answer


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

Similar presentations


Ads by Google