第三章 FBP 演算法嵌入式系統實作
3.2 FBP 建立及系統設定
3.2.2 建立 FBP 元件及連結其週邊
這裡使用 EDK 軟體所提供的 Create/Import Peripheral Wizard 幫我們建立 自己的週邊元件,首先用 Create Peripheral wizard 建立 FBP 元件。關於 FBP 元件的硬體描述,我們將最上層電路的 VHDL 模組,取名為 fbp,然後將 FBP 元 件連接上 PLB Bus,如圖 3-3 所示。
連上 PLB Bus
FBP 元件
圖 3-3 Add/Edit Hardware Platform Specifications
到目前為止我們訂下了整個系統最初步的架構,包含了 FBP 元件以及各個
z CompactFlash 與 RS232_Uart:
RS232_Uart 的功用是可以讓我們透過 terminal 程式經由 serial port 與系統溝 通。而 Compact Flash 則讓我們可以透過 System ACE CF Controller 控制 CompactFlash card,作為 sinogram 影像及完成重建後影像的儲存設備。如下圖所 示,其中 Input sonogram image 以及 Output reconstructed image 都是利用此一 CompactFlash card 來完成。
圖 3-5 FBP 簡易流程圖
而由於我們的 FBP 程式要能讀取 CompactFlash card 上的 sinogram 影像以及
Input
sinogram image Filter Backproject Output
reconstructed image
PLB2OPB
將重建結果回存,所以我們需要一個可以讀寫 CompactFlash card 的函式庫。在 這部分 Xilinx 公司有提供一個名稱為 xilfatfs 的函式庫可以幫助我們達成此功 能,其使用方式只要在 EDK 的 Software Platform Settings 中勾選此函式庫,並在 軟體端的程式中包含 xsysace.h 及 sysace_stdio.h 兩個標頭檔,如此一來即可順利 讀寫 CompactFlash card。此外,由於 RS232_Uart 及 SysAce_CompactFlash 本身 是比較慢的週邊設備,因此將之與 OPB Bus 連接。
Interfaces PLB bus
圖 3-6 IPIF 與 IP 模組及 PLB bus 之間的關係
由圖 3-6 我們可以看出,FBP 元件與 PLB bus 之間的溝通方式其實是利用 EDK 所提供的 IP Interface(IPIF)框架,它可以提供使用者建立的 IP 模組與 on-chip buses 之間的溝通介面服務,主要包含兩個介面,分別是對 PLB bus 的介面及對 IP 模組的介面。
利用 IPIF 提供的溝通介面服務,我們可以決定使用者的元件與 Bus 間資料 的溝通方式,主要提供了下列幾項:
z S/W Reset and Module Information register(RST/MIR) z Burst and Cacheline Transaction Support
z DMA z FIFO
z User Logic Interrupt Support z User Logic S/W Register Support z User Logic Master Support
z User Logic Address Range Support
在我們的設計中選擇了 S/W Reset and Module Information register(RST/MIR) 及 User Logic S/W Register Support 這兩項來滿足我們的基本需求,其主要功能就 是讓我們定義出 32 個 64bits 的暫存器供我們使用,透過這些暫存器,我們可以
Signal Name I/O Description
Bus2IP_Clk O IPIC clock provided to IP. This
PLB_CLk
Bus2IP_Reset O Active high reset for use by the User IP.
Bus2IP_Data(0:C_IPIF_DWIDTH-1) O Write data bus to the User IP. Write data is accepted by the IP during a write operation by assertion of the
IP2Bus_WrAck signal and the rising edge of the Bus2IP_Clk.
Bus2IP_BE(0:(C_IPIF_DWIDTH/8)-1) O Byte enable qualifiers for the requested read or write operation with the User IP.
Bit 0 corresponds to Byte lane 0, Bit 1 to Byte lane 1, and so on.
Bus2IP_RdCE(0: see note 1) O Active high chip enable bus. Chip enables are assigned per the User’s entries in the
C_ARD_NUM_CE_ARRAY. These chip enables are asserted only during active read transaction requests with the target address space and in conjunction with the corresponding sub-address within the space.
Bus2IP_WrCE(0: see note 1) O Active high chip enable bus. Chip enables are assigned per the User’s entries in the
C_ARD_NUM_CE_ARRAY. These chip enables are asserted only during active write transaction requests with the target address space and in conjunction with the corresponding sub-address within the space.
Bus2IP_RdReq O Active high signal indicating the
initiation of a read operation with the IP. It is asserted for 1 Bus2IP_Clk during single data beat transaction and remains high to completion on burst write operations.
Bus2IP_WrReq O Active high signal indicating the
initiation of a write operation with the IP. It is asserted for 1 Bus2IP_Clk during single data beat transaction and remains high to completion on burst
write operations.
IP2Bus_Data(0:C_IPIF_DWIDTH-1) I Input Read Data bus from the User IP.
Data is qualified with the assertion of IP2Bus_RdAck signal and the rising edge of the Bus2IP_Clk.
IP2Bus_Retry I Active high signal indicating the User
IP is requesting a retry of an active operation. This signal is currently unused by the PLB IPIF.
IP2Bus_Error I Active high signal indicating the User
IP has encountered an error with the requested operation. This signal is asserted in conjunction with
IP2Bus_RdAck or the IP2Bus_WrAck.
IP2Bus_ToutSup I Active high signal requesting
suppression of the data phase time-out function in the IPIF for the active read or write operation.
IP2Bus_RdAck I Active high read data qualifier. Read
data on the IP2Bus_Data Bus is deemed valid at the rising edge of Bus2IP_Clk and the assertion of the IP2Bus_RdAck signal by the User IP.
IP2Bus_WrAck I Active high write data qualifier. Write
data on the IP2Bus_Data Bus is deemed accepted by the User IP at the rising edge of the Bus2IP_Clk and
IP2Bus_WrAck asserted high by the User IP.
表 3-1 PLB IPIF I/O Signals
完 成 FBP 元 件 建 立 後 , 會 產 生 兩 個 重 要 的 檔 案 , 分 別 是 fbp.vhd 及 user_logic.vhd。其中 fbp.vhd 是 FBP 元件的最上層 VHDL 模組,而 user_logic.vhd 則是我們程式實作成硬體的地方。接下來我們必須把建立出來的 FBP 元件加入 整個設計之中,所以利用 EDK 內的 Import Peripheral Wizard,執行後 EDK 軟體 會將 FBP 元件的資訊記錄在 MHS 檔案中,也就是前面提到的硬體規格檔 (Microprocessor Hardware Specification)。
圖 3-7 將 FBP 元件加入設計之示意圖
在將 FBP 元件加入整個設計之中以後,基本上我們就完成了整個架構的建 立了,而接下來我們還會繼續介紹有關 IP 的使用以及 FBP 元件的實作等部份。
User Logic
system.mhs fbp.vhd
plb_ipif opb_v20
plb_ipif
Bus_Bridge ppc_405
IPIC fbp
user_logic.vhd
plb_v34 User Logic