gate sub-categories
This commit is contained in:
@@ -8,9 +8,18 @@ namespace UntitledLogicGame.Workspace.Gates
|
||||
{
|
||||
// Static properties
|
||||
private static Dictionary<GateType, GateDefinition> Definitions;
|
||||
public static Dictionary<GateCategory, List<GateType>> TypeCategoryList =>
|
||||
Enum.GetValues(typeof(GateCategory)).Cast<GateCategory>()
|
||||
.ToDictionary(
|
||||
c => c,
|
||||
c => Enum.GetValues(typeof(GateType)).Cast<GateType>()
|
||||
.Where(t => (GateCategory)((int)t / 100) == c).ToList()
|
||||
);
|
||||
|
||||
// Public properties
|
||||
public string Name { get; internal set; }
|
||||
public GateType Type { get; private set; }
|
||||
public GateCategory Category => (GateCategory)((int)Type / 100);
|
||||
public string Name => Type.ToString();
|
||||
public bool HasState => false;
|
||||
public Dictionary<InputState, OutputState> TruthTable { get; private set; } = new Dictionary<InputState, OutputState>();
|
||||
|
||||
@@ -27,9 +36,9 @@ namespace UntitledLogicGame.Workspace.Gates
|
||||
Definitions = new Dictionary<GateType, GateDefinition>();
|
||||
foreach (var gateType in Enum.GetValues(typeof(GateType)).Cast<GateType>())
|
||||
{
|
||||
var t = Type.GetType($"{typeof(GateDefinition).Namespace}.{gateType}Gate", true);
|
||||
var t = System.Type.GetType($"{typeof(GateDefinition).Namespace}.{gateType}Gate", true);
|
||||
Definitions[gateType] = (GateDefinition)t.GetConstructor(new Type[0]).Invoke(new object[0]);
|
||||
Definitions[gateType].Name = gateType.ToString();
|
||||
Definitions[gateType].Type = gateType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
public enum GateType
|
||||
{
|
||||
// 000 - Technical
|
||||
NONE = 000,
|
||||
// 100 - Special
|
||||
None = 000,
|
||||
// 100 - I/O
|
||||
IN = 100,
|
||||
OUT = 110,
|
||||
// 200 - Basic
|
||||
@@ -28,7 +28,7 @@
|
||||
// 500 - Arithmetic
|
||||
HalfAdd = 500,
|
||||
FullAdd = 510,
|
||||
HalSub = 520,
|
||||
HalfSub = 520,
|
||||
FullSub = 530,
|
||||
// 600 - Data
|
||||
Mux = 610,
|
||||
@@ -45,4 +45,17 @@
|
||||
Counter2b = 800,
|
||||
Counter4b = 810
|
||||
}
|
||||
|
||||
public enum GateCategory
|
||||
{
|
||||
None = 00,
|
||||
IO = 01,
|
||||
Basic = 02,
|
||||
Latches = 03,
|
||||
FlipFlops = 04,
|
||||
Arithmetic = 05,
|
||||
Data = 06,
|
||||
Registers = 07,
|
||||
Counters = 08
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user