Transcript 下載/瀏覽
CHAPTER 4 Verilog 與 VHDL 的語言結構 第4章 以 Verilog 與 VHDL 的語言結構 2 4-1 Verilog的輸出入埠敘述 模組外 Module 模組內 net / register net Input Port net / register output Port net input 輸入埠 net 輸出 /入埠 net output 輸出埠 Input / output Port inout 模組內外之輸出入埠的連接方式 第4章 以 Verilog 與 VHDL 的語言結構 3 data data_in enable_in_out 自訂的 雙向埠 tri_inout 驅動模組 BiDir.V:雙向埠(inout, Bidirectional)驅動的邏輯符號 第4章 以 Verilog 與 VHDL 的語言結構 4 BiDir.V 的模擬結果 第4章 以 Verilog 與 VHDL 的語言結構 5 下圖是將BiDir.V電路描述經由QuickLogic所設計出來的 SpDE合成出來的電路(使用:現場可規劃邏輯閘陣列(Field Programmable Gate Array,FPGA)IC。 第4章 以 Verilog 與 VHDL 的語言結構 6 4-2 VHDL語言的結構圖 Package Generics Ports Entity Architecture Concurrent 敘述 Process Sequential 敘述 第4章 以 Verilog 與 VHDL 的語言結構 7 4-3 Verilog的四大模型 低階交換模型(Switch Level Model)或電晶體 層次(Transistor Model) 邏輯閘層次模型(Gate Level Model) 資料處理模型(Data Flow Model)或暫存器轉 移層次(Register Transfer Level) 行為模型(Be-havioral Model) 第4章 以 Verilog 與 VHDL 的語言結構 8 My_NOT.V 的模擬結果 第4章 以 Verilog 與 VHDL 的語言結構 9 in1 Out in2 2 輸入的 AND 閘 GATEAND2.V 的模擬結果 第4章 以 Verilog 與 VHDL 的語言結構 10 DF_AND2.V 的模擬結果 第4章 以 Verilog 與 VHDL 的語言結構 11 BEH_AND2.V 的模擬結果 第4章 以 Verilog 與 VHDL 的語言結構 12 4-4 VHDL的三種設計層次 第4章 以 Verilog 與 VHDL 的語言結構 13 接著我們用一個具有enable訊號制輸出與否的“半加器” 當作例子,使用三種不同層次來設計。 x y carry Enable result Half_Adder “半加器”的『Symbol』 第4章 以 Verilog 與 VHDL 的語言結構 14 4-5 Verilog的模組 只有在當模組需要與外界相互連接時才有埠列與埠的宣告。 其他的五個部份包括: wire與reg等變數的宣告 引用較低階之模組的別名 assign資料處理層級之描述 always行為層級之描述 以及task任務與function函數 這五大部份並沒有一定的撰寫順序,一個模組的尾端永遠是 endmodule這個關鍵字。 第4章 以 Verilog 與 VHDL 的語言結構 15 4-6 VHDL的語法 VHDL 的 entity v.s. architecture 法 symbol v.s VHDL 的 entity VHDL 的 entity 語法 HDL 的 entity 宣告加上 generic 子句 VHDL 的 architecture 宣告 第4章 以 Verilog 與 VHDL 的語言結構 16 VHDL 的 architecture 語法 symbol v.s VHDL 的 architecture VHDL 的 component 宣告 VHDL 的 configuration 敘述 VHDL 的process 敘述 VHDL 的 block 敘述 第4章 以 Verilog 與 VHDL 的語言結構 17 一個VHDL檔案中只能有一個entity及一個architecture。 例如: 第4章 以 Verilog 與 VHDL 的語言結構 18 a1 a2 a3 zn NAND3的『Symbol』 第4章 以 Verilog 與 VHDL 的語言結構 19 in out inout buffer VHDL 提供的四種『輸出/入』port 圖示 第4章 以 Verilog 與 VHDL 的語言結構 20 in1 in2 Sum 全 加 器 CarryOut CarryIn 一個位元全加器(Full_Adder)電路的方塊圖 第4章 以 Verilog 與 VHDL 的語言結構 21 Generic_Adder 的模擬結果(constant Max_Adder_Bits:integer:= 8;) 第4章 以 Verilog 與 VHDL 的語言結構 22 Generic_Adder 的模擬結果(constant Max_Adder_Bits:integer:=10;) 第4章 以 Verilog 與 VHDL 的語言結構 23 a1 zn a2 a3 NAND3的『Schematic』 第4章 以 Verilog 與 VHDL 的語言結構 24 例如:設計一個N Bits的Adder,同時採用:Structural Level、RTL Level以及Behavioral Level三種方式去設計; test bench測試程式中則是使用configuration敘述去引用三 種不同設計層次的architec-ture。 xor_gate structural adder_Nbits tb_Nbits_adder adder_Nbits rtl adder_Nbits adder_1bit and_gate or_gate behavioral adder_Nbits 第4章 以 Verilog 與 VHDL 的語言結構 25 tb_Nbits_adder的模擬結果 第4章 以 Verilog 與 VHDL 的語言結構 26 VHDL 的 block 敘述 第4章 以 Verilog 與 VHDL 的語言結構 27