Exemplo n.º 1
0
        public void TryGetNetAt_WorksWell_WithProperInnput()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                //   012345678
                "  XXXXXXX",
                " XX     X",
                " XX XXX X",
                "",
                " XX XXX X",
                "  XX    X",
                "   XXXX",
                "",
            });
            BitmapScanner dut = new BitmapScanner(accessor);

            dut.Scan();
            dut.ComputeNetlists();
            dut.CompactNets();
            dut.MapNetlists();

            Assert.IsTrue(dut.TryGetNetAt(1, 2, out int netId));
            Assert.AreEqual(1, netId);

            Assert.IsTrue(dut.TryGetNetAt(5, 2, out netId));
            Assert.AreEqual(2, netId);

            Assert.IsTrue(dut.TryGetNetAt(5, 4, out netId));
            Assert.AreEqual(4, netId);

            Assert.IsFalse(dut.TryGetNetAt(3, 4, out netId));
        }
Exemplo n.º 2
0
        public void MapNetlists_WorksWell()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                //   012345678
                "X        X",
                "X  X  X  X",
                "X  X  X  X",
                "XXXX  XXXX",
                "",
            });
            BitmapScanner dut = new BitmapScanner(accessor);

            dut.Scan();
            dut.ComputeNetlists();
            dut.CompactNets();
            dut.MapNetlists();

            for (int netId = 1; netId <= dut.GetNetCount(); netId++)
            {
                Console.WriteLine($"NetId : {netId}");
                foreach (var segment in dut.GetSegmentsOfNet(netId))
                {
                    Console.WriteLine($"    {segment}");
                }
            }
        }
Exemplo n.º 3
0
        public void Scan_GeneratesGood_Scanlines()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                //   012345678
                "XXXXXXXXX",
                " XXXXXXX",
                "  XXXXX",
                "   XXX",
                "    X",
                "",
            });
            var expectedStart = new int[] { 0, 1, 2, 3, 4 };
            var expectedEnd   = new int[] { 8, 7, 6, 5, 4 };

            BitmapScanner dut = new BitmapScanner(accessor);

            dut.Scan();
            int y = 0;

            foreach (var i in dut.Segments)
            {
                Console.WriteLine(i.ToString());
                Assert.AreEqual(expectedStart[y], i.XMin);
                Assert.AreEqual(expectedEnd[y], i.XMax);
                y++;
            }

            Assert.AreEqual(y, expectedEnd.Length);
        }
Exemplo n.º 4
0
        public void GetHoles_WorksWell_WithProperBitmap()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                //   012345678
                "XXXXXXXXXXX",
                "X         X",
                "X XX  XX  X",
                "X XX  XX  X",
                "X         X",
                "X    XX   X",
                "X    XX   X",
                "X         X",
                "XXXXXXXXXXX",
            });

            BitmapScanner dut = new BitmapScanner(accessor);

            dut.PrepareAll();

            DrillScanner scanner = new DrillScanner(dut);

            var holes = scanner.GetHoles();

            Assert.AreEqual(3, holes.Count);
            Assert.AreEqual(2.5, holes[0].X);
            Assert.AreEqual(2.5, holes[0].Y);
            Assert.AreEqual(6.5, holes[1].X);
            Assert.AreEqual(2.5, holes[1].Y);
            Assert.AreEqual(5.5, holes[2].X);
            Assert.AreEqual(5.5, holes[2].Y);
        }
Exemplo n.º 5
0
        private bool IsSingleNetlist(BitmapScanner dut)
        {
            var result = true;

            dut.Scan();
            dut.ComputeNetlists();
            foreach (var segment in dut.Segments)
            {
                result &= segment.NetList == 1;
            }

            return(result);
        }
Exemplo n.º 6
0
        public void ComputeNetlists_WorksWell_Case2()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                "  XXXX       XXXXXXXX            X",
                " XXXXXX     XXXX   XXXXX       XXX",
                "XXXXXXXXXXXXXX       XXXXX  XXXX",
                "                        XXXXX"
            });
            BitmapScanner dut = new BitmapScanner(accessor);

            Assert.IsTrue(IsSingleNetlist(dut));
        }
Exemplo n.º 7
0
        public void Scan_GeneratesGood_CompositeScanlnes_WorksWell()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                //   012345678
                "  XXXXX",
                " XX    X",
                " XX XXX X",
                "",
                " XX XXX X",
                "  XX    X",
                "   XXXX",
                "",
            });

            Console.WriteLine("Check Segments");
            var           expectedy     = new int[] { 0, 1, 1, 2, 2, 2, 4, 4, 4, 5, 5, 6 };
            var           expectedStart = new int[] { 2, 1, 7, 1, 4, 8, 1, 4, 8, 2, 8, 3 };
            var           expectedEnd   = new int[] { 6, 2, 7, 2, 6, 8, 2, 6, 8, 3, 8, 6 };
            BitmapScanner dut           = new BitmapScanner(accessor);

            dut.Scan();
            int i = 0;

            foreach (var s in dut.Segments)
            {
                Assert.AreEqual(expectedy[i], s.Y);
                Assert.AreEqual(expectedStart[i], s.XMin);
                Assert.AreEqual(expectedEnd[i], s.XMax);
                i++;
            }

            // Check Scanline Index
            var expectedY       = new int[] { 0, 1, 2, 4, 5, 6 };
            var expectedInitial = new int[] { 0, 1, 3, 6, 9, 11 };
            var expectedLen     = new int[] { 1, 2, 3, 3, 2, 1 };

            i = 0;
            Console.WriteLine("Check ScanLineIndex");
            foreach (var index in dut.ScanlineIndex)
            {
                Console.WriteLine(index);
                Assert.AreEqual(expectedY[i], index.Y);
                Assert.AreEqual(expectedInitial[i], index.InitialIndex);
                Assert.AreEqual(expectedLen[i], index.Length);
                i++;
            }
            Assert.AreEqual(i, expectedY.Length);
        }
Exemplo n.º 8
0
        private void CheckConnection(string[] expected)
        {
            BitmapScanner topLayer = new BitmapScanner(this.top);

            topLayer.PrepareAll();

            BitmapScanner bottomLayer = new BitmapScanner(this.bottom);

            bottomLayer.PrepareAll();

            BitmapScanner drillLayer = new BitmapScanner(this.drill);

            drillLayer.PrepareAll();

            DrillScanner drillScanner = new DrillScanner(drillLayer);

            DrillConnector drillConnector = new DrillConnector(topLayer, bottomLayer, drillScanner);

            drillConnector.ComputeGlobalNet();

            var nets     = drillConnector.GetNets();
            int netCount = 0;

            foreach (int key in nets)
            {
                Console.WriteLine($"KEY: {key}");
                StringBuilder sb = new StringBuilder();
                foreach (var layerNet in drillConnector.GetLayerNetsOfNet(key))
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(',');
                    }
                    sb.Append(layerNet.ToString());
                }
                Console.WriteLine($"  {sb}");
                Assert.AreEqual(expected[netCount], sb.ToString());
                netCount++;
            }
            Assert.AreEqual(expected.Length, netCount);
        }