예제 #1
0
        public void VGASyncModule_VSyncTest()
        {
            var sim = new RTLInstanceSimulator <VGASyncModule, VGASyncModuleInputs>(new VGASyncModule(480, 10, 2, 33));

            sim.TraceToVCD(VCDOutputPath());

            var tl = sim.TopLevel;

            Action assertSingleFlag = () =>
            {
                var flags = new[] { tl.OutVisible, tl.OutFP, tl.OutSP, tl.OutBP };
                var set   = flags.Where(f => f);
                Assert.IsTrue(set.Count() == 1, "Multiple flags are set");
            };

            for (var i = 0; i <= 525; i++)
            {
                assertSingleFlag();
                sim.ClockCycle(new VGASyncModuleInputs()
                {
                    Enabled = true
                });
            }

            assertSingleFlag();
        }
        public void VGAAlienArtModuleTest()
        {
            var module = new VGAAlienArtModule((clocks) => new TimerModule(clocks));

            module.InitVGA(VGAControllerMode.Test);
            var sim = new RTLInstanceSimulator <VGAAlienArtModule, VGAAlienArtModuleInputs>(module);
            var tl  = sim.TopLevel;

            var result = new List <bool>();

            while (result.Count != 4800)
            {
                if (tl.OutVisible)
                {
                    result.Add(tl.R);
                }
                sim.ClockCycle();
            }

            var resized = new Bitmap(80, 60);

            for (var row = 0; row < 60; row++)
            {
                for (var col = 0; col < 80; col++)
                {
                    if (result.Count <= (row * 80 + col))
                    {
                        continue;
                    }

                    resized.SetPixel(col, row, result[row * 80 + col] ? Color.Green : Color.White);
                }
            }
            resized.Save(PNGOutputPath(), ImageFormat.Png);
        }
        public void VGASyncModuleTest()
        {
            var sim = new RTLInstanceSimulator <VGASyncModule, VGASyncModuleInputs>(new VGASyncModule(480, 10, 2, 33), true);

            for (var i = 0; i <= 525; i++)
            {
                sim.ClockCycle(new VGASyncModuleInputs()
                {
                    Enabled = true
                });
            }

            var tb = sim.TBAdapter(RTLVerilogConfig);

            tb.PostSynthTimingSimulation();
        }
        public void VGAStaticQRModuleTest()
        {
            var config    = RuntimeConfigurationLoader.FromConfigFile(RTLVerilogConfig);
            var container = new QuokkaContainer()
                            .WithRuntimeConfiguration(config);
            var module = container.Resolve <VGAStaticQRModule>();

            var sim = new RTLInstanceSimulator <VGAStaticQRModule, VGAStaticQRModuleInputs>(module, true);
            var tb  = sim.TBAdapter(RTLVerilogConfig);

            tb.TranslateInstance();


            var tl           = sim.TopLevel;
            int pixelCounter = 0;

            uint[] pixels = new uint[800 * 600];

            for (int row = 0; row < 628; row++)
            {
                for (int col = 0; col < 1056; col++)
                {
                    if (tl.OutVisible)
                    {
                        pixels[pixelCounter] = (uint)(((tl.R ? 255 : 0) << 16) | ((tl.G ? 255 : 0) << 8) | (tl.B ? 255 : 0));
                        pixelCounter++;
                    }

                    sim.ClockCycle(new VGAStaticQRModuleInputs());
                }
            }

            Assert.AreEqual(800 * 600, pixelCounter);

            var resized = new Bitmap(800, 600);

            for (var row = 0; row < 600; row++)
            {
                for (var col = 0; col < 800; col++)
                {
                    resized.SetPixel(col, row, Color.FromArgb((int)(0xFF000000 | pixels[row * 800 + col])));
                }
            }
            resized.Save(PNGOutputPath(), ImageFormat.Png);
        }
        public void BoardTimerModuleTest()
        {
            var  container     = new QuokkaContainer();
            var  runtimeConfig = container.Resolve <RuntimeConfiguration>();
            uint testClock     = 10;

            runtimeConfig.Initialize(new QuokkaConfig()
            {
                Configurations = new List <BoardConfigAttribute>()
                {
                    new BoardConfigAttribute()
                    {
                        Name = "Test", ClockFrequency = testClock
                    }
                }
            });

            var moduleInstance = container.Resolve <BoardTimerModule>();
            var sim            = new RTLInstanceSimulator <BoardTimerModule, BoardTimerModuleInputs>(moduleInstance, true);

            sim.TraceToVCD(VCDOutputPath());

            var topLevel = sim.TopLevel;

            for (var i = 1; i <= testClock * 10; i++)
            {
                Assert.AreEqual(i % testClock == 0, topLevel.OutActive10);
                Assert.AreEqual(i % (testClock * 2) == 0, topLevel.OutActive20);

                sim.ClockCycle(new BoardTimerModuleInputs());
            }

            var tb = sim.TBAdapter(RTLVerilogConfig);

            tb.PostSynthTimingSimulation();
        }