Exemple #1
0
        public static async Task Aggregator(
            FPGA.OutputSignal <byte> OutWithDefault,
            FPGA.OutputSignal <byte> OutOperation,
            FPGA.OutputSignal <bool> OutTrigger,
            FPGA.OutputSignal <float> OutResult,
            FPGA.OutputSignal <bool> OutCompleted)
        {
            byte value = 100;

            FPGA.Config.Link(value, OutWithDefault);

            Sequential handler = () =>
            {
                FPU.FPUScope();

                float op1 = 1.23f, op2 = 10f, res = 0;
                FPGA.Config.Link(res, OutResult);

                for (byte op = 0; op < 10; op++)
                {
                    FPGA.Config.Link(op, OutOperation);
                    OutTrigger = true;
                    FloatControllersOps.TestHandler(op1, op2, op, out res);
                    OutCompleted = true;
                }
            };

            FPGA.Config.OnStartup(handler);
        }
Exemple #2
0
        public static async Task Aggregator(
            FPGA.InputSignal <bool> RXD,
            FPGA.OutputSignal <bool> TXD
            )
        {
            Sequential handler = () =>
            {
                FPU.FPUScope();

                const int baud    = 115200;
                byte      command = 0;

                float op1, op2, res = 0;

                while (true)
                {
                    UART.ReadFloat(baud, RXD, out op1);
                    UART.ReadFloat(baud, RXD, out op2);
                    command = UART.Read(baud, RXD);

                    FloatControllersOps.TestHandler(op1, op2, command, out res);

                    UART.WriteFloat(baud, res, TXD);
                }
            };

            FPGA.Config.OnStartup(handler);
        }
        public static async Task Aggregator(
            FPGA.InputSignal <bool> RXD,
            FPGA.OutputSignal <bool> TXD)
        {
            const int baud = 115200;

            bool internalTXD = true;

            FPGA.Config.Link(internalTXD, TXD);

            FPGA.Signal <bool> handler0 = false, handler1 = false;
            float res0 = 0, res1 = 0;

            FPGA.Config.Suppress("W0003", handler0, handler1, res0, res1);

            Sequential handler = () =>
            {
                uint idx = FPGA.Config.InstanceId();

                FPU.FPUScope();

                float op1, op2, res = 0;

                UART.ReadFloat(baud, RXD, out op1);
                UART.ReadFloat(baud, RXD, out op2);

                FloatControllersOps.TestHandler(op1, op2, 0, out res);

                // TODO: this is constant expression, should remove branch comletely
                if (idx == 0)
                {
                    res0     = res;
                    handler0 = true;
                }
                else
                {
                    res1     = res;
                    handler1 = true;
                }
            };

            FPGA.Config.OnStartup(handler, 2);

            // expect to be completed at exactly the same time as they should not share FPU
            Func <bool> trigger = () => handler0 && handler1;

            Sequential onTigger = () =>
            {
                UART.RegisteredWriteFloat(baud, res0, out internalTXD);
                UART.RegisteredWriteFloat(baud, res1, out internalTXD);
            };

            FPGA.Config.OnSignal(trigger, onTigger);
        }