Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (29 sloc) 1011 Bytes
using Roluan.Emulator.Common.Enums;
namespace Roluan.Emulator.Common.Gates
{
/// <summary>
/// Represents The Ternary AND gate
/// </summary>
public static class TAND
{
public static Trit Output(Trit inputA, Trit inputB)
{
Check.IsNull(inputA);
Check.IsNull(inputB);
if ((inputA.State == TritState.Negative && inputB.State == TritState.Zero)
|| (inputA.State == TritState.Zero && inputB.State == TritState.Negative)
|| (inputA.State == TritState.Negative && inputB.State == TritState.Negative)
|| (inputA.State == TritState.Positive && inputB.State == TritState.Negative)
|| (inputA.State == TritState.Negative && inputB.State == TritState.Positive))
{
return new Trit(TritState.Negative);
}
if ((inputA.State == TritState.Positive && inputB.State == TritState.Zero)
|| (inputA.State == TritState.Zero && inputB.State == TritState.Positive))
{
return new Trit(TritState.Zero);
}
return new Trit(TritState.Zero);
}
}
}