Vengineerの妄想(準備期間)

人生は短いけど、長いです。人生を楽しみましょう!

BluespecのAWSteria_Infraを調べる(その2)

はじめに

の続き、

今日は、Host側のプログラムの中を調べていきます。

Host側のプログラム

Host側のテストプログラムは、TestApp/Host/main.c です。

HW側のPlatformは、VCU118として動作していますので、マクロ PLATFORM_VCU118 が定義されています。

$ cd TestApp/Host/build_sim
 ./exe_Host_sim
INFO: TestApp host-side built for simulation of Platform VCU118
    ddr_A_base = 0x               0  ddr_A_lim = 0x        80000000
    ddr_B_base = 0x        80000000  ddr_B_lim = 0x       100000000
    out_of_bounds_addr                         = 0x       100000000

ここで AWSteria host-side API libs を読んで、tcp_client_open 関数にて、IPアドレス(127.0.0.1)、ポート番号(30000)でHW側と通信しています。

Initializing AWSteria host-side API libs
tcp_client_open: connecting to '127.0.0.1' port 30000
tcp_client_open: connected

この部分は、ここで、下記のようなコードになっています。AWSteria_Host_init関数を実行しています。

    // ----------------------------------------------------------------
    // Initialize AWSteria host-side API libs

    fprintf (stdout, "Initializing AWSteria host-side API libs\n");
    AWSteria_Host_state = AWSteria_Host_init ();
    if (AWSteria_Host_state == NULL) goto ret_err;

Platform_Sim/Host/AWSteria_Host_lib.cのここで、AWSteria_Host_init 関数を定義しています。

void *AWSteria_Host_init (void)
{
    if (verbosity_init > 0)
    fprintf (stdout, "%s()\n", __FUNCTION__);

    if (awsteria_host_state.p_bytevec_state != NULL) {
    fprintf (stdout, "WARNING: %s: already initialized\n", __FUNCTION__);
    return (& awsteria_host_state);
    }

    awsteria_host_state.p_bytevec_state = mk_Bytevec_state ();
    if (awsteria_host_state.p_bytevec_state == NULL) {
    fprintf (stdout, "ERROR: %s: mk_Bytevec_state failed\n", __FUNCTION__);
    exit (1);
    }

    uint32_t status = tcp_client_open (DEFAULT_HOSTNAME, DEFAULT_PORT);
    if (status == status_err) {
    fprintf (stdout, "ERROR: %s: failed\n", __FUNCTION__);
    exit (1);
    }

    if (verbosity_init > 0)
    fprintf (stdout, "%s: initialized, connected to simulation server\n", __FUNCTION__);

    return (& awsteria_host_state);
}

次にデータの準備をします。

Filling wbuf with random data
    filled wbuf with random data

コードは、ここに あります。

以降、テストを開始します。コードは、ここです。

Performing tests ...

test0: ----------------
AXI4: Single-byte write, base_addr 0x0
AXI4: Single-byte read, base_addr 0x0

test0: ----------------
AXI4: Single-byte write, base_addr 0x80000000
AXI4: Single-byte read, base_addr 0x80000000

test50: ----------------
AXI4: Series of small writes/reads across first 128 bytes
    base_addr = 0x0
    at sizes 1, 2, 4, 8 bytes

test50: ----------------
AXI4: Series of small writes/reads across first 128 bytes
    base_addr = 0x80000000
    at sizes 1, 2, 4, 8 bytes

test60: ----------------
AXI4: write/read 0x2000 bytes, base_addr 0x0

test60: ----------------
AXI4: write/read 0x2000 bytes, base_addr 0x80000000

test60: ----------------
AXI4: write/read 0x1001 bytes, base_addr 0x5

test60: ----------------
AXI4: write/read 0x1001 bytes, base_addr 0x80000005

test70: ----------------
AXI4: write DDR_A (addr 0x0); data 0x0 to 0x100
AXI4: write DDR_B (addr 0x80000000); data 0x100 to 0x200
AXI4: read back DDR_A, testing that data was not overwritten
AXI4: read back DDR_B, testing that data was not overwritten

test80: ----------------
AXI4L: Series of 4 byte write/read across first 128 bytes

test90: ----------------
AXI4 write, AXI4-Lite read, base_addr 0x0
AXI4 write 128 bytes
AXI4L: readback 128 bytes

test100: ----------------

AXI4 write, AXI4-Lite read, base_addr 0x0
AXI4L write 128 bytes
AXI4: readback 128 bytes

ここまでは順調にいっています。

test990 ではエラーが発生しています。これは期待されたエラーなのでOKのようです。

test990: ----------------
AXI4: Single-byte write, out-of-bounds addr 0x100000000
NOTE: ERROR expected
----
AXI4: Single-byte read, out-of-bounds addr 0x100000000
NOTE: ERROR expected
ERROR: buf_read_AXI4: 1 bytes from addr 0x100000000
    FAILED: rc = 1

最後にテストステータスを表示し、プログラムを終了します。

END OF TESTS; TEST STATS ----------------
num_ERRORS = 0
num_expected_ERRORS = 1
n_AXI4_reads  = 489, AXI4_read_bytes  = 26244
n_AXI4_writes = 490, AXI4_write_bytes = 26245
n_AXI4L_reads  = 64 (4 bytes each)
n_AXI4L_writes = 64 (4 bytes each)
----------------

最後にHW側との通信を開放しています。

Finalizing FPGA lib or simulation lib
AWSteria_Host_shutdown: closing TCP connection
tcp_client_close

コードは、ここで、次のようになっています。

    // ----------------------------------------------------------------
    // Shutdown FPGA PCIe or simulation libraries

    fprintf (stdout, "Finalizing FPGA lib or simulation lib\n");
    rc = AWSteria_Host_shutdown (AWSteria_Host_state);
    if (rc != 0) goto ret_err;
    // ----------------------------------------------------------------

AWSteria_Host_shutdown 関数は、ここで次のようになっています。

// ================================================================
// Host_shutdown takes pointer to state returned by Host_init
// Return 0 if ok, non-zero if error

int AWSteria_Host_shutdown (void *awsteria_host_state)
{
    fprintf (stdout, "%s: closing TCP connection\n", __FUNCTION__);
    tcp_client_close (0);
    return 0;
}

// ================================================================

tcp_client_xxx 関数

tcp_client_xxx 関数は、ここで定義されています。

おわりに

次回は、HW側(Bluespec)の中を見ていきます。