XilinxProcessorIPLib/drivers/aiengine/examples/aie_sim_test/ext/top/xaiesim_elfload.c
uint64_t XAieSim_GetTargetTileAddr(XAieSim_Tile *TileInstPtr, uint32 ShAddr)
{
	uint64_t TgtTileAddr;
	uint8 CardDir;
	uint8 TgtRow;
	uint8 TgtCol;
        uint8 RowParity;

	/* Find the cardinal direction and get the tile addr */
	CardDir = (ShAddr & XAIESIM_ELF_TILEADDR_DMB_CARD_OFF) >>
				XAIESIM_ELF_TILEADDR_DMB_CARD_SHIFT;

	TgtRow = TileInstPtr->RowId;
	TgtCol = TileInstPtr->ColId;
        RowParity = TgtRow % 2U;

	switch(CardDir) {
	case 0U:
                /* South */
		if(TgtRow > 0U) {
			TgtRow -= 1U;
		}
		break;
	case 1U:
                /*
                 * West - West I/F could be same tile or adjacent tile based on
                 * the row number
                 */
		if(RowParity == 1U) {
                        /* Adjacent tile */
                        if(TgtCol > 0U) {
			        TgtCol -= 1U;
                        }
		}
		break;
	case 2U:
                /* North */
		TgtRow += 1U;
		break;
	case 3U:
		/*
                 * East - East I/F could be same tile or adjacent tile based on
                 * the row number
                 */
		if(RowParity == 0U) {
                        /* Adjacent tile */
                        TgtCol += 1U;
                }
                break;
	}

        /* Restore orig values if we have exceeded the array boundary limits */
	if(TgtRow > XAieGbl_ConfigTable->NumRows) {
		TgtRow = TileInstPtr->RowId;
	}
	if(TgtCol >= XAieGbl_ConfigTable->NumCols) {
		TgtCol = TileInstPtr->ColId;
	}

	TgtTileAddr = ((TileInstPtr->TileAddr &
                                (~(uint64_t)XAIESIM_ELF_TILEBASE_ADDRMASK)) |
				(TgtCol << XAIESIM_ELF_TILEADDR_COL_SHIFT) |
				(TgtRow << XAIESIM_ELF_TILEADDR_ROW_SHIFT));

	return TgtTileAddr;
}
/*****************************************************************************/
/**
*
* This routine is used to get the actual tile data memory address based on the
* section's loadable address. The actual tile address is derived from the 
* cardinal direction the secton's loadable address points to.
*
* @param	TileInstPtr - Pointer to the Tile instance structure.
* @param	ShAddr: Section's loadable address.
*
* @return	32-bit target tile address.
*
* @note		None.
*
*******************************************************************************/
This routine is used to get the actual tile data memory address based on the
section's loadable address. The actual tile address is derived from the
cardinal direction the secton's loadable address points to.
This routine is used to get the actual tile data memory address based on the section ' s loadable address . The actual tile address is derived from the cardinal direction the secton ' s loadable address points to .
uint64_t XAieSim_GetTargetTileAddr(XAieSim_Tile *TileInstPtr, uint32 ShAddr)
{
	uint64_t TgtTileAddr;
	uint8 CardDir;
	uint8 TgtRow;
	uint8 TgtCol;
        uint8 RowParity;
	CardDir = (ShAddr & XAIESIM_ELF_TILEADDR_DMB_CARD_OFF) >>
				XAIESIM_ELF_TILEADDR_DMB_CARD_SHIFT;
	TgtRow = TileInstPtr->RowId;
	TgtCol = TileInstPtr->ColId;
        RowParity = TgtRow % 2U;
	switch(CardDir) {
	case 0U:
		if(TgtRow > 0U) {
			TgtRow -= 1U;
		}
		break;
	case 1U:
		if(RowParity == 1U) {
                        if(TgtCol > 0U) {
			        TgtCol -= 1U;
                        }
		}
		break;
	case 2U:
		TgtRow += 1U;
		break;
	case 3U:
		if(RowParity == 0U) {
                        TgtCol += 1U;
                }
                break;
	}
	if(TgtRow > XAieGbl_ConfigTable->NumRows) {
		TgtRow = TileInstPtr->RowId;
	}
	if(TgtCol >= XAieGbl_ConfigTable->NumCols) {
		TgtCol = TileInstPtr->ColId;
	}
	TgtTileAddr = ((TileInstPtr->TileAddr &
                                (~(uint64_t)XAIESIM_ELF_TILEBASE_ADDRMASK)) |
				(TgtCol << XAIESIM_ELF_TILEADDR_COL_SHIFT) |
				(TgtRow << XAIESIM_ELF_TILEADDR_ROW_SHIFT));
	return TgtTileAddr;
}
uint64_t XAieSim_GetTargetTileAddr ( XAieSim_Tile * TileInstPtr , uint32 ShAddr ) { uint64_t TgtTileAddr ; uint8 CardDir ; uint8 TgtRow ; uint8 TgtCol ; uint8 RowParity ; CardDir = ( ShAddr & XAIESIM_ELF_TILEADDR_DMB_CARD_OFF ) >> XAIESIM_ELF_TILEADDR_DMB_CARD_SHIFT ; TgtRow = TileInstPtr -> RowId ; TgtCol = TileInstPtr -> ColId ; RowParity = TgtRow % 2U ; switch ( CardDir ) { case 0U : if ( TgtRow > 0U ) { TgtRow -= 1U ; } break ; case 1U : if ( RowParity == 1U ) { if ( TgtCol > 0U ) { TgtCol -= 1U ; } } break ; case 2U : TgtRow += 1U ; break ; case 3U : if ( RowParity == 0U ) { TgtCol += 1U ; } break ; } if ( TgtRow > XAieGbl_ConfigTable -> NumRows ) { TgtRow = TileInstPtr -> RowId ; } if ( TgtCol >= XAieGbl_ConfigTable -> NumCols ) { TgtCol = TileInstPtr -> ColId ; } TgtTileAddr = ( ( TileInstPtr -> TileAddr & ( ~ ( uint64_t ) XAIESIM_ELF_TILEBASE_ADDRMASK ) ) | ( TgtCol << XAIESIM_ELF_TILEADDR_COL_SHIFT ) | ( TgtRow << XAIESIM_ELF_TILEADDR_ROW_SHIFT ) ) ; return TgtTileAddr ; }
This routine is used to get the actual tile data memory address based on the
section's loadable address.
This routine is used to get the actual tile data memory address based on the section ' s loadable address .
/* Find the cardinal direction and get the tile addr */ /* South */ /*
                 * West - West I/F could be same tile or adjacent tile based on
                 * the row number
                 */ /* Adjacent tile */ /* North */ /*
                 * East - East I/F could be same tile or adjacent tile based on
                 * the row number
                 */ /* Adjacent tile */ /* Restore orig values if we have exceeded the array boundary limits */