public void BitReverseController()
 {
     using (var port = new COMPort())
     {
         port.Write(0);
         foreach (var i in _bp.Range)
         {
             var reversed = port.ReadUInt32(port.DefaultTimeout);
             Assert.AreEqual(FPGA.Runtime.Reverse(i, _bp.Bits), reversed, $"Failed for {i}");
         }
     }
 }
        public void FPUTimingController()
        {
            using (var port = new COMPort())
            {
                var ops = new[]
                {
                    FPUTimingType.None,
                    FPUTimingType.Add,
                    FPUTimingType.Sub,
                    FPUTimingType.Mul,
                    FPUTimingType.Div
                };

                var durations = new Dictionary <FPUTimingType, uint>();
                var results   = new Dictionary <FPUTimingType, float>();
                var op1       = 100000000f;
                var op2       = 10f;

                foreach (var op in ops)
                {
                    port.Write(new byte[] { (byte)op });
                    port.WriteFloat(op1);
                    port.WriteFloat(op2);

                    var opResult = port.ReadFloat(port.DefaultTimeout);
                    var duration = port.ReadUInt32(port.DefaultTimeout);
                    durations[op] = duration;
                    results[op]   = opResult;
                }

                /// current FPU overhead is 11 clocks 8-{
                const int overhead    = 11;
                var       opDurations = durations
                                        .Select(p => new { p.Key, Value = Math.Max(overhead, p.Value - durations[FPUTimingType.None]) - overhead })
                                        .ToDictionary(p => p.Key, p => p.Value);
            }
        }