• flywiththewind > accelerating functions with the c2h compiler: scatter ...
  • accelerating functions with the c2h compiler: scatter ...

    免费下载 下载该文档 文档格式:PDF   更新时间:2006-07-02   下载次数:0   点击次数:1
    文档基本属性
    文档语言:Simplified Chinese
    文档格式:pdf
    文档作者:ISOYES
    关键词:
    主题:
    备注:
    点击这里显示更多文档属性
    Accelerated Implementation
    This section discusses how you can refactor the checksum implementation shown in Example 1 for optimal results using the C2H Compiler. The implementation of the scatter-gather DMA function for the C2H Compiler, shown in Example 2, is straight-forward. It resembles the methodology a software developer would use to access multiple 2 Accelerating Functions with the C2H Compiler Altera Corporation July 2006
    Background: Scatter-Gather DMA
    buffer locations if no DMA engine were present. The scatter-gather DMA design is integrated with a checksum function to validate Ethernet packets. The checksum validation, which requires the processor to execute a large number of memory accesses, is time consuming. Because the primary bottleneck in the checksum computation is memory throughput, combining the checksum algorithm and DMA operation into a hardware accelerator maximizes system performance. Figure 1 shows a block diagram of the hardware accelerator and its connections to memory. Figure 1: Simplified Scatter-Gather DMA
    Altera Corporation July 2006
    3 Accelerating Functions with the C2H Compiler
    Background: Scatter-Gather DMA
    Example 2 shows the C code that has been optimized for hardware mapping by the C2H compiler. The pointer addr is used to access the data in each buffer located in main memory. The value count is used to control the number of iterations of the DMA loop contained in the accelerated function. Example 2: Scatter-gather DMA Code Integrated with Hardware Implementation of Checksum
    void hw_checksum(unsigned long * table_address, unsigned long table_length, unsigned short *return_values) { void * addr; unsigned long buffer_ctr; /****************************************************************** * Scatter-gather DMA loop * ******************************************************************* * Use "addr" to perform read operations on the memory and "count" * * to keep track of the length of the buffer. These values are * * loaded from the table using the pointer "table_address." The * * number of entries in the table is "table_length." * *******************************************************************/ for(buffer_ctr = 0; buffer_ctr 3) { temp_data = *(unsigned long *)addr; sum += (temp_data & 0xFFFF) + ((temp_data & 0xFFFF0000) >> 16); count -= 4; addr += 4; } /* Add left-over half word when applicable. This is a half * * word access so the pointer "addr" must advance by 2 */ sum += ((count == 2) || (count == 3)) *(unsigned short*)addr : 0; addr += ((count == 2) || (count == 3)) 2 : 0; /* Add left-over byte when applicable. This is the last * * possible access so no need to move the pointer "addr" */ sum += ((count == 1) || (count == 3)) *(unsigned char *)addr : 0; /* Fold 32-bit sum to 16 bits. The first fold could result in * a 17 bit sum so a second fold guarantees that the result * fits within 16 bits /* 1st fold */ sum = (sum & 0xffff) + (sum >> 16); /* 2nd fold */ return_values[buffer_ctr] = ~((sum & 0xffff) + (sum >> 16)); /****************************************************************** * End of Code that the C2H Compiler Maps to Hardware * /*******************************************************************/ } * * */

    上一页下一页

  • 下载地址 (推荐使用迅雷下载地址,速度快,支持断点续传)
  • 免费下载 PDF格式下载
  • 您可能感兴趣的
  • flywiththewind  flyinthewind  gonewiththewind  runwiththewind  rollwiththewind  gongwiththewind  conewiththewind  comewiththewind  gownwiththewind  gunwiththewind