Ejemplo n.º 1
0
        public static void TestMethod(byte inData, out byte result)
        {
            byte   r       = 0;
            object l       = new object();
            byte   counter = 0;

            FPGA.Register <byte> data = 0;

            // TODO: const handlers count
            Func <bool> completed = () => counter == 2;

            Action handler = () =>
            {
                lock (l)
                {
                    r += data;
                    counter++;
                }
            };

            FPGA.Config.OnRegisterWritten(data, handler, 2);

            FPGA.Runtime.Assign(FPGA.Expressions.AssignRegister(inData, data));

            FPGA.Runtime.WaitForAllConditions(completed);

            result = r;
        }
Ejemplo n.º 2
0
        public static async Task Aggregator(
            FPGA.InputSignal <bool> RXD,
            FPGA.OutputSignal <bool> TXD
            )
        {
            Action handler = () =>
            {
                byte data = 0;
                Drivers.UART.Read(RXD, out data);

                Func <byte>        dFunc       = () => (byte)(data * 2);
                FPGA.Signal <bool> writeEnable = false;

                FPGA.Register <byte> result = new FPGA.Register <byte>(0);

                FPGA.Config.RegisterOverride(result, dFunc, writeEnable);

                FPGA.Runtime.Assign(FPGA.Expressions.AssignSignal(true, writeEnable));

                Drivers.UART.Write(result, TXD);
            };
            bool trigger = true;

            FPGA.Config.OnSignal(trigger, handler);
        }
Ejemplo n.º 3
0
        public static void ClockCounter(FPGA.Register <uint> value)
        {
            Func <uint> nextClockCounter = () => value + 1;
            Func <bool> clockCounterWE   = () => true;

            FPGA.Config.RegisterOverride(value, nextClockCounter, clockCounterWE);
        }
        public static void MakeRandomValue(
            GameControlsState controlsState,
            FPGA.Register <int> randomValue)
        {
            FPGA.Register <byte> tickCounter     = 0;
            Func <byte>          nextTickCounter = () => (byte)(tickCounter + 1);
            Func <bool>          tickCounterWE   = () => controlsState.keyCode != Drivers.KeypadKeyCode.None;

            FPGA.Config.RegisterOverride(tickCounter, nextTickCounter, tickCounterWE);

            FPGA.Register <bool> randomCounterWE = true;

            Func <int> nextRandomCounter = () => tickCounter + randomValue + controlsState.adcChannel1 + controlsState.adcChannel2;

            FPGA.Config.RegisterOverride(randomValue, nextRandomCounter, randomCounterWE);
        }