Esempio n. 1
0
        public void Merge_Pulled()
        {
            var pullBehavior = PullBehavior.PullUp;
            var input        = new List <DataValue>();

            input.Add(
                DataValue.FromValues(
                    new[]
            {
                BitValue.One,
                BitValue.Floating,
                BitValue.Floating
            }));
            input.Add(
                DataValue.FromValues(
                    new[]
            {
                BitValue.Floating,
                BitValue.Zero,
                BitValue.Floating
            }));

            BitValue[] expected =
            {
                BitValue.One,
                BitValue.Zero,
                BitValue.One
            };

            DataValue actual = DataValue.Merge(input, pullBehavior);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 2
0
        public void Zero()
        {
            var bitWidth = 2;

            BitValue[] expected =
            {
                BitValue.Zero,
                BitValue.Zero
            };

            DataValue actual = DataValue.Zero(bitWidth);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 3
0
        public void Floating()
        {
            var bitWidth = 2;

            BitValue[] expected =
            {
                BitValue.Floating,
                BitValue.Floating
            };

            DataValue actual = DataValue.Floating(bitWidth);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 4
0
        public void Error()
        {
            var bitWidth = 2;

            BitValue[] expected =
            {
                BitValue.Error,
                BitValue.Error
            };

            DataValue actual = DataValue.Error(bitWidth);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 5
0
        public void Boolean_False()
        {
            var value    = false;
            var bitWidth = 2;

            BitValue[] expected =
            {
                BitValue.Zero,
                BitValue.Zero
            };

            DataValue actual = DataValue.Boolean(value, bitWidth);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 6
0
        public void Signed_MaxBitWidth()
        {
            int  bitWidth = DataValue.MaxBitWidth;
            long value    = long.MaxValue;
            var  expected = new BitValue[bitWidth];

            for (var i = 0; i < bitWidth; i++)
            {
                expected[i] = i == bitWidth - 1
                    ? BitValue.Zero
                    : BitValue.One;
            }

            DataValue actual = DataValue.Signed(value, bitWidth);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 7
0
        public void Signed_Negative()
        {
            var  bitWidth = 4;
            long value    = -3;

            BitValue[] expected =
            {
                BitValue.One,
                BitValue.Zero,
                BitValue.One,
                BitValue.One
            };

            DataValue actual = DataValue.Signed(value, bitWidth);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 8
0
        public void Unsigned()
        {
            var   bitWidth = 4;
            ulong value    = 3;

            BitValue[] expected =
            {
                BitValue.One,
                BitValue.One,
                BitValue.Zero,
                BitValue.Zero
            };

            DataValue actual = DataValue.Unsigned(value, bitWidth);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 9
0
        public void Split()
        {
            DataValue input = DataValue.FromValues(
                new[]
            {
                BitValue.One,
                BitValue.One,
                BitValue.Zero,
                BitValue.Zero,
                BitValue.Floating,
                BitValue.Floating,
                BitValue.Floating
            });

            BitValue[][] expected =
            {
                new[]
                {
                    BitValue.One,
                    BitValue.One
                },
                new[]
                {
                    BitValue.Zero,
                    BitValue.Zero
                },
                new[]
                {
                    BitValue.Floating,
                    BitValue.Floating,
                    BitValue.Floating
                }
            };

            DataValue[] actual = DataValue.Split(input, 2, 2, 3);

            for (var i = 0; i < 3; i++)
            {
                DataValueTest.ValidateValuesEqual(actual[i], expected[i]);
            }
        }
Esempio n. 10
0
        public void FromValues_NonNull()
        {
            BitValue[] input =
            {
                BitValue.One,
                BitValue.Zero,
                BitValue.Floating,
                BitValue.Error
            };
            BitValue[] expected =
            {
                BitValue.One,
                BitValue.Zero,
                BitValue.Floating,
                BitValue.Error
            };

            DataValue actual = DataValue.FromValues(input);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }
Esempio n. 11
0
        public void Concatenate()
        {
            DataValue input1 = DataValue.FromValues(
                new[]
            {
                BitValue.One,
                BitValue.One
            });
            DataValue input2 = DataValue.FromValues(
                new[]
            {
                BitValue.Zero,
                BitValue.Zero
            });
            DataValue input3 = DataValue.FromValues(
                new[]
            {
                BitValue.Floating,
                BitValue.Floating,
                BitValue.Floating
            });

            BitValue[] expected =
            {
                BitValue.One,
                BitValue.One,
                BitValue.Zero,
                BitValue.Zero,
                BitValue.Floating,
                BitValue.Floating,
                BitValue.Floating
            };

            DataValue actual = DataValue.Concatenate(
                input1,
                input2,
                input3);

            DataValueTest.ValidateValuesEqual(actual, expected);
        }