public override bool TestGate() { Input1.SetValue(7); Input2.SetValue(7); if (Output.Get2sComplement() != 14) { return(false); } Input1.Set2sComplement(6); Input2.Set2sComplement(-6); if (Output.Get2sComplement() != 0) { return(false); } Input1.Set2sComplement(6); Input2.Set2sComplement(-1); if (Output.Get2sComplement() != 5) { return(false); } return(true); }
public override bool TestGate() { int value1; int value2; Random ran = new Random(); for (int i = 0; i < 4; i++) { value1 = ran.Next(0, ((int)Math.Pow(2, Size) - 1) / 2); value2 = ran.Next(0, ((int)Math.Pow(2, Size) - 1) / 2); Input1.SetValue(value1); Input2.SetValue(value2); //Console.WriteLine(ToString()); if (Output.GetValue() != value1 + value2) { return(false); } } return(true); }