formatting
This commit is contained in:
@@ -1,35 +1,35 @@
|
||||
namespace UntitledLogicGame.Workspace.Gates
|
||||
{
|
||||
public enum GateType
|
||||
{
|
||||
// 000 - Technical
|
||||
None = 000,
|
||||
// 100 - I/O
|
||||
IN = 100,
|
||||
OUT = 110,
|
||||
// 200 - Basic
|
||||
BUF = 200,
|
||||
AND = 210,
|
||||
OR = 220,
|
||||
XOR = 230,
|
||||
public enum GateType
|
||||
{
|
||||
// 000 - Technical
|
||||
None = 000,
|
||||
// 100 - I/O
|
||||
IN = 100,
|
||||
OUT = 110,
|
||||
// 200 - Basic
|
||||
BUF = 200,
|
||||
AND = 210,
|
||||
OR = 220,
|
||||
XOR = 230,
|
||||
NOT = 240,
|
||||
NAND = 250,
|
||||
NOR = 260,
|
||||
XNOR = 270,
|
||||
// 300 - Latches
|
||||
SRLatch = 300,
|
||||
JKLatch = 310,
|
||||
DLatch = 320,
|
||||
// 500 - Flip-Flops
|
||||
SRFlipFlop = 400,
|
||||
JKFlipFlop = 410,
|
||||
DFlipFlop = 420,
|
||||
TFlipFlop = 430,
|
||||
// 500 - Arithmetic
|
||||
HalfAdd = 500,
|
||||
FullAdd = 510,
|
||||
HalfSub = 520,
|
||||
FullSub = 530,
|
||||
JKLatch = 310,
|
||||
DLatch = 320,
|
||||
// 500 - Flip-Flops
|
||||
SRFlipFlop = 400,
|
||||
JKFlipFlop = 410,
|
||||
DFlipFlop = 420,
|
||||
TFlipFlop = 430,
|
||||
// 500 - Arithmetic
|
||||
HalfAdd = 500,
|
||||
FullAdd = 510,
|
||||
HalfSub = 520,
|
||||
FullSub = 530,
|
||||
// 600 - Data
|
||||
Mux = 610,
|
||||
Demux = 620,
|
||||
|
||||
@@ -3,77 +3,77 @@ using System.Linq;
|
||||
|
||||
namespace UntitledLogicGame.Workspace.Gates
|
||||
{
|
||||
public class InputState : State
|
||||
{
|
||||
public InputState(IEnumerable<bool> args) : base(args) { }
|
||||
public class InputState : State
|
||||
{
|
||||
public InputState(IEnumerable<bool> args) : base(args) { }
|
||||
|
||||
public InputState(params bool[] args) : base(args) { }
|
||||
public InputState(params bool[] args) : base(args) { }
|
||||
|
||||
public InputState(int len) : base(len) { }
|
||||
}
|
||||
public InputState(int len) : base(len) { }
|
||||
}
|
||||
|
||||
public class OutputState : State
|
||||
{
|
||||
public OutputState(IEnumerable<bool> args) : base(args) { }
|
||||
{
|
||||
public OutputState(IEnumerable<bool> args) : base(args) { }
|
||||
|
||||
public OutputState(params bool[] args) : base(args) { }
|
||||
public OutputState(params bool[] args) : base(args) { }
|
||||
|
||||
public OutputState(int len) : base(len) { }
|
||||
}
|
||||
public OutputState(int len) : base(len) { }
|
||||
}
|
||||
|
||||
public abstract class State
|
||||
{
|
||||
internal int Length => values.Length;
|
||||
{
|
||||
internal int Length => values.Length;
|
||||
|
||||
internal bool[] values;
|
||||
internal bool[] values;
|
||||
|
||||
public State(IEnumerable<bool> args)
|
||||
{
|
||||
values = args.ToArray();
|
||||
}
|
||||
public State(IEnumerable<bool> args)
|
||||
{
|
||||
values = args.ToArray();
|
||||
}
|
||||
|
||||
public State(params bool[] args)
|
||||
{
|
||||
values = args;
|
||||
}
|
||||
public State(params bool[] args)
|
||||
{
|
||||
values = args;
|
||||
}
|
||||
|
||||
public State(int len)
|
||||
{
|
||||
values = new bool[len];
|
||||
}
|
||||
public State(int len)
|
||||
{
|
||||
values = new bool[len];
|
||||
}
|
||||
|
||||
public bool this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= values.Length)
|
||||
return false;
|
||||
return values[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index >= 0 && index < values.Length)
|
||||
values[index] = value;
|
||||
}
|
||||
}
|
||||
public bool this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= values.Length)
|
||||
return false;
|
||||
return values[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index >= 0 && index < values.Length)
|
||||
values[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is State state && Enumerable.SequenceEqual(values, state.values);
|
||||
}
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is State state && Enumerable.SequenceEqual(values, state.values);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
//https://stackoverflow.com/questions/6832139/gethashcode-from-booleans-only
|
||||
int hash = 17;
|
||||
for (int index = 0; index < values.Length; index++)
|
||||
hash = hash * 23 + values[index].GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
//https://stackoverflow.com/questions/6832139/gethashcode-from-booleans-only
|
||||
int hash = 17;
|
||||
for (int index = 0; index < values.Length; index++)
|
||||
hash = hash * 23 + values[index].GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(",", values);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(",", values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user