480 likes | 655 Views
硬體實作 軟體實作. Hello World 軟 / 硬體實作. DE2_70. NIOS II Program. SOPC(FPGA). System Interconnect Fabric. 50MHZ. RESET_N(1). NIOS II Processor. On-Chip Memory. POWER. LCD Controller. LCD. PC. USB Blaster. JTAG UART. System Block Diagram. 功能 : 於 LCD 顯示 “ Hello World”.
E N D
硬體實作 軟體實作 Hello World 軟/硬體實作
DE2_70 NIOS II Program SOPC(FPGA) System Interconnect Fabric 50MHZ RESET_N(1) NIOS II Processor On-Chip Memory POWER LCD Controller LCD PC USB Blaster JTAG UART System Block Diagram • 功能: 於LCD 顯示 “Hello World”
建立 Quartus Project 建立 SOPC 完成Quartus Top Compile/Download Hello World “硬”體實作
1.建立 Quartus Project 建立QUARTUS Project
Windows Menu “開始所有程式AlteraQuartus II 7.2 (32-btis)” Start Quartus 建立QUARTUS Project
Qaurtus Menu “FileNew Project Wizard…” Start“New Project Wizard…” 建立QUARTUS Project
Specify Project Info. 建立QUARTUS Project
Add Project Files 建立QUARTUS Project
Select FPGA 建立QUARTUS Project
Select EDA Tool 建立QUARTUS Project
Confirm/Finish 建立QUARTUS Project
2.建立 SOPC 建立 SOPC
啟動 SOPC Builder • 於Qaurtus 下啟動SOPC Builder • 選單 “Tools SOPC Builder…”, 或 • 按下 SOPC Builder ICON 建立 SOPC
輸入 SYSTEM 資訊 建立 SOPC
Add “On-Chip Memory” 建立 SOPC
Add “NIOS II Processor” 建立 SOPC
Add “JTAG UART” 建立 SOPC
Add “LCD” 建立 SOPC
完成SOPC 設計 建立 SOPC
Generate Code - DE2_70_SOPC.V (top) - DE2_70_SOPC.PTF 建立 SOPC
SOPC_DE2_70_SOPC.v (內容) 建立 SOPC
SOPC_DE2_70_SOPC.v(SYMBLE) 建立 SOPC
3. 完成Quartus Top 完成Quartus Top
目的:連接SOPC與週邊 完成Quartus Top
New Verilog File 完成Quartus Top
Rename Verilog File 完成Quartus Top
Coding MY_FIRST_SOPC.v module MY_FIRST_SOPC ( //////////////////// Clock Input //////////////////// iCLK_50, // 50 MHz //////////////////// LCD Module 16X2 //////////////// oLCD_ON, // LCD Power ON/OFF oLCD_BLON, // LCD Back Light ON/OFF oLCD_RW, // LCD Read/Write Select, 0 = Write, 1 = Read oLCD_EN, // LCD Enable oLCD_RS, // LCD Command/Data Select, 0 = Command, 1 = Data LCD_D, // LCD Data bus 8 bits ); 完成Quartus Top
Port Declaration // PORT declarations //================================================== //////////////////////// Clock Input //////////////////////// input iCLK_50; // 50 MHz //////////////////// LCD Module 16X2 //////////////////////////// inout [7:0] LCD_D; // LCD Data bus 8 bits output oLCD_ON; // LCD Power ON/OFF output oLCD_BLON; // LCD Back Light ON/OFF output oLCD_RW; // LCD Read/Write Select, 0 = Write, 1 = Read output oLCD_EN; // LCD Enable output oLCD_RS; // LCD Command/Data Select, // 0 = Command, 1 = Data 完成Quartus Top
Power On LCD //========== 16*2 LCD Module assign oLCD_ON = 1'b1; // LCD ON assign oLCD_BLON = 1'b1; // LCD Back Light 完成Quartus Top
Connect SYSTEM // Structural coding //================================================== DE2_70_SOPC u1 ( // 1) global signals: .clk(iCLK_50), .reset_n(1), // the_lcd .LCD_E_from_the_lcd(oLCD_EN), .LCD_RS_from_the_lcd(oLCD_RS), .LCD_RW_from_the_lcd(oLCD_RW), .LCD_data_to_and_from_the_lcd(LCD_D) ); endmodule 完成Quartus Top
Pin Assignment - Analysis • 選單 “FileSave” save “MY_FIRST_SOPC.V” • 選單 “ProcessingStartStart Analysis & Elaboration” 完成Quartus Top
開啟Pin Planner 完成Quartus Top
輸入PIN角位置 滑鼠雙擊後, 打B2 完成Quartus Top
4. Compile/Download Compile/Download
Compile Compile/Download
1 3 2 4 Download • DE2_70 左邊SWITCH 須切至 “RUN” Compile/Download
2 1 3 No USB-Blaster? Compile/Download
Start NIOS II IDE 7.2 • Windows選單“開始所有程式AlteraNIOS II EDS 7.2NIOS II IDE 7.2” New Project
Setup Workspace • 選單“FileSwitch Workspace…” C:\DE2_70\MY_FIRST_SOPC\ software\project_hello New Project
3 4 1 C:\DE2_70\MY_FIRST_SOPC\ DE2_70_SOPC.ptf 2 5 New Nios Project • 選單“FileNewNios II C/C++ Application” New Project
Editor Project Management NIOS II IDE 介面 Coding
Coding – hello_world.c #include <stdio.h> #include <stdlib.h> #include "system.h" void hello_lcd(void); int main() { printf("Hello from Nios II!\n"); hello_lcd(); return 0; } • void hello_lcd(void){ • FILE *pLCD; • char szHello[] = "DE2_70\nHello\n"; • pLCD = fopen(LCD_NAME, "w"); • if (pLCD){ • fwrite(szHello, strlen(szHello), 1, pLCD); • //fclose(pLCD); • }else{ • printf("failed to open LCD\n"); • } • } Coding
Menu “ProjectBuild All” Sytem.h Compile Compile
Download Hardware .SOF • Menu “ToolsQuartus II Progammer” 5 3 2 1 C:\DE2_70\MY_FIRST_SOPC\ MY_FIRST_SOPC.sof 4 Download HW
2 1 Run Run
Run Configuration Target Connection NIOS II Hardware 1.滑鼠 左鍵雙擊 3 2 4 只有第一次未指定硬體時 才會出現此畫面 5 Run
結果 • LCD 上出現 • NIO2 IDE Console 出現 DE2_70 Hello Run