コード例 #1
0
        private string TextOutVias(Cell cell, Vias vias)
        {
            string text = "";

            text += "vias " + cell.Label + ", ";

            if (vias.Label.Length == 0)
            {
                if (vias.Type == EntityType.ViasInput)
                {
                    text += "in";
                }
                else if (vias.Type == EntityType.ViasOutput)
                {
                    text += "out";
                }
                else if (vias.Type == EntityType.ViasInout)
                {
                    text += "inout";
                }
                else
                {
                    return("");         // Skip
                }
            }
            else
            {
                text += vias.Label;
            }

            text += ", " + vias.posOffset.X.ToString().Replace(',', '.') +
                    ", " + vias.posOffset.Y.ToString().Replace(',', '.') + ", ";

            text += vias.Type.ToString();

            text += ", 0\r\n";

            return(text);
        }
コード例 #2
0
        private void GenSingleCell(PointF origin, PointF keyPoint, PointF stop, int Tier, int Kpn)
        {
            PointF[] kp   = new PointF[3];
            Cell     cell = new Cell();

            Console.WriteLine("Start from keypoint[" + Tier.ToString() + "," + Kpn.ToString() + "]: " +
                              keyPoint.ToString());

            //
            // Scan for labeled and unlabeled ViasFloating
            //

            bool   LabeledViasFound   = false;
            bool   UnlabeledViasFound = false;
            Entity labeled            = null;
            Entity unlabeled          = null;

            PointF keypointPolar = PlanarToPolar(keyPoint);
            PointF originPolar   = PlanarToPolar(origin);
            PointF stopPolar     = PlanarToPolar(stop);

            PointF vertDelta = new PointF(keyPoint.X, keyPoint.Y);
            PointF horzDelta = new PointF(keyPoint.X, keyPoint.Y);

            Random rand = new Random();

            byte[] color = new byte[3];
            rand.NextBytes(color);

            if (color[0] < 15)
            {
                color[0] = 15;
            }
            if (color[1] < 15)
            {
                color[1] = 15;
            }
            if (color[2] < 15)
            {
                color[2] = 15;
            }

            float r = 0, phi = 0;

            for (r = keypointPolar.X; r < stopPolar.X; r += ScanWindowWidth)
            {
                if (LabeledViasFound && UnlabeledViasFound)
                {
                    break;
                }

                PointF vertPolarDelta = PlanarToPolar(vertDelta);
                PointF horzPolarDelta = PlanarToPolar(horzDelta);

                for (phi = horzPolarDelta.Y; phi < vertPolarDelta.Y; phi += 0.017F)
                {
                    PointF planar = PolarToPlanar(new PointF(r, phi));

                    planar.X *= -1;

                    // DEBUG
#if false
                    Point  screen     = entityBox1.LambdaToScreen(planar.X, planar.Y);
                    Entity debugPoint = entityBox1.AddVias(EntityType.ViasConnect, screen.X, screen.Y,
                                                           Color.FromArgb(255, color[0], color[1], color[2]));
#endif

                    RectangleF rect = new RectangleF(planar.X, planar.Y,
                                                     ScanWindowWidth * 2, ScanWindowWidth * 2);

                    foreach (Entity entity in entityBox1.GetEntities())
                    {
                        if (entity.Type == EntityType.ViasFloating && entity.Label.Length > 0 &&
                            rect.Contains(new PointF(entity.LambdaX, entity.LambdaY)) &&
                            !LabeledViasFound &&
                            !CellExists(new PointF(entity.LambdaX, entity.LambdaY)))
                        {
                            labeled          = entity;
                            LabeledViasFound = true;
                        }

                        if (entity.Type == EntityType.ViasFloating && entity.Label.Length == 0 &&
                            rect.Contains(new PointF(entity.LambdaX, entity.LambdaY)) &&
                            !UnlabeledViasFound && LabeledViasFound)
                        {
                            if (entity.LambdaY > labeled.LambdaY && entity.LambdaX > labeled.LambdaX)
                            {
                                unlabeled          = entity;
                                UnlabeledViasFound = true;
                            }
                        }
                    }

                    if (LabeledViasFound && UnlabeledViasFound)
                    {
                        break;
                    }
                }

                vertDelta.X -= ScanWindowWidth;
                horzDelta.Y += ScanWindowWidth;
            }

#if DEBUG
            Point  startPoint = entityBox1.LambdaToScreen(-keyPoint.X, keyPoint.Y);
            PointF planarEnd  = PolarToPlanar(new PointF(r, phi));
            Point  endPoint   = entityBox1.LambdaToScreen(-planarEnd.X, planarEnd.Y);
            Entity wire       = entityBox1.AddWire(EntityType.WireInterconnect, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
            wire.Label = Tier.ToString() + "," + Kpn.ToString();
#endif

            if (!LabeledViasFound || !UnlabeledViasFound)
            {
                Console.WriteLine("Stop from keypoint[" + Tier.ToString() + "," + Kpn.ToString() + "]: " +
                                  keyPoint.ToString());
                return;
            }

            Console.WriteLine("labeled: X=" + labeled.LambdaX.ToString() +
                              ", Y=" + labeled.LambdaY.ToString());
            Console.WriteLine("UN-labeled: X=" + unlabeled.LambdaX.ToString() +
                              ", Y=" + unlabeled.LambdaY.ToString());
            Console.WriteLine(" --- ");

            //
            // Grab in / out viases within area
            //

            cell.vias = new List <Vias>();

            RectangleF cellArea = new RectangleF(labeled.LambdaX, labeled.LambdaY,
                                                 unlabeled.LambdaX - labeled.LambdaX,
                                                 unlabeled.LambdaY - labeled.LambdaY);

            foreach (Entity vias in entityBox1.GetEntities())
            {
                PointF point = new PointF(vias.LambdaX, vias.LambdaY);

                if ((vias.Type == EntityType.ViasInput ||
                     vias.Type == EntityType.ViasOutput ||
                     vias.Type == EntityType.ViasInout) &&
                    cellArea.Contains(point))
                {
                    Vias myVias = new Vias();

                    myVias.Label     = vias.Label;
                    myVias.posOffset = new PointF(vias.LambdaX - labeled.LambdaX,
                                                  vias.LambdaY - labeled.LambdaY);
                    myVias.Type = vias.Type;

                    cell.vias.Add(myVias);
                }
            }

            //
            // Insert in list
            //

            cell.labeledPos = new PointF(labeled.LambdaX, labeled.LambdaY);

            cell.Label = labeled.Label;
            cell.Type  = CellTypeByLabel(cell.Label);

            // Count transistors
            TransCount(cellArea, cell);

            cells.Add(cell);

            Console.WriteLine(cell.Label + " vias collection:");

            foreach (Vias vias in cell.vias)
            {
                Console.WriteLine(vias.Type.ToString() +
                                  " x: " + vias.posOffset.X.ToString() +
                                  ", y: " + vias.posOffset.Y.ToString());
            }

            //
            // Highlight cells without transistors
            //

            if (cell.PCount == 0 || cell.NCount == 0)
            {
                foreach (Entity entity in entityBox1.GetEntities())
                {
                    PointF point = new PointF(entity.LambdaX, entity.LambdaY);

                    if (cellArea.Contains(point))
                    {
                        entity.Selected = true;
                        entityBox1.Invalidate();
                    }
                }
            }

            //
            // Propagate keypoints
            //

            kp[0].X = keyPoint.X;
            kp[0].Y = unlabeled.LambdaY + ScanWindowWidth;
            kp[1].X = -(unlabeled.LambdaX + ScanWindowWidth);
            kp[1].Y = keyPoint.Y;
            kp[2].X = -(unlabeled.LambdaX + ScanWindowWidth);
            kp[2].Y = unlabeled.LambdaY + ScanWindowWidth;

            GenSingleCell(origin, kp[0], stop, Tier + 1, 0);
            GenSingleCell(origin, kp[1], stop, Tier + 1, 1);
            GenSingleCell(origin, kp[2], stop, Tier + 1, 2);
        }