Ejemplo n.º 1
0
        /// <summary>
        /// Relocate the tile given by instanceTileLocation from anchor
        /// instanceTileLocation does not have to be part of the FPGA
        /// </summary>
        /// <param name="instanceTileLocation"></param>
        /// <param name="anchor"></param>
        /// <returns></returns>
        ///
        public bool GetTargetLocation(string instanceTileLocation, Tile anchor, out string targetLocation)
        {
            targetLocation = "";

            int x, y;

            FPGATypes.GetXYFromIdentifier(instanceTileLocation, out x, out y);

            int locationIncrX = x - ResourceShape.Anchor.AnchorLocationX;
            int locationIncrY = y - ResourceShape.Anchor.AnchorLocationY;

            int targetLocationX = anchor.LocationX + locationIncrX;
            int targetLocationY = anchor.LocationY + locationIncrY;


            // three chars should match the type CLB/BRAM/DSP
            if (string.IsNullOrEmpty(instanceTileLocation) || instanceTileLocation.Length < 3)
            {
            }
            string prefix     = instanceTileLocation.Substring(0, 3);
            Tile   targetTile = FPGA.FPGA.Instance.GetAllTiles().FirstOrDefault(t => t.Location.StartsWith(prefix) && t.LocationX == targetLocationX && t.LocationY == targetLocationY);


            //int lastUnderScore = instanceTileLocation.LastIndexOf("_");
            //targetLocation += instanceTileLocation.Substring(0, lastUnderScore);
            //targetLocation += "_X" + targetLocationX + "Y" + targetLocationY;
            // naming fun
            //String resolvedTargetLocation = null;
            //bool success = FPGA.FPGATypes.ResolveLMIdentifier(targetLocation, str => !FPGA.FPGA.Instance.Contains(str), out resolvedTargetLocation);

            if (targetTile != null)
            {
                targetLocation = targetTile.Location;
                return(true);
            }
            else
            {
                // relocated DSP INT_X3Y5 -> INT_BRAM_X3Y5 or INT_BRAM_BRK_X3Y5
                // move to init.goa
                Tile differentlyNamedTile = FPGA.FPGA.Instance.GetAllTiles().Where(t =>
                                                                                   ((t.Location.StartsWith("BRAM_") && FPGA.FPGA.Instance.Family.Equals(FPGATypes.FPGAFamily.Virtex6)) ||
                                                                                    (t.Location.StartsWith("INT_BRAM_") && FPGA.FPGA.Instance.Family.Equals(FPGATypes.FPGAFamily.Spartan6))) &&
                                                                                   t.LocationX == targetLocationX &&
                                                                                   t.LocationY == targetLocationY).FirstOrDefault();
                if (differentlyNamedTile != null)
                {
                    targetLocation = differentlyNamedTile.Location;
                    return(true);
                }
                else
                {
                    targetLocation = "";
                    return(false);
                }
                //throw new ArgumentException("Error during relocation: Can not relocate " + instanceTileLocation + " using anchor " + anchor.Location + ". Target " + targetLocation + " not found");
            }
        }