/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { unchecked { return((Byte1.GetHashCode() * 397) ^ Byte2.GetHashCode()); } }
public void Test3() { // Arrange var instruction = new Byte2(-985); // Act var decodedInstruction = InstructionDecoder.Decode(instruction); // Assert decodedInstruction.ComputationInstruction.Should().BeTrue(); decodedInstruction.SourceMemory.Should().BeTrue(); decodedInstruction.Operation.zx.Should().BeTrue(); decodedInstruction.Operation.nx.Should().BeTrue(); decodedInstruction.Operation.zy.Should().BeFalse(); decodedInstruction.Operation.ny.Should().BeFalse(); decodedInstruction.Operation.Function.Should().BeFalse(); decodedInstruction.Operation.NegateOutput.Should().BeFalse(); decodedInstruction.Destination.A.Should().BeTrue(); decodedInstruction.Destination.D.Should().BeFalse(); decodedInstruction.Destination.Ram.Should().BeFalse(); decodedInstruction.Condition.GreaterThanZero.Should().BeTrue(); decodedInstruction.Condition.EqualToZero.Should().BeTrue(); decodedInstruction.Condition.LessThanZero.Should().BeTrue(); decodedInstruction.w.ToInt16().Should().Be(0); }
public Byte4(Byte2 xy, byte z, byte w) { this.X = xy.X; this.Y = xy.Y; this.Z = z; this.W = w; }
private static void InitSpriteAttribute(int i) { var temp = new Byte2(); temp.adress = ((AddressSetup)Memory[i + 2]); SpriteAttribute.Add(temp); }
public Byte4(byte x, byte y, Byte2 zw) { this.X = x; this.Y = y; this.Z = zw.X; this.W = zw.Y; }
public Byte4(byte x, Byte2 yz, byte w) { this.X = x; this.Y = yz.X; this.Z = yz.Y; this.W = w; }
public void Controlunit_can_add_two_numbers() { // Arrange var controlUnit = new ControlUnit(); // Act // Set A to 17 controlUnit.Do(new Byte2(17), false); controlUnit.Do(new Byte2(17), true); // Copy A to D var byte2 = new Byte2("1000100010010000"); controlUnit.Do(byte2, false); controlUnit.Do(byte2, true); // Set A to 29 controlUnit.Do(new Byte2(29), false); controlUnit.Do(new Byte2(29), true); // Add A and D and store result in A controlUnit.Do(new Byte2("1000000010100000"), false); var controlUnitOutput = controlUnit.Do(new Byte2("1000000010100000"), true); // Assert controlUnitOutput.J.Should().BeFalse(); controlUnitOutput.A.ToInt16().Should().Be(46); }
public void Controlunit_can_move_data_from_register_to_ram() { // Arrange var controlUnit = new ControlUnit(); // Act // Set A to 17 controlUnit.Do(new Byte2(17), false); controlUnit.Do(new Byte2(17), true); // Copy A to D var byte2 = new Byte2("1000100010010000"); controlUnit.Do(byte2, false); controlUnit.Do(byte2, true); // Set A to 0 controlUnit.Do(new Byte2(0), false); controlUnit.Do(new Byte2(0), true); // Copy D to Ram controlUnit.Do(new Byte2("1000000010001000"), false); controlUnit.Do(new Byte2("1000000010001000"), true); // Copy D to A controlUnit.Do(new Byte2("1000000010100000"), false); var controlUnitOutput = controlUnit.Do(new Byte2("1000000010100000"), true); // Assert controlUnitOutput.J.Should().BeFalse(); controlUnitOutput.A.ToInt16().Should().Be(17); }
public static bool EqualsZero(Byte2 a) { var eq0high = EqualsZero(a.High); var eq0low = EqualsZero(a.Low); return(Gates.And(eq0high, eq0low)); }
public static Byte2 Subtract(Byte2 a, Byte2 b) { var inverted = Gates.Invert16(b); var incremented = Increment(inverted); return(AddByte2(a, incremented, false).Low); }
public ControlUnitOutput Do(Byte2 data, bool clock) { var decodedInstruction = InstructionDecoder.Decode(data); var selectedSourceMemory = Select16.Do(decodedInstruction.SourceMemory, _memoryOutput.Ram, _memoryOutput.A); _aluOutput = ArithmeticLogicUnit.Do(decodedInstruction.Operation, _memoryOutput.D, selectedSourceMemory); _selectedBasedOnComputationInstruction = Select16.Do(decodedInstruction.ComputationInstruction, _aluOutput, decodedInstruction.w); _memoryOutput = _memory.Do(decodedInstruction.Destination, _selectedBasedOnComputationInstruction, clock); var isCondition = ArithmeticLogicUnit.Evaluate(decodedInstruction.Condition, _aluOutput); return(new ControlUnitOutput(isCondition, _memoryOutput.A)); }
public Byte4(Byte2 xy, Byte2 zw) { this.X = xy.X; this.Y = xy.Y; this.Z = zw.X; this.W = zw.Y; }
public AMask(Byte1 byte1 = Byte1.None, Byte2 byte2 = Byte2.None, Byte3 byte3 = Byte3.None, Byte4 byte4 = Byte4.None) { Mask = (AMaskValues)(((int)byte1 << 8 * 3) | ((int)byte2 << 8 * 2) | ((int)byte3 << 8 * 1) | ((int)byte4)); }
public static Byte2 Do(bool zero, bool negate, Byte2 data) { var selectZero = Select16.Do(zero, new Byte2(0), data); var selectNegate = Select16.Do(negate, Gates.Invert16(selectZero), selectZero); return(selectNegate); }
//public CombinedMemoryOutput Do(bool storeA, bool storeD, bool storeRam, Byte2 data, bool clock) //{ // var registerOutputA = _registerA.Do(storeA, data, clock); // var registerOutputD = _registerD.Do(storeD, data, clock); // var ramOutput = _ram.Do(registerOutputA, storeRam, data, clock); // return new CombinedMemoryOutput(registerOutputA, registerOutputD, ramOutput); //} public CombinedMemoryOutput Do(InstructionDecoder.Destination destination, Byte2 data, bool clock) { var registerOutputA = _registerA.Do(destination.A, data, clock); var registerOutputD = _registerD.Do(destination.D, data, clock); var ramOutput = _ram.Do(registerOutputA, destination.Ram, data, clock); return(new CombinedMemoryOutput(registerOutputA, registerOutputD, ramOutput)); }
public void Maxvalue_is_not_less_than_zero() { // Act var byte2 = new Byte2(short.MaxValue); var equalsZero = Arithmetics.IsLessThanZero(byte2); // Assert equalsZero.Should().BeFalse(); }
public FMask(Byte1 byte1 = Byte1.None, Byte2 byte2 = Byte2.None, Byte3 byte3 = Byte3.None, Byte4 byte4 = Byte4.None, Byte5 byte5 = Byte5.None) { Mask = (FMaskValues)(((long)byte1 << 8 * 4) | ((long)byte2 << 8 * 3) | ((long)byte3 << 8 * 2) | ((long)byte4 << 8) | ((long)byte5)); }
public void Test_0_increment() { // Arrange var a = new Byte2(0); // Act var byteResult = Arithmetics.Increment(a); // Assert byteResult.ToInt16().Should().Be(1); }
public void Run() { bool clock = false; while (true) { _programEngineOutput = _programEngine.Execute(_controlUnitOutput.J, _controlUnitOutput.A, clock); _controlUnitOutput = _controlUnit.Do(_programEngineOutput, clock); clock = !clock; } }
public void Test9() { // Arrange var byte2 = new Byte2("1111111111111111"); // Act var output = UnaryArithmeticLogicUnit.Do(false, false, byte2); // Assert output.ToString().Should().Be("1111111111111111"); }
public void Test3() { // Arrange var byte2 = new Byte2(0); // Act var output = UnaryArithmeticLogicUnit.Do(true, false, byte2); // Assert output.ToInt16().Should().Be(0); }
public void Test6() { // Arrange var byte2 = new Byte2(27); // Act var output = UnaryArithmeticLogicUnit.Do(false, true, byte2); // Assert output.ToUInt16().Should().Be(65508); }
public void Test_MinValue_increment() { // Arrange var a = new Byte2(short.MinValue); // Act var byteResult = Arithmetics.Increment(a); // Assert byteResult.ToInt16().Should().Be(short.MinValue + 1); }
public override int GetHashCode() { unchecked { int hashCode = Byte1.GetHashCode(); hashCode = (hashCode * 397) ^ Byte2.GetHashCode(); hashCode = (hashCode * 397) ^ Byte3.GetHashCode(); hashCode = (hashCode * 397) ^ Byte4.GetHashCode(); return(hashCode); } }
public void Test_255_plus_255() { // Arrange var byteA = new Byte2(255); var byteB = new Byte2(255); // Act var byteResult = Arithmetics.AddByte2(byteA, byteB, false); // Assert byteResult.ToInt32().Should().Be(510); }
public void Test1() { // Arrange var counter = new Counter(); var byte2 = new Byte2(0); // Act var output = counter.Do(false, byte2, false); // Assert output.ToInt16().Should().Be(0); }
public void Test6() { // Arrange var byte2X = new Byte2(1); var condition = new Condition(true, false, false); // Act var output = ArithmeticLogicUnit.Evaluate(condition, byte2X); // Assert output.Should().BeFalse(); }
public void Test_MinValue_subtract_1() { // Arrange var a = new Byte2(short.MinValue); var b = new Byte2(1); // Act var byteResult = Arithmetics.Subtract(a, b); // Assert byteResult.ToInt16().Should().Be(short.MaxValue); }
public void Test_0_subtract_0() { // Arrange var a = new Byte2(0); var b = new Byte2(0); // Act var byteResult = Arithmetics.Subtract(a, b); // Assert byteResult.ToInt16().Should().Be(0); }
public void Test1() { // Arrange var ram = new RandomAccessMemory(); var byte2 = new Byte2(42); // Act var output = ram.Do(false, false, byte2, false); // Assert output.ToInt16().Should().Be(0); }
public AMask(Byte1 byte1 = Byte1.None, Byte2 byte2 = Byte2.None, Byte3 byte3 = Byte3.None, Byte4 byte4 = Byte4.None, Byte5 byte5 = Byte5.None, Byte6 byte6 = Byte6.None, Byte7 byte7 = Byte7.None) { Mask = (AMaskValues) ((ulong)byte1 << 8 * 6 | (ulong)byte2 << 8 * 5 | (ulong)byte3 << 8 * 4 | (ulong)byte4 << 8 * 3 | (ulong)byte5 << 8 * 2 | (ulong)byte6 << 8 * 1 | (ulong)byte7 << 8 * 0); }