Upload
-
View
208
Download
4
Embed Size (px)
Citation preview
1
林俊瑋、李柏毅
指導老師:蘇文鈺教授
自己要用的工具自己做
以OpenRISC為基礎的千核心處理器的異質軟硬體整合專案
2
成果示意1. 開啟 GUI
2. 透過一條 USB 連接 Host 與 FPGA
3. 按下「Run」將 C code program 到硬體端讓
OpenRISC core 做運算
3
Outline
•動機
•事前準備
•系統介紹
4
動機
• 多核心通用運算平台
• CPU Visualization:能夠看到底層 core 的運作
• 修改 CPU 或記憶體架構,提供研究的驗證平台
• 在硬體電路中插入 performance counter 做分析
5
Outline
•動機
•事前準備
•系統介紹
6
事前準備
• CPU架構:OpenRISC(Open source
Reduced Instruction Set Computer)
• 實作平台:FPGA
• 軟硬體溝通介面:SMIMS Tool
7
OpenRISC
本系統使用最小化的OpenRISC system
Wis
hbone B
US
Master
Slave
UART
RAM
OpenRISC
core
OpenRISC system
8
事前準備
• CPU架構:OpenRISC
•實作平台:FPGA
•軟硬體溝通介面:SMIMS Tool
9
Programmer
FPGA
FPGA
OpenRISC_v2.bitOpenRISC_v1.bit
Reset
10
事前準備
• CPU架構:OpenRISC
•實作平台:FPGA
•軟硬體溝通介面:SMIMS Tool
11
SMIMS Tool
12
系統架構
SMIMS
Tool
FPGA
OpenRISC system
OpenRISC system
OpenRISC system
OpenRISC system
Software Hardware
結合三種既有工具
13
Outline
•動機
•事前準備
•系統介紹
14
系統介紹
• UART
• Header
• Return information from OpenRISC
• Baton API
• GPIO
• GUI
15
UART
• 動機
• 為 Multi core 考量,減少RS232接線,使用一條USB即可處理所有輸出
FPGA
OpenRISC system TX / RX
OpenRISC system TX / RX
OpenRISC system TX / RX
OpenRISC system TX / RX缺點:每個 core 需要一組TX / RX
RS232
RS232
RS232
RS232
16
標準的 UART 輸出
OpenRISC system
UART TX / RX
要被 UART
print 的字元 經過 UART
module 轉換成類比訊號
透過RS232做序列傳輸
Wis
hbone B
US
OpenRISC
Core
UART
data
17
FPGA
改變輸出方式
OpenRISC
core
Control FSM
UARTUART
data
OpenRISC system
UART print
Data
register
紅線代表 Data path
黃線代表 Control path
SMIMS
Tool
從 UART module 中找出 UART
print 的控制訊號,並接到 FSM
將要輸出的資料先存到我們新增的 register 中
FSM 判斷此時可以進行輸出
透過SMIMS
Tool 傳到軟體層
18
UART
• 綜上所述,只要從 UART module 中拉出下列訊號,就可以達成 UART print 的功能
1. 控制訊號
2. 需要回傳的資料
• 另外加入兩套機制協助運作
1. Flag:紀錄各 core 是否需要做 UART print
2. Round robin:為確保公平,避免同個 core 持續占用輸出的通道
19
UART
• Example:
1. Core0 與 Core1 同時要做 UART print
2. 先處理 Core0
3. 此時 Core0 又有新的 UART print
4. 按照 Round robin 的機制會先處理 Core1
5. 最後再處理 Core0
0 0
core0 core1
UART_flag 1 1
20
系統架構
SMIMS
Tool
Control FSM
FPGA
OpenRISC
system
OpenRISC
system
OpenRISC
system
OpenRISC
system
Data
register
此 model 只能用作UART 回傳嗎?
遵循此 model,可以回傳任何我們想知道的訊息
UART print
UART
print data
Software Hardware
新增 UART 相關電路
黃色區塊:我們實作的項目
21
系統介紹
• UART
• Header
• Return information from OpenRISC
• Baton API
• GPIO
• GUI
22
Header
• 各種資料經由相同的通道傳輸,Host 該如何識別?
• 參考網路協定中的封包架構
• 在資料前端加上 header,經 Host 端做 parse 後即可辨別 data
type 與 core ID
Data type Core ID 實際資料
23
系統介紹
• UART
• Header
• Return information from OpenRISC
• Baton API
• GPIO
• GUI
24
Return information from OpenRISC
1. 目前僅實作回傳 PC值 ( Program Counter )
2. 未來將從 OpenRISC 中拉出更多訊號線
• General purpose registers
• ALU 的 input / output、opcode
• ……
3. 藉以達成 CPU visualization 的功能
25
系統架構
Baton
APISMIMS
Tool
Control FSM
FPGA
OpenRISC
system
OpenRISC
system
OpenRISC
system
OpenRISC
system
Data
register
Software Hardware
除了硬體架構外,還需要與FSM 相對應的 API
黃色區塊:我們實作的項目
26
系統介紹
• UART
• Header
• Return information from OpenRISC
• Baton API
• GPIO
• GUI
27
Baton API
初始化相關設定
解析 header 內容
釋放相關資源
初始化 OpenRISC system的 RAM
對 RAM 的任意位置寫值
對 RAM 的任意位置讀值啟動底層 core 開始運作
28
Stall
Control FSM
Hardware Software
OpenRISC
system_0
OpenRISC
system_1
OpenRISC
system_2
StallStall
時間軸
Program()
RAM_0 RAM_1 RAM_2
功能簡介:從 Host 端將 RAM
的初始檔傳到OpenRISC system
的 RAM 中
29
OpenRISC
system_2OpenRISC
system_1OpenRISC
system_0
Stall
Control FSM
Hardware Software
StallStall
時間軸
Start()RAM_0 RAM_1 RAM_2
功能簡介:解除底層所有 core 的stall 訊號
30
Hardware Software
OpenRISC
system_0
OpenRISC
system_1
OpenRISC
system_2
時間軸
Parse()
PC
Data
register
UART
data
Control FSM
功能簡介:解析來自 OpenRISC core
的資料,辨別 data type 與core ID。目前的 type 包含:1. PC ( Program Counter )
2. UART
3. End of core
31
Stall
Control FSM
Hardware Software
OpenRISC
core0
OpenRISC
core1
OpenRISC
core2
StallStall
時間軸
RAM_0 RAM_1 RAM_2
Receive()
功能簡介:可以對 RAM 的特定區間( start address ~ start
address + size ) 讀值
32
紅框的 state 用於與 API handshaking
Control
FSM
33
系統架構
Baton
APISMIMS
Tool
Control FSM
FPGA
OpenRISC
system
OpenRISC
system
OpenRISC
system
OpenRISC
system
Data
register
不想讓 OpenRISC core
只是單純的運算單元
還希望 core 具有控制周邊設備的能力
Software Hardware黃色區塊:我們實作的項目
34
系統介紹
• UART
• Header
• Return information from OpenRISC
• Baton API
• GPIO
• GUI
35
GPIO
OpenRISC system
RAM
Core
GPIO_register
Redirector
Wishbone BUS
Core 透過 BUS
連接 RAM
新增 Redirector,當Core讀取特定位址時會導向GPIO register
最後將 GPIO_register
assign 到 FPGA上的GPIO port
36
GPIO –示波器驗證
• 令 GPIO port 做0-1-0-1-……的輸出
37
Software Hardware
系統架構
Baton
API
SMIMS
Tool
Control FSM
FPGA
OpenRISC
system
OpenRISC
system
OpenRISC
system
OpenRISC
system
Data
register
Host
(GUI)
基於 Baton API
往上實作 Host
端的 GUI
新增 GPIO 相關電路
黃色區塊:我們實作的項目
38
系統介紹
• UART
• Header
• Return information from OpenRISC
• Baton API
• GPIO
• GUI
Host 架構
39
Kernel
Program
40
Kernel
Program
• 於終端機下執行
• 編譯專案原始碼以及交付FPGA開發板或模擬器執行的管理中樞
• 加入FPGA開發板所需的SDK
並且重新包裝為Baton API
Host 架構
41
Kernel
Program
FPGA
Board
Program • Kernel Program 將 OpenRISC
電路檔燒錄至開發板上• Kernel Program將專案程式傳送至開發板上後即可執行
• Kernel Program回收執行結果及UART訊息
Host 架構
42
Kernel
Program
FPGA
Board
Program • Kernel Program 呼 叫Or1ksim並且傳入設定檔及專案程式
• Kernel Program回收執行結果及UART訊息
Or1ksim
System
Call
43
Or1ksim
sim_init exec_main
dump
memory
自動輸入指令
44
Or1ksim
void handle_sim_command (void)
void handle_sim_command_simplified
(char *cmd)
去除使用者輸入指令的部分
45
Or1ksim
sim_init exec_main
dump
memorysim_done
Host 架構
46
Kernel
ProgramGUI
Socket
• GUI發送編譯或執行專案的要求
• Kernel Program回應要求、回傳UART訊息FPGA
Board
Program
Or1ksim
System
Call
47
• 利用Qt library開發的視窗程式介面
• 以C++為基底
• 強大的GUI及各式各樣的API函式庫
• 良好移植性,可在各平台上開發
GUI
48
• 提供專案管理(新增/儲存等)功能• 選擇運作平台為FPGA開發板或者模擬器
• 按下執行後即可將任務提交至FPGA
開發板或者模擬器執行,結束後將可以取得變動後的RAM資料
49
• 一個tab代表一個core
• 每個core都有三個區塊,分別顯示C
code、assembly code以及memory block
50
• 可以選擇載入的C code
• 顯示行號及highlight
• 可開啟外部編輯器(例如Gedit)
進行編輯• 按下編譯後即可產生assembly
code以及memory block資料
51
• 顯示行號及highlight
• 可開啟外部編輯器進行編輯
• 按下compile後會根據修改過的assembly code進行編譯
52
• 展示專案執行檔執行前後的RAM資料• 不同的背景色分別不同功能• 內容不同處提供紅色字體標記• 搜尋指定記憶體位址
53
• 輸出編譯或UART訊息• 可調整輸出文字大小
未來開發項目• 可視覺化CPU(CPU Visualization)
54
未來開發項目• 可視覺化CPU(CPU Visualization)
55
功能展示
56
Q & A
• 若對本系統有興趣,歡迎來信討論
• 林俊瑋:[email protected]
• 李柏毅:[email protected]
• Source code 下載
• http://ruru.csie.ncku.edu.tw/openrisc_tools/
57