數位系統設計實習 (FPGA 系統設計實務) 授課對象: 大三 教師: 夏世昌 博士 教學目標 1.使學生了解可程式邏輯之原理及使用 2.軟体エ具使用 3.整合發展系統使用 4.快速硬体雛形験証 5.墊定學VLSI基礎 課程內容大綱 1. FPGA晶片架構及原理 2. FPGA電路設概念及流程 3. Xilinx FGPA發展系統軟体 使用(設計,模擬) 4. FPGA發展系統使用(實現,驗証) FPGA除錯及下載 實例設計1-以加法器為範例 5.實例設計2-VGA 顯示控制器 6.實例設計3-加密/解密電路 7.實例設計4- 可預設式CRC錯誤偵測器 8.實例設計5- ITU_R656 串序視訊編解碼器 9.實例設計6- Micro-processor與FPGA 共同設計可程式函數波產生器 實習內容 一 FPGA晶片架構及原理 PLD (Programmable Logic Device)依其架構及密 度可分成三類: 1.SPLD (Simple Programmable Logic Device) 2.CPLD (Complex Programmable Logic Device) 3.FPGA ( Field Programmable Gate Array) Circuit complexity : FPGA>CPLD>PAL SPLD Ex. PAL or PLA Device : PAL20L8 ; 1.邏輯閘約在數百閘左右 2.IC 腳位在28pin 以內 3.Bipolar process ,只能作單次燒錄,資料 無法抹除 4.GAL process ,多次燒錄,可縮短設計時程 * Instead of the Standard TTL/CMOS IC CPLD : 1. 邏輯閘在800 ~10000 之間 2. 44pin 以上IC 的封裝以PLCC 為主 3. CMOS 設計技術 4. On-Chip 多次燒錄抹除 5. Built Flash Memory FPGA 1. 使用和CPLD 不同的架構設計方式 2. 邏輯閘密度數比CPLD高 3. Routing 複雜,非固定式,延遲時間較 長 4. SRAM Base -可重覆燒錄但需外部電源 維持資料 配合外加EEPROM作資料保持off chip Interconnect .Continuous Interconnect (CPLD) 1.Predictable delay 2.Faster global Interconnect .Segmented Interconnect (FPGA) 1.Unpredictable delays slower local Interconnect 2. Switching Box for circuit wiring Configurable VLSI .Advantages 1.Short time-to-market 2.Low tooling costs 3.Low penalty on design changes 4.Low testing cost 5.product advantage (new process) .Disadvantages Low capacity; Low cost; Low speed CPLD Routing High Speed But low Density Built in Flash Memory Max. 10k ~50K Gates FPGA Routing Using local switching box Cascade one-by-one Low Speed High Density Extra EEPROM required Max 5000k Gates (2003) Xilinx FPGA Vendors 1. Xilinx (>50%) 2. Altera (20%~30%) 3. Others (Lattice, Actel)<10% Reprogrammable : 可重複燒錄 One Time Programmable : 單次燒錄 SRAM : 以SRAM Cell 組成可程式點 EEPROM / Flash : 以EEPROM / Flash Cell 組成可 程式點 Anti-Fuse : 以逆熔絲組成可程式點 Xilinx FPGA Architecture 1.Gate-array like architecture 2.Configurable logic blocks(Implement logic) 3.I/O blocks 16 signal standards 4.Block RAM (Synthesisable) On-chip memory for higher performance 5.Clocks & delay-locked loop (PLL) 6.Interconnect resources 7. Three-state internal buses Basic Architecture Example for CLB connection Configurable Logic Block (CLB) 1. Combinational logic generated with lookup table(LUT) 2. Any function of available inputs (32 bits or more) 3.LUT output feeds CLB output or D input of flip-flop for sequential circuit) 1. LUT limit is on inputs , not complexity 2n input logic conditions 2. Logic Programming by Xilinx synthesis and implementation tools Can combine Any logical function Flip-Flop Controls .Reset (clear) and/or set .Global initialization (GSR) Use to initialize all flip-flops .Programmable clock polarity .Clock enable . Feedback connection CLB Slice RAM I/O Block (IOB) 1. Input, output, or bi-directional 2. Direct or registered 3. Pullup/Pulldown 4. Programmable slew rate 5. Three-state output (0,1,Z) 6. Programmable thresholds 實習內容 二 FPGA電路設計概念及流程 Function / Specification : 功能和規格的制定 Algorithm / Data Flow : 演算法和資料流程的規劃 Data Path / Control : 資料路徑和控制流程的規劃 Design Implement :電路實現 FPGA Development Flow Ex 1. Function / Specification, 功能和規格的制定 : 設計一個電路計算0+1+2+……+9 2. Algorithm / Data Flow, 演算法和資料流程規 劃: 3. Data Path / Control : 資料路徑和控制流程的規劃 4. Circuit Design Count 0~9 Output Accumulator Control 5. Function Simulations : no delay 6. Synthesis : 用基本Gates合成電路 7. Layout / Place & Route : 佈局, 放置與繞線 8. Timing Simulation added circuit delay 9. Download to FPGA and Verification Real-time run design function And debug in circuit Main design consideration – Design spec. –Hardware Cost –Implementation FPGA or ASIC – Select FPGA vendor – Select Device Meet the circuit size to device – Development timeexpectation) Implementation 1. Develop architecture – Parallel, pipeline, serial, DA, ….. 2. Choose the design entry method – Schematic • Gate level design • Intuitive & easy to debug – HDL (Hardware Description Language), e.g. Verilog & VHDL • RTL (register transfer level) coding – Mixed HDL & schematic Functional Preparation for simulation Only check Logic Function, fast Verification circuit design – Generate simulation patterns – Generate simulation netlist • Simulation results – Waveform display – Text output • Challenge – Sufficient & efficient test patterns FPGA Complier flow – Netlist merging, flattening, data base building – Design rule checking – Logic optimization – Block mapping & placement – Net routing – Configuration bitstream generation(for download) Implementation results – Design error or warnings * “warning” can continue to run – Device utilization – Timing reports (delay) • Challenge –How to reach high performance & high utilization implementation? • Timing analysis – included device delay and routing delay - To examine the timing constraints – To show the detailed timing paths – Can find the critical path • Timing simulation – To verify both the functionality & timing of the design Download to FPGA Choose the appropriate configuration scheme – SRAM-based FPGA/CPLD devices • Downloading the bitstream via a download cable • Programming onto a non-volatile memory device & attaching it on the circuit board – OTP, EPROM, EEPROM or Flash-based FPGA/CPLD devices • Using hardware programmer (writer) Device Programming Finish system design on the board - combine FPGA& other components • Challenge – Board design (wiring connection, PCB layout) – System considerations 實習內容 三 Xilinx FGPA發展系統軟体使用 安裝Xilinx ISE WebPack 5.1i 軟體free from www.xilinx.com Select ISE Design 未曾在Xilinx 網站註冊者, 請先行註冊 Notice * 若您的網路速度相當快, 可點選Xilinx WebInstall 安裝 執行WebPACK_51_fcfull_i.exe 執行 Service Pack 3 : 5_1_03i_pc.exe 如果PC 是新的主機板, 配備USB 2.0, 可能必 須安裝下列修正程式, ftp://ftp.xilinx.com/pub/applications/misc/ mltlnx_ans_14782.zip; 請參考 http://support.xilinx.com/xlnx/xil_ans_displ ay.jsp?iLanguageID=1&iCou ntryID=1&getPagePath=14782 ISE 軟体使用 輸入方法: 1. 繪圖法 2. 硬體描述語言HDL 使用繪圖法設計邏輯電路 1. 使用繪圖法設計邏輯電路的流程 2. 功能驗證 (Function Simulation) 3. Mapping to FPGA circuits 4. 時序驗證(Timing Simulation) 5. Download to FPGA broad 執行 ISE Project Navigator 出現下列視窗 繪圖法 1. Call Components 2. Drawing for wiring Call Components 1. 點選 Add Symbol Icon ; 2. Categories 的視窗內點選Logic 3. 滑鼠移至圖面內, 點在適當位置即可 IO Symbol must be added 1. 在Categories 的視窗內點選IO, 2. 並在Symbols 的視窗內點選ibuf ie, if input 7 pins, 放置7 個 ibuf; 2. 接著在Symbols 的視窗內點選obuf, ie, if output 4 pins, 放置4 個 obuf, Connecting for components 點選 Add Wire Icon 將元件連接 特別注意Ibuf 和Obuf 需多預 留單端的短線 Add I/O Pad 1. 點選Add I/O Marker , 並確認 Add an Input Marker 已被勾選; 接著放置 2. Input Marker 至Ibuf 端先前 預留的短線上 勾選Add an Output Marker , 接著放置 Output Marker 至Obuf 端先前預留的短線上 點選 Select Icon , 點右鍵在Input Marker 上, 選擇Rename Port 儲存檔案, 然後點選Tools-Check Schematic; 若沒有錯誤則會顯示No errors 點選 Source in Project 視窗內的設計檔gates, 接著, 點右鍵在 Processes for Current Source 視窗內的Synthesis 上, 選擇Run 接著建立Constraints File 1. 以指定Pin Assignments to FPGA chip; 2. 點右鍵在Project Icon 選擇New Source; 3. 然後選擇Implementation Constraints File 點選Source in Project 視窗內的gates.ucf, 接著 點兩下Processes for Current Source 視窗內的 Assign Package Pins, 執行Xilinx PACE 程式 點選Package Pins for XC2S200-5FG456 視窗; 點選Design Hierarchy 視 窗內的I/O Pins; Design Object List 視 窗會顯示所有的I/O Pins 將Design Object List 視窗會內的I/O Pins 拖曳至適當的FPGA Pins 例如: 將Input Pin a0 拖曳至 Pin V9. ALL I/0 Signals assigned to FPGA Pins Finish 點選Sources in Project 視窗內的設計檔gates 接著點右鍵在 Processes for Current Source 視 窗內的Generate Programming File 上, 選擇Run 執行完,若沒有錯誤, 則Implement Design 和 Generate Programming File 會顯示綠色打勾 實習內容四. FPGA發展系統使用(實現,驗証) 採用雅普科技數位整合系統包括 1. Xilinx FPGA Spant-II 2SC20 (200k gates) 2. 2M RAM 3. Video Port 4. Camera Input 5. Built Micro-Processor 6. Stepping motor driver 7. ADC Input/DAC Output 8. Switch/display Broad View Testing Modular FPGA Configuration 的Download執行 IdsX2S 將滑鼠移至Forth 的視窗, 按一下滑鼠左鍵, 在Forth 的視窗內輸入 tst1km.fth , 按 Enter Config file 的List box 上, 找到測試程式 “Tests\HexFil 在 file 的List box 上, 找到測試程式 “Tests\HexFiles 測試7-segment Forth 的視窗內輸入 tst1k0 測試VGA 模組的LED 在Forth 的視窗內輸入 tst1k1 測試VGA: 在Forth 視窗內輸入tst1k2 可測試 1.VGA 80MHz 24 bits 全彩DAC 2. Micro-Processor模組的 AVR 3.Memory 模組的SDRAM 功能; 此時螢幕會出現彩色帶狀圖 測試CMOS Image Sensor 在Forth 的視窗內輸入 tst1k3 按Enter,可測試影像擷取 Download 自己設計電路 1. Load Config :將磁碟機內的Configuration file 下載至FPGA 2.Config File 磁碟機內的Configuration file 之List Box 3. Add Config 將磁碟機內的Configuration file 燒錄至EEPROM 4. Config ROM 燒錄在EEPROM 的Configuration 之List Box 5. Act Config 燒錄在EEPROM 的Configuration 之List Box 6. Set Active設定下一次起動實驗器時, 立即由EEPROM 下載至FPGA 的Configuration 7. Del Config 將已經燒錄在Config ROM 的 Circuit 刪除 點選ConfigROM 的下拉鈕, 若狀態列為0 Cmd 則表示 UART 連線正確, 否則,點選Setup-Preference 設定 Com Port, 並檢查Cable 及實驗器電源 1.確定連線沒問題後, 則進行Configuration Download. 2. 點選ConfigFile 的下拉鈕,切換路徑至Project 的目錄, 並選取檔案gates, 接著點選LoadConf鈕Download. Forth 視窗內會出現: “ path\gates” loadconf, 此時, 狀態列為3 Cmd, 數秒後,又轉回0 Cmd, 且Forth 視 窗內會出現 ( ok ), 表示Configuration Load 完成. 切動DIP SW cy0~y6 (a0,a1,b0,b1,c0,d0,d1), 由 VGA模組的LED vld0~vld3 (對應到ay, by, cy, dy ); 驗 證輸出個別的邏輯是否正確 Clock 設定 1. 3 組獨立可程式的高頻clock sources—分別為 CKA, CKB, CKC, 其頻率為800KHz~90MHz; 2. 1 組CKD, 在此版本為目前頻率為10MHz (fixed) 3. 2 組可單步, 多步低頻的clock, 分別為CKE 和 CKF, CKE 的clock 頻率為1Hz~100KHz, CKF 的clock 頻率為0.1Hz~100KHz; 低頻的clock 可作為debug之用; CKE 和CKF 頻率設定的單位 為: 每秒toggle(0->1 或1->0)次數 4. Xilinx FPGA X2S200FG456 有4 clock 的 Input個Ports 是FPGA 專門用來作為, 分別是 W12, C11, A11, Y11 ,Clock 必須設定在這4 個 Ports 的其中之一 J6 為Clock Source 的Select jumper 區 cka(drives)->gck0(drives)->W12 of FPGA; 經由Jumper 的Short, clock 輸入的Port 就有許 多不同的組合與選擇, 例如: cka 可 驅動gck0, gck1 或gck2; 下表列出每個clock source ckn 所能驅動的gck list Programming Frequency Forth 指令800 ckaf :設定cka 為頻率800KHz Project-1 8-bit Full Adder Design 目的: 1. 了解基本加法器設計 2. 由實例學習FPGA軟体使用 3. 實際下載電路至發展系統, 作即時驗証 儀器及設備: 個人電腦, FPGA發展系統及模擬軟体 原理: 1. First design 1-bit full adder 2. Design 8-bit adder using 1-bit adder 1-bit adder : S=ab ci Cout=a b+b cin+a cin Simulations 8-bit full adder using 1-bit adder symbol 層次設計 Pin Assignment Input output 用發展系統驗証結果 實例設計2-VGA 顯示控制器 目的: 1. 了解-VGA 顯示控制原理 2. 由實例學習用FPGA作顯示控制 3. 訓練除錯之作即時驗証技術 儀器及設備: 個人電腦, FPGA發展系統發展系統及模擬軟体 原理 VGA Module 1.80MHz 24 bits True Color VGA Interface 2. 8 bits x 3 LED / 8 bits DIP Switch 3. Character/Graphic LCD Module Connector A VGA video signal contains 5 active signals 1.Two signals for synchronization of the video • Horizontal sync • Vertical sync 0.7 to 1.0-Volt peak-to-peak level 2. Three color signals • Red • Greed • Blue Video Display Technology (2/2) To reduce flicker due to interference from fluorescent lighting source : • Refresh rates higher than 60Hz are sometimes used in PC monitors. • In 320 x 480-pixel model, a 60Hz refresh rate means approximately 80ns duration per pixel. • A 12.5MHz clock has a period of80ns, which is preferably adopted as the system clock VGA display connector VGA Design Spec 640 pixels X 480-lines H- Sync. freq. = 31.4kHz V- Sync. freq. = 60Hz (60 frame/Sec) Base time = 40ns (25MHz) clock period Display: 1. Show your name in TOP 2. Draw circle radius=1 to 10 changed per second To VGA From FPGA D/A Converter The analog RGB outputs IOR, IOG, and IOB related to the digital inputs are stable : after the clock edge with a two-cycles latency. 方法-配置在發展糸統位置 LED vg7~vg0, vb7~vb0: These groups of LEDs share the ports (connecting to the FPGA) with that of the VGA DAC. The buffers driving these LEDs are turned off by default. Clock Selection 實例設計3-DES 加密設計 目的: 1. 了解-DES 加密設計原理 2. 由實例學習用FPGA作加解密控制電路 3. 訓練除錯之作即時驗証技術 儀器及設備: 個人電腦, FPGA發展系統發展系統及模擬軟体 原理 Data Encryption /Decryption are important for secure networks. The most popular one is the DES. VPN (virtual private networks) DES 1. 64bit data 做加解密 2.以56bit 長度做加解密鑰匙(key) 概要流程 1.由56bit 長度的主鑰匙分別再產生16 把48bit 子鑰匙 為了就是16 次的流程 2. 而欲加密之64bit 資料以2 個32bit 分做左右兩部分 右邊的部分被會保留至下一次的左邊每一次的運算 只做右邊‘查表’後互斥或左邊然後放置於下一次的右邊 然‘查表’ System Block 加解密資料的輸入與輸出 加解密資料中重複的核心流程 16 把48bit 子鑰匙 1.以主要的56bit 鑰匙產生16 把48bit 子鑰匙用來 對應16 次的重複的加解密流程 2.加密與解密時的不同在於鑰匙產生的順序相反 如加密時16 把子鑰匙產生分別為為類型1~16 產生子鑰匙的流程 產生子鑰匙的方式 DES 中加密時第1,2,9,16 的流程裡左移1bit 其他則左移2bit 然4 個1bit 加上12 個2bit 剛好等於28bit 構成DES 最主要的條件以8 個替換盒所構成 構成DES 最主要的條件以8 個替換盒所構成 輸入為32bit 的資料及48bit 子鑰匙 輸出為32bit 查表後的資料 輸入與輸出的關係為(以3 次為例) ** 密文<=查表(查表(查表(明文))) ** 明文<=查表(查表(查表(密文))) 進入查表的則為48bit 由32bit 的資料擴 增為48bit 後與48bit 子鑰匙互斥或而得 每替換盒分到6 個bit 的輸入而輸出為4 個bit 6*8=48 查表的架構中所用的擴增與換位 替換盒的構成 每一交換盒皆以6bit 輸入 以第1 與第6 位元為輸入參數1 第2 到第5 位元為輸入參數2 DES 替換盒對應表 Bit2~5 Hardware Design 以www.opencores.org 裡所公開 主程式規劃 1.Pipeline 的規劃 2.最長路徑經過用4 個暫存器 3.可規劃性非常高 最長路徑在於核心加解密流程經過查表後才能進行 下一級 鑰匙產生 1. 與先前換位再運算再換位不同而 採直接換位 2.加密與解密的差別為換位的順序不 同 3. 為了Pipeline 而放入15 個對於主 鑰匙的暫存器但卻能提高鑰匙的規劃 性 Basic Architecture Pipeline 規劃透過時序圖觀察核心加解密時資料的轉移 解密使其還原 Project-4 CRC 錯誤檢查碼產生器及解碼器 CRC(Cyclic Redundancy Code): 運用於磁諜 及通信系統資料讀取及傳送中錯誤偵測及修正 .目的: 使學生了解CRC原理,並用FPGA驗証其功能, 理論配合實作 儀器及設備: 個人電腦, FPGA發展系統發展系 統及模擬軟体 原理 If D(x)為欲傳送資料 G(x)為偵測用多項式係數 G(x)有國際標準碼如 CRC-12: x12+x11+x3+x2+1 CRC-16: x16+x15+x2+1 CRC-CCITT: x16+x12+x5+1 每一種測偵碼,對資料錯 誤偵測及修正效果不同 動作: 把D(x)除以G(x)得餘數R(x), 傳送T(x)=D(x)-R(x)至接收端 在接收端,用相同G(x)除T(x) 若餘數為0,表示傳送資料沒錯誤 否則有錯 *傳送及接收端要用相同G(x) Ex. If G(x)=10011(=x4+x+1) D(x)=1101011011 110101101110011=1100001010 R(x)=1110 T(x)=11010110111110 用XOR配合DFF移位代替除法器 And a0 D a1 Q And a2 D Q a2 And a3 D Q a3 a2 And D Q D(x) ck ck ck G(x)=anXn+…+ a2x2+ a1x+a0 Initial : all DFF reset to zero ck T(x) If G(x)=10011(=x4+x+1), D(x)=1101011011 a0=1, a1=1, a2=0,a3=0,a4=1 Q0 Q1 Q2 Q3 Q4 T(=D(x)Q4) 0 0 0 0 0 1 1 1 0 0 1 1 商 數 pass 10 clocks 0 1 1 1 pass 4 clocks 1 0 餘 數 System Check Encoder D(x) T(x) CRC Kernel Controller G(x)(setting) Decoder T(x) NoiseGenerator CRC Kernel G(x)(setting) Error Detection Checker 結果分析 1. 由發展系統中DIP開關控制欲傳送資料20bits 採循環方式, 經CRC編碼器送至解碼端 2. 接收資料加雜訊及不加雜訊, 在發展系統中的LED 觀看是否成果正確 Project-5 ITU_R656 Video Encoder/Decoder .目的: 使學生了解ITU_R656串序視訊資料原理, 並用FPGA驗証其功能, 增加實作能力 儀器及設備: 個人電腦, FPGA發展系統發展系 統及模擬軟体 原理 Communication Encoder Parallel Decoder Serial 學習如何在串序資料分別控制信號及 資料 Parallel Analog: gray-scale video (also called black-and-white)information. using analog RGB (red, green, blue) color video data. — A few short years ago :analog broadcast and cable television, analog VCRs, analog settop boxes with limited functionality, and simple analog video capture for the personal computer (PC) . Digital : video was confined to professional applications,such as video editing ,digital settop boxes, digital television (DTV), internet video transferring data. —Today we have: tremendous and rapid conversion to digital video, mostly based on the MPEG ,JPEG2000 ,and DV (Digital Video) standards. Figure 1 contains the RGB values for 100% amplitude, 100% saturated color Red, green, and blue three-dimensional, Cartesian coordinate system (Figure 1). Color Space: (1).Adjust data manage. (2).Computer use R.G.B (3).Television use YUV change type (Y Cb Cr or ITU-R656). (4).R.G.B Image is non-interlacing. (5).YCbCr Image is Interlacing . (6)Color Image technique occupied more bandwidth. image4 image3 image2 image1 Horizontal Scanning Vertical Scanning time Vertical Scanning Horizontal Scanning Field 1 Horizontal Scanning Field 2 8-bit Data D7 D6 D5 D4 D3 D2 D1 D0 [MSB] Status word 1 F V H P3 EAV And SAV Sequence P2 P1 P0 YUV, YIQ,and YCbCr color spaces PAL (Phase Alternation Line):China Italy Germany Australia 625scan-line/frame picture by modulation luminance 25frame/sec interlace amplitude transmission By subcarrier orthogonal chromimance balance mechanism NTSC (National Television System Committee):Taiwan,Japan,America. 525 scan-line/frame luminance picture by modulation 30frame/sec interlace amplitude transmission chromimance By subcarrier inverse phase mechanism SECAM(Sequentiel Couleur Avec Mémoire or Sequential Color with Memory): application was developed in France, with broadcasting starting in 1967. 625scan-line/frame 25 frame/sec interlace luminance chromimance Color Transform: (R,G,B) picture by modulation amplitude transmission By subcarrier modulation frequency (Y,Cb,Cr) Luminance:Y Chrominance:Cb,Cr •16*16 MacroBlock (three chrominance formats) 4:2:0 0 1 4 5 2 3 Y Cb Cr 4:2:2 4:4:4 0 1 44 5 0 1 4 8 5 2 3 6 7 2 3 6 10 7 11 Y Cb Cr Y Cb Cr 9 ITU-R 656 Video Decoder Function & Block Diagram Search Buffer Search Search Output for for the the control symbl Data Data signal “1 ” Cb “Yo “ FF F Y0 Cb 00 V Cr Cr, 00“٠ H” Y1 ” Y1 Cb Cr” Vdata_Out [ 23 : 0 ] [ 7 : 0 ]VD0_DataIn Clk 1 Resetz Video Decoder for ITUR656 Standard ITU-HDE ITU-V ITU-Field Clk 2 Program Block Diagram (一)Set up the buffer “VDO_Dout” [ 7: 0 ] VD0_DataIn BUFFER CLK1 VDO_Dout [ 7 : 0 ] (二)Search for Data “FF 00 00” Clk1 Resetz IF “resetz” V_DODout=FF V_DO Dout=00 V_DO Dout=00 & ITU_Cnt=1 & ITU_Cnt=2 & Syn_state=1 & Syn_state=2 ITU_Cnt=3 Else ITU_Cnt=0 ITU_Cnt=1 ITU_Cnt=2 ITU_Cnt=3 ITU_Cnt=0 ITU_Cnt= ITU_Cnt+ 1 Sync_state=0 Sync_state=1 Sync_state=2 Sync_state=3 Sync_state=0 Sync_state=0 (三)Search for Symbol ” 1 F V H ” Clk 1 resetz [7:0] VD_0Dout IF resetz Sync_state IF IF V_DO Dout [7] =1 V_DO Dout [4] & & Sync_state = 3 V_DO Dout [5] =1 else ITU_F=0 ,ITU_V=0 ITU_F= V_DO Dout [6] ITU_H=0 ITU_V= V_DO Dout [5] ITU_H=1 ITU_H=0 (四)Search the Data”CbY0Cr Y1”And put [7:0] VD_O Dout*3 into [23:0]VData IF CLK1 ITU-Cnt=2 Vdata[23:16]<= VDODout[7:0] ITU-Cnt=1 Vdata[15:8]<= VDODout[7:0] or =3 ITU-Cnt=0 Vdata[7:0]<=V DODout[7:0] (五)Output the Data”Cb Y0 Cr Y1” Clk1 Cb=ITU_Cnt ==0 if Vdata_out[23:16] ITU_Cnt=3 Vdata_out[23:16]<=Vdata_out[23:16] “Y0=ITU_Cnt ==1 “Cr=ITU_Cnt ==2 “Y1=ITU_Cnt ==3 Vdata[23:16] ITU_Cnt= Vdata_out[15:8] Vdata[15:8] 1 or3 Vdata_out[15:8]<= Vdata _out[15:8] ITU_Cnt=3 Vdata_out[7:0] Vdata[7:0] Vdata_out[7:0] <= Vdata _out[7:0] 8.實例設計6- Micro-processor與FPGA 共同設計可程式函數波產生器 .目的: 使學生了解作軟硬体共同設計, 增加實作能力 儀器及設備: 個人電腦, FPGA發展系統發展系 統及模擬軟体, 示波器 原理 Software and Hardware共同設計 1. Software: low speed, human interactive Changeable, Flexible Ex. Keyboard,LCD display 2. Hardware : High Speed, non-changed part Ex. Control Circuit (clock based),Computations, Timing Constraint 軟体送命令給硬体 System Block of Function Generator LCD DAC FPGA Output Waveform Micro Keyboard Micro Processor 控制輸出波型選擇 採用4x4鍵盤 0 4 1 2 5 8 C 9 D 6 A F: Enter E 3 7 0~9 控制頻率値 A: K or M選擇 B B :選擇三角波 正弦波 方波 F Software LCD Driver Main Control Kernel Keyboard Scanning To FPGA 20bit 可定頻 1Hz~1MHz* Hardware 三角波:用100點組成一週期三角波 If Clock=100MHz, the output max. Frequency=1MHz 用Delay Loop 控制頻率 三角波設計: 用Up Counter-50 and Down-Counter-50 100 100 Delay Loop 控制 設計 1.1us delay模組 2. 10 us delay模組 3. 100us delay模組 4. 1ms delay模組 5. 10ms delay模組 如果要産生 3k頻率 3k=33.3us 3*10us=30us 3*1us=3us 呼叫一次 10us and 1us模組 正弦波産生器 三角波 輸入 正弦 波形 修正 正弦波 輸出 Sin (2*3.6*n/360) n=1,..100 1. Use C or Mathlab find sine value 2. Built in these values with ROM for mapping n 1 2 3 4 Delay Control : 三角波相同 ROM Table 方波産生器 1.最快頻率=系統頻率 直接clock輸出 2.第二快頻率=系統頻率/2 T B T,B各一點 3.第三快頻率=系統頻率/4 TB各二點 Even-based 4,6,8,10,12,,,,, If the system clock=100Mhz 方波輸出頻率=2.4Mhz 1/2.4M=416ns 1/100M=10ns T B T=B=213ns T,B 各取21點 産生21*2*10=420ns 1/420ns=2.38MHz 歩驟: 1. Set the System Frequency First ( from micro-processor) 2 Input the output frequency 3.Compute the T,B points in Micro 4.Output T,B value to FPGA 5. IN FPGA, Set output=1 in T period Set output=0 in B period 結果分析 1. 由微處理器 決定波形種類及頻率 2. 由發展系統中D/A輸出端用示波器 觀察是否合乎預期 測量系統最高最低頻率及輸出挀幅
© Copyright 2025 ExpyDoc