Beispiel #1
0
        /// <summary>
        /// Return tupel of an XDLInstance and the tile where the instance will be placed based on the given placementAnchor
        /// </summary>
        /// <returns></returns>
        public IEnumerable <Tuple <Instance, Tile> > GetInstanceTiles(Tile anchor, LibraryElement libElement)
        {
            if (FPGA.FPGA.Instance.BackendType == FPGATypes.BackendType.ISE || (FPGA.FPGA.Instance.BackendType == FPGATypes.BackendType.Vivado && !libElement.VivadoConnectionPrimitive))
            {
                foreach (Instance inst in Containter.Instances)
                {
                    string targetLocation = "";
                    bool   success        = GetTargetLocation(inst.Location, anchor, out targetLocation);

                    if (success)
                    {
                        Tile targetTile = FPGA.FPGA.Instance.GetTile(targetLocation);
                        yield return(new Tuple <Instance, Tile>(inst, targetTile));
                    }
                    else
                    {
                        throw new ArgumentException("Could not relocate " + inst.Location + " from anchor " + anchor);
                    }
                }
            }
            else if (FPGA.FPGA.Instance.BackendType == FPGATypes.BackendType.Vivado && libElement.VivadoConnectionPrimitive)
            {
                TCLInstance inst = new TCLInstance();
                inst.SliceNumber      = SliceNumber;
                inst.SliceName        = anchor.Slices[SliceNumber].SliceName;
                inst.Location         = anchor.Location;
                inst.LocationX        = anchor.LocationX;
                inst.LocationY        = anchor.LocationY;
                inst.SliceType        = anchor.Slices[SliceNumber].SliceType;
                inst.Name             = anchor.Location;
                inst.TileKey          = anchor.TileKey;
                inst.OmitPlaceCommand = true;
                inst.BELType          = libElement.PrimitiveName;
                Tuple <Instance, Tile> result = new Tuple <Instance, Tile>(inst, anchor);
                yield return(result);
            }
            else
            {
                throw new ArgumentException("Unsupported branch in GetInstanceTiles");
            }
        }
 private void RelocateInstancesForTCL(LibraryElement libElement, Tile anchorCLB, TCLContainer netlistContainer)
 {
     foreach (Tuple <Instance, Tile> tileSliceTupel in libElement.GetInstanceTiles(anchorCLB, libElement))
     {
         TCLInstance newInstance = new TCLInstance((TCLInstance)tileSliceTupel.Item1);
         // change LOC property and the other fields carries out the actual relocation
         Slice targetSlice = tileSliceTupel.Item2.Slices[(int)newInstance.SliceNumber];
         newInstance.Properties.SetProperty("LOC", targetSlice.SliceName, false);
         if (InsertPrefix)
         {
             newInstance.Name = InstanceName + "_" + newInstance.Name; // do not use / to avoid creating a new hierarchy for which w do not have a refernce cell
         }
         newInstance.SliceName        = targetSlice.SliceName;
         newInstance.SliceType        = targetSlice.SliceType;
         newInstance.SliceNumber      = targetSlice.ContainingTile.GetSliceNumberByName(targetSlice.SliceName);
         newInstance.TileKey          = targetSlice.ContainingTile.TileKey;
         newInstance.Location         = targetSlice.ContainingTile.Location;
         newInstance.LocationX        = targetSlice.ContainingTile.LocationX;
         newInstance.LocationY        = targetSlice.ContainingTile.LocationY;
         newInstance.OmitPlaceCommand = true; // TODO we only support GND primitves, overwork this when placing module
         netlistContainer.Add(newInstance);
     }
 }
        protected override void DoCommandAction()
        {
            NetlistContainer nlc = GetNetlistContainer();

            DesignParser parser = DesignParser.CreateDesignParser(FileName);

            try
            {
                parser.ParseDesign(nlc, this);
            }
            catch (Exception e)
            {
                throw new ArgumentException("Error during parsing the design " + FileName + ": " + e.Message + ". Are you trying to open the design on the correct device?");
            }

            foreach (Instance inst in nlc.Instances)
            {
                Tile t = FPGA.FPGA.Instance.GetTile(inst.Location);
                if (!t.HasSlice(inst.SliceName))
                {
                    OutputManager.WriteWarning("Can not find primitve " + inst.SliceName + " on tile " + t.Location);
                }
                else
                {
                    Slice s = t.GetSliceByName(inst.SliceName);
                    s.Usage = FPGATypes.SliceUsage.Macro;
                    if (FPGA.FPGA.Instance.BackendType == FPGATypes.BackendType.Vivado)
                    {
                        TCLInstance tclInst = (TCLInstance)inst;
                        if (!string.IsNullOrEmpty(tclInst.BELType))
                        {
                            s.SetBelUsage(tclInst.BELType, FPGATypes.SliceUsage.Macro);
                        }
                    }
                }
            }

            foreach (Net n in nlc.Nets)
            {
                n.BlockUsedResources();
            }

            if (AutoFixXDLBugs)
            {
                FPGATypes.AssertBackendType(FPGATypes.BackendType.ISE);

                if (FPGA.FPGA.Instance.Family == FPGATypes.FPGAFamily.Spartan6)
                {
                    foreach (XDLInstance inst in nlc.Instances.Where(i => i.Location.Contains("IOB") || i.SliceType.Equals("IOB")))
                    {
                        string code = inst.ToString();
                        if (!code.Contains("OUTBUF:"))
                        {
                            code = code.Replace("PRE_EMPHASIS::#OFF", "");
                            inst.SetCode(code);
                            OutputManager.WriteWarning("Fixed XDL code for instance " + inst.Name);
                        }
                    }
                }
            }
        }