sopc/niosii 設計與實作課程 © 2007 terasic corporation 1 hello world 軟 / 硬體實作...

Post on 12-Jan-2016

245 Views

Category:

Documents

12 Downloads

Preview:

Click to see full reader

TRANSCRIPT

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

1

Hello World Hello World 軟軟 // 硬體實作硬體實作

• 硬體實作• 軟體實作

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

2

System Block Diagram

DE2_70

50MHZ

SOPC(FPGA)

On-ChipMemory

LCDController

NIOS IIProcessor

JTAGUART

System

Interco

nn

ect Fab

ric

LCD

RESET_N(1)

USBBlaster

PC

NIOS IIProgram

POWER

• 功能 : 於 LCD 顯示 “ Hello World”

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

3

Hello World “Hello World “ 硬”體實作硬”體實作

1. 建立 Quartus Project

2. 建立 SOPC

3. 完成 Quartus Top

4. Compile/Download

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

4

1.建立 Quartus Project

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

5

Start Quartus• Windows Menu “ 開始所有程式

AlteraQuartus II 7.2 (32-btis)”

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

6

Start“New Project Wizard…”• Qaurtus Menu “FileNew Project

Wizard…”

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

7

Specify Project Info.

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

8

Add Project Files

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

9

Select FPGA

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

10

Select EDA Tool

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

11

Confirm/Finish

建立 QUARTUS Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

12

2.建立 SOPC

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

13

• 於 Qaurtus 下啟動 SOPC Builder– 選單 “ Tools SOPC Builder…”, 或– 按下 SOPC Builder ICON

啟動 SOPC Builder

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

14

輸入 SYSTEM 資訊

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

15

Add “On-Chip Memory”

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

16

Add “NIOS II Processor”

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

17

Add “JTAG UART”

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

18

Add “LCD”

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

19

完成 SOPC 設計

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

20

Generate Code- DE2_70_SOPC.V (top)- DE2_70_SOPC.PTF

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

21

SOPC_DE2_70_SOPC.v (內容 )

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

22

SOPC_DE2_70_SOPC.v(SYMBLE)

建立 SOPC

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

23

3. 完成Q uartus Top

完成 Quartus Top

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

24

目的 : 連接 SOPC與週邊

完成 Quartus Top

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

25

New Verilog File

完成 Quartus Top

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

26

Rename Verilog File

完成 Quartus Top

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

27

Coding MY_FIRST_SOPC.vmodule 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

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

28

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

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

29

Power On LCD//========== 16*2 LCD Module

assign oLCD_ON = 1'b1; // LCD ON

assign oLCD_BLON = 1'b1; // LCD Back Light

完成 Quartus Top

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

30

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

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

31

Pin Assignment - Analysis• 選單 “ FileSave” save

“MY_FIRST_SOPC.V”

• 選單 “ ProcessingStartStart Analysis & Elaboration”

完成 Quartus Top

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

32

開啟 Pin Planner

完成 Quartus Top

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

33

輸入 PIN角位置

完成 Quartus Top

滑鼠雙擊後 , 打

B2

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

34

4. Compile/Download

Compile/Download

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

35

Compile

Compile/Download

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

36

Download

13 2

4

• DE2_70 左邊 SWITCH 須切至 “ RUN”

Compile/Download

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

37

No USB-Blaster?

1

2

3

Compile/Download

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

38

Hello World “Hello World “ 軟”體實軟”體實作作

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

39

Start NIOS II IDE 7.2• Windows 選單“開始所有程式

AlteraNIOS II EDS 7.2NIOS II IDE 7.2”

New Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

40

Setup Workspace• 選單“ FileSwitch Workspace…”

C:\DE2_70\MY_FIRST_SOPC\software\project_hello

New Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

41

New Nios Project• 選單“ FileNewNios II C/C++ Application”

1

2

34

5

C:\DE2_70\MY_FIRST_SOPC\DE2_70_SOPC.ptf

New Project

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

42

NIOS II IDE 介面

Coding

Editor

Project Management

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

43

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

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

44

• Menu “ProjectBuild All”

• Sytem.h

Compile

Compile

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

45

Download Hardware .SOF• Menu “ToolsQuartus II Progammer”

1

23

4

5

Download HW

C:\DE2_70\MY_FIRST_SOPC\MY_FIRST_SOPC.sof

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

46

Run

Run

1

2

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

47

Run Configuration

1.滑鼠左鍵雙擊

Run

2

3

4

5

NIOS II Hardware Target Connection

只有第一次未指定硬體時才會出現此畫面

SOPC/NIOSII設計與實作課程

© 2007 Terasic Corporation

48

• LCD 上出現

• NIO2 IDE Console 出現

結果

DE2_70Hello

Run

top related