Пример #1
0
 public void Test4()
 {
     for (int i = 8001; i <= 11111; i++)
     {
         Assert.Equal(GetResultByBruteForce(i), CountOne.CountOneResult(i));
     }
 }
Пример #2
0
        public byte Read(int port)
        {
            if (port == PORT_CONTROL)
            {
                throw new InvalidOperationException();
            }

            if (port == PORT_COUNT0)
            {
                return(CountZero.Read());
            }
            else if (port == PORT_COUNT1)
            {
                return(CountOne.Read());
            }
            else if (port == PORT_COUNT2)
            {
                return(CountTwo.Read());
            }
            else if (port == PORT_STATUS)
            {
                if (_timerHack.Count > 0)
                {
                    return(_timerHack.Dequeue());
                }

                return((byte)((timerZero ? 1 : 0) + ((timerOne ? 1 : 0) << 1)));
            }

            throw new InvalidOperationException();
        }
Пример #3
0
 public void Test1()
 {
     for (int i = 0; i <= 3000; i++)
     {
         Assert.Equal(GetResultByBruteForce(i), CountOne.CountOneResult(i));
     }
 }
Пример #4
0
        public void Step(double us)
        {
            _us += us;

            if (_us >= CLK_US)
            {
                var beforeZero = CountZero.Output;
                CountZero.Pulse();
                if (!beforeZero && CountZero.Output && CountZero.Active)
                {
                    CountOne.Pulse();
                }

                CountTwo.Pulse();

                if (CountZero.Output && CountZero.Active)
                {
                    timerZero = true;
                }
                if (CountTwo.Output && CountTwo.Active)
                {
                    timerOne = true;
                }

                _us -= CLK_US;
            }
        }