動作確認
Vivado 2015.4 on Windows 8.1 pro
Vivadoでの作業 > IPの作成
http://qiita.com/7of9/items/9e46cb1f83a9c6935780
の流れに従いIPを作ってみた。
- Display name: myip_v1.0
- IP location: 160604ip_repo
XSDKでの作業
Repository追加
関連 http://qiita.com/7of9/items/710614ec6d0d15ab11ed
RepositoriesにVivadoで作成したIPを追加 (160604ip_repo)。
xparameter.h
XSDKにて作成したBSPのxparameters.hにてMYIPで検索すると以下が見つかった。
/******************************************************************/
/* Definitions for driver MYIP */
#define XPAR_MYIP_NUM_INSTANCES 1
/* Definitions for peripheral MYIP_0 */
#define XPAR_MYIP_0_DEVICE_ID 0
#define XPAR_MYIP_0_S00_AXI_BASEADDR 0xFFFFFFFF
#define XPAR_MYIP_0_S00_AXI_HIGHADDR 0x00000000
myip_selftest.c
BSP > ps7_cortexa9_0 > libsrc > myip_v1_0 > srcに myip_selftest.cというファイルがある。
中身を見るとテスト用の関数が用意されている。
myip_selftest.c
XStatus MYIP_Reg_SelfTest(void * baseaddr_p)
{
u32 baseaddr;
int write_loop_index;
int read_loop_index;
int Index;
baseaddr = (u32) baseaddr_p;
xil_printf("******************************\n\r");
xil_printf("* User Peripheral Self Test\n\r");
xil_printf("******************************\n\n\r");
/*
* Write to user logic slave module register(s) and read back
*/
xil_printf("User logic slave module test...\n\r");
for (write_loop_index = 0 ; write_loop_index < 4; write_loop_index++)
MYIP_mWriteReg (baseaddr, write_loop_index*4, (write_loop_index+1)*READ_WRITE_MUL_FACTOR);
for (read_loop_index = 0 ; read_loop_index < 4; read_loop_index++)
if ( MYIP_mReadReg (baseaddr, read_loop_index*4) != (read_loop_index+1)*READ_WRITE_MUL_FACTOR){
xil_printf ("Error reading register value at address %x\n", (int)baseaddr + read_loop_index*4);
return XST_FAILURE;
}
xil_printf(" - slave register write/read passed\n\n\r");
return XST_SUCCESS;
}
application
New > Application Projectにて以下の実装をした。
- xparameters.hとmyip.hのincludeを追加。
- MYIP_Reg_SelfTest(XPAR_MYIP_0_S00_AXI_BASEADDR);を使用
- baseaddr_pはxparameters.hに定義されているXPAR_MYIP_0_S00_AXI_BASEADDRを指定 (正解かは不明)
helloworld.c
#include <stdio.h>
#include "platform.h"
#include <xparameters.h>
#include <myip.h>
void print(char *str);
int main()
{
init_platform();
print("Hello World\n\r");
XStatus sts;
sts = MYIP_Reg_SelfTest(XPAR_MYIP_0_S00_AXI_BASEADDR);
if (sts == XST_SUCCESS) {
print("MYIP selftest OK\r\n");
} else {
print("MYIP selftest NG\r\n");
}
cleanup_platform();
return 0;
}
実行すると一応動いているが、詳細を理解できていない。
Hello World
******************************
* User Peripheral Self Test
******************************
User logic slave module test...
- slave register write/read passed
MYIP selftest OK