public Computable(Output con)
 {
     this.Node       = null;
     this.Con        = con;
     this.IsBorderIO = con.Node is Module || con.Node is Wire;
     this.OldValue   = new BinaryVarValue();
 }
Exemple #2
0
        internal static void VerifyInferTypes(string moduleName, string extension, bool isVerilogVCD, string modulePath)
        {
            CircuitGraph graph = VerifyMakeGraph(moduleName, extension, modulePath);

            using VCD vcd = LoadVCD(moduleName, modulePath);

            foreach (var variables in vcd.Variables)
            {
                foreach (var variable in variables)
                {
                    ScalarIO varCon = graph.GetConnection(variable, isVerilogVCD);
                    if (varCon == null)
                    {
                        continue;
                    }

                    ref BinaryVarValue actual = ref varCon.GetValue();
                    if (!varCon.Value.IsInitialized())
                    {
                        continue;
                    }
                    if (variable.Size != actual.Bits.Length)
                    {
                        Console.WriteLine($"Ref: {variable.Reference}, Expected: {variable.Size}, Actual: {actual.Bits.Length}");
                    }
                    Assert.AreEqual(variable.Size, actual.Bits.Length);
                }
            }
 public Computable(FIRRTLNode node)
 {
     this.Node       = node;
     this.Con        = null;
     this.IsBorderIO = false;
     this.OldValue   = new BinaryVarValue();
 }
Exemple #4
0
        public ValueType(GroundType type)
        {
            this.IsSigned       = type is SIntType;
            this.HasInitialized = true;
            this.Value          = new BinaryVarValue(type.Width, false);
            Value.SetAllUnknown();

            this.ValueString = null;
        }
 public override void Compute()
 {
     //Copy input values to outputs
     for (int i = 0; i < VecInputs.Length; i++)
     {
         if (VecInputs[i].IsConnectedToAnything())
         {
             ref BinaryVarValue binValue = ref VecInputs[i].UpdateValueFromSourceFast();
             VecOutputs[i].Value.UpdateValue(ref binValue);
         }
        public override void Compute()
        {
            if (FirstCompute)
            {
                FirstCompute = false;

                BinaryVarValue binValue = new BinaryVarValue(Value.Width, true);
                binValue.SetBitsAndExtend(Value.Value, false);
                Result.Value.UpdateValue(ref binValue);
            }
        }
        public void InferType()
        {
            if (Node != null)
            {
                Node.InferType();
            }
            else
            {
                Con.InferType();
                Con.SetDefaultvalue();
                OldValue = new BinaryVarValue(Con.GetValue().Bits.Length, false);
                OldValue.SetAllUnknown();

                foreach (var input in Con.GetConnectedInputs())
                {
                    input.InferType();
                    input.SetDefaultvalue();
                }
            }
        }
        public bool SameValue(ref BinaryVarValue other)
        {
            ReadOnlySpan <BitState> rBits      = Bits;
            ReadOnlySpan <BitState> rBitsOther = other.Bits;

            if (rBits.Length != rBitsOther.Length)
            {
                return(false);
            }

            //xor of two equivalent values gives 0 and anything else
            //gives not 0. If check can be replaced with this check by checking
            //that all xors give 0 in return. That's how this check work. In
            //addition to that, poor simd is used to xor 8 BitStates at once.
            ulong xored = 0;
            int   index = 0;

            if (rBits.Length >= sizeof(ulong))
            {
                ReadOnlySpan <ulong> uBits      = MemoryMarshal.Cast <BitState, ulong>(rBits);
                ReadOnlySpan <ulong> uBitsOther = MemoryMarshal.Cast <BitState, ulong>(rBitsOther);

                for (; index < uBits.Length; index++)
                {
                    xored |= uBits[index] ^ uBitsOther[index];
                }

                const int sizeDiff = sizeof(BitState) / sizeof(ulong);
                index *= sizeDiff;
            }

            for (; index < rBits.Length; index++)
            {
                xored |= (ulong)rBits[index] ^ (ulong)rBitsOther[index];
            }

            return(xored == 0);
        }
        public bool SameValue(ref BinaryVarValue other, bool isSigned)
        {
            if (Bits.Length == other.Bits.Length)
            {
                return(SameValue(ref other));
            }

            ReadOnlySpan <BitState> minL = Bits.Length < other.Bits.Length ? Bits : other.Bits;
            ReadOnlySpan <BitState> maxL = Bits.Length < other.Bits.Length ? other.Bits : Bits;

            if (minL.Length == 0)
            {
                for (int i = 0; i < maxL.Length; i++)
                {
                    if (maxL[i] != BitState.Zero)
                    {
                        return(false);
                    }
                }

                return(true);
            }

            BitState expectedRemainer = isSigned ? minL[^ 1] : BitState.Zero;
Exemple #10
0
        internal void AddChange(BinaryVarValue value)
        {
            var variable = value.Variables[0];

            VariableValues[variable.ID] = value;
        }
Exemple #11
0
 public void UpdateValue(ref BinaryVarValue update)
 {
     Value.SetBitsAndExtend(ref update, IsSigned);
 }