你问我答——求助:SoCFPGA例子时候遇到的问题。

2019-03-25 08:15发布

例子:Altera-SoCFPGA-HardwareLib-GNU  
ALT_STATUS_CODE test_config_full(void)
{
    // Verify the MSELs are appropriate for the type of image we're using.
    ALT_FPGA_CFG_MODE_t mode = alt_fpga_cfg_mode_get();
    switch (mode)
    {
    case ALT_FPGA_CFG_MODE_PP32_FAST_AESOPT_DC:
    case ALT_FPGA_CFG_MODE_PP32_SLOW_AESOPT_DC:
    case ALT_FPGA_CFG_MODE_PP16_FAST_AESOPT_DC:
    case ALT_FPGA_CFG_MODE_PP16_SLOW_AESOPT_DC:
        printf("INFO: MSEL configured correctly for FPGA image. ");
        break;
    default:
        printf("ERROR: Incompatible MSEL mode set. Cannot continue with FPGA programming. ");
        return ALT_E_ERROR;
    }

    // This is the symbol name for the SOF file contents linked in.
    extern char _binary_soc_system_dc_rbf_start;
    extern char _binary_soc_system_dc_rbf_end;


    // Use the above symbols to extract the FPGA image information.
    const char *   fpga_image      = &_binary_soc_system_dc_rbf_start;
    const uint32_t fpga_image_size = &_binary_soc_system_dc_rbf_end - &_binary_soc_system_dc_rbf_start;

    // Trace the FPGA image information.
    printf("INFO: FPGA Image binary at %p. ", fpga_image);
    printf("INFO: FPGA Image size is %u bytes. ", (unsigned int)fpga_image_size);

    // Try the full configuration a few times.
    const uint32_t full_config_retry = 5;
    for (uint32_t i = 0; i < full_config_retry; ++i)
    {
        ALT_STATUS_CODE status;
        status = alt_fpga_configure(fpga_image, fpga_image_size);
        if (status == ALT_E_SUCCESS)
        {
            printf("INFO: alt_fpga_configure() successful on the %u of %u retry(s). ",
                   (unsigned int)(i + 1),
                   (unsigned int)full_config_retry);
            return ALT_E_SUCCESS;
        }
    }

    printf("ERROR: FPGA failed to program after %u attempt(s). ", (unsigned int)full_config_retry);

    return ALT_E_ERROR;
}


请问:红 {MOD}部分代码是如何实现与FPGA的代码链接的?
是不是这样链接了后,在C语言中,就可以直接调用FPGA端的程序了? 此帖出自小平头技术问答
0条回答

一周热门 更多>