public void a2_plus_b2(int a2, int b2, int f2, int f3) { var alu = new TTL74181(TTLGateTypeEnum.Perfect); alu.S0.Add(5); alu.S1.Add(0); alu.S2.Add(0); alu.S3.Add(5); alu.Cn.Add(5); alu.M.Add(0); alu.A0.Add(0); alu.A1.Add(0); alu.A2.Add(a2); alu.A3.Add(0); alu.B0.Add(0); alu.B1.Add(0); alu.B2.Add(b2); alu.B3.Add(0); Assert.True(alu.VerifyAllGateInputsConnected()); Assert.True(alu.VerifyNoShortedOutputs()); Assert.Equal(0, alu.F0(0)); Assert.Equal(0, alu.F1(0)); Assert.Equal(f2, alu.F2(0)); Assert.Equal(f3, alu.F3(0)); }
public void f_equals_0(int b0, int b1, int b2, int b3) { var alu = new TTL74181(TTLGateTypeEnum.Perfect); alu.S0.Add(0); alu.S1.Add(0); alu.S2.Add(5); alu.S3.Add(5); alu.Cn.Add(0); alu.M.Add(5); alu.A0.Add(0); alu.A1.Add(0); alu.A2.Add(0); alu.A3.Add(0); alu.B0.Add(b0); alu.B1.Add(b1); alu.B2.Add(b2); alu.B3.Add(b3); Assert.True(alu.VerifyAllGateInputsConnected()); Assert.True(alu.VerifyNoShortedOutputs()); Assert.Equal(5, alu.F0(0)); Assert.Equal(5, alu.F1(0)); Assert.Equal(5, alu.F2(0)); Assert.Equal(5, alu.F3(0)); }
public void a3_plus_b3(int a3, int b3, int f3, int cn4) { var alu = new TTL74181(TTLGateTypeEnum.Perfect); alu.S0.Add(5); alu.S1.Add(0); alu.S2.Add(0); alu.S3.Add(5); alu.Cn.Add(5); alu.M.Add(0); alu.A0.Add(0); alu.A1.Add(0); alu.A2.Add(0); alu.A3.Add(a3); alu.B0.Add(0); alu.B1.Add(0); alu.B2.Add(0); alu.B3.Add(b3); Assert.True(alu.VerifyAllGateInputsConnected()); Assert.True(alu.VerifyNoShortedOutputs()); Assert.Equal(0, alu.F0(0)); Assert.Equal(0, alu.F1(0)); Assert.Equal(0, alu.F2(0)); Assert.Equal(f3, alu.F3(0)); Assert.Equal(cn4, alu.Cn4(0)); // this output is inverted }
public void a0_plus_b0(int a0, int b0, int f0, int f1) { var alu = new TTL74181(TTLGateTypeEnum.Perfect); alu.S0.Add(5); alu.S1.Add(0); alu.S2.Add(0); alu.S3.Add(5); alu.Cn.Add(5); alu.M.Add(0); alu.A0.Add(a0); alu.A1.Add(0); alu.A2.Add(0); alu.A3.Add(0); alu.B0.Add(b0); alu.B1.Add(0); alu.B2.Add(0); alu.B3.Add(0); Assert.True(alu.VerifyAllGateInputsConnected()); Assert.True(alu.VerifyNoShortedOutputs()); Assert.Equal(f0, alu.F0(0)); Assert.Equal(f1, alu.F1(0)); Assert.Equal(0, alu.F2(0)); Assert.Equal(0, alu.F3(0)); }
public TTL8BitALUCircuit(TTLGateTypeEnum gateTypes) { Name = "8-bit ALU"; Alu1 = new TTL74181(gateTypes); Alu2 = new TTL74181(gateTypes); Alu1.Name = "ALU #1"; Alu2.Name = "ALU #2"; #region inputs // hard-code M to be zero for both ALUs Connections.Add(new Connection { Source = new Ground(1), WireTermination = Alu1.M, Name = "GND -> Alu1.M" }); Connections.Add(new Connection { Source = new Ground(1), WireTermination = Alu2.M, Name = "GND -> Alu2.M" }); Connections.Add(new Connection { Source = A0, WireTermination = Alu1.A0, Name = "A0 -> Alu1.A0" }); Connections.Add(new Connection { Source = A1, WireTermination = Alu1.A1, Name = "A1 -> Alu1.A1" }); Connections.Add(new Connection { Source = A2, WireTermination = Alu1.A2, Name = "A2 -> Alu1.A2" }); Connections.Add(new Connection { Source = A3, WireTermination = Alu1.A3, Name = "A3 -> Alu1.A3" }); Connections.Add(new Connection { Source = A4, WireTermination = Alu2.A0, Name = "A4 -> Alu2.A0" }); Connections.Add(new Connection { Source = A5, WireTermination = Alu2.A1, Name = "A5 -> Alu2.A1" }); Connections.Add(new Connection { Source = A6, WireTermination = Alu2.A2, Name = "A6 -> Alu2.A2" }); Connections.Add(new Connection { Source = A7, WireTermination = Alu2.A3, Name = "A7 -> Alu2.A3" }); Connections.Add(new Connection { Source = B0, WireTermination = Alu1.B0, Name = "B0 -> Alu1.B0" }); Connections.Add(new Connection { Source = B1, WireTermination = Alu1.B1, Name = "B1 -> Alu1.B1" }); Connections.Add(new Connection { Source = B2, WireTermination = Alu1.B2, Name = "B2 -> Alu1.B2" }); Connections.Add(new Connection { Source = B3, WireTermination = Alu1.B3, Name = "B3 -> Alu1.B3" }); Connections.Add(new Connection { Source = B4, WireTermination = Alu2.B0, Name = "B4 -> Alu2.B0" }); Connections.Add(new Connection { Source = B5, WireTermination = Alu2.B1, Name = "B5 -> Alu2.B1" }); Connections.Add(new Connection { Source = B6, WireTermination = Alu2.B2, Name = "B6 -> Alu2.B2" }); Connections.Add(new Connection { Source = B7, WireTermination = Alu2.B3, Name = "B7 -> Alu2.B3" }); Connections.Add(new Connection { Source = S0, WireTermination = Alu1.S0, Name = "S0 -> Alu1.S0" }); Connections.Add(new Connection { Source = S0, WireTermination = Alu2.S0, Name = "S0 -> Alu2.S0" }); Connections.Add(new Connection { Source = S1, WireTermination = Alu1.S1, Name = "S1 -> Alu1.S1" }); Connections.Add(new Connection { Source = S1, WireTermination = Alu2.S1, Name = "S1 -> Alu2.S1" }); Connections.Add(new Connection { Source = S2, WireTermination = Alu1.S2, Name = "S2 -> Alu1.S2" }); Connections.Add(new Connection { Source = S2, WireTermination = Alu2.S2, Name = "S2 -> Alu2.S2" }); Connections.Add(new Connection { Source = S3, WireTermination = Alu1.S3, Name = "S3 -> Alu1.S3" }); Connections.Add(new Connection { Source = S3, WireTermination = Alu2.S3, Name = "S3 -> Alu2.S3" }); Connections.Add(new Connection { Source = Cin, WireTermination = Alu1.Cn, Name = "Cin -> Alu1.Cn" }); #endregion }