325f63fb70b22a33eae1424bb41504dc0ab54605
[Mograsim.git] /
1 package net.mograsim.logic.model.am2900.machine;
2
3 import java.util.Collections;
4 import java.util.HashSet;
5 import java.util.Set;
6
7 import net.mograsim.logic.model.am2900.machine.registers.NumberedRegister;
8 import net.mograsim.logic.model.am2900.machine.registers.QRegister;
9 import net.mograsim.logic.model.model.LogicModelModifiable;
10 import net.mograsim.machine.ISASchema;
11 import net.mograsim.machine.MachineDefinition;
12 import net.mograsim.machine.Register;
13
14 //we can't use the Singleton pattern here because a MachineDefinition needs a public parameterless constructor
15 //(used for detecting installed machines in plugin.core)
16 public class Am2900MachineDefinition implements MachineDefinition
17 {
18         public static final String AM2900_MACHINE_ID = "Am2900";
19
20         public static final Set<Register> allRegisters;
21
22         static
23         {
24                 Set<Register> allRegistersModifiable = new HashSet<>();
25                 allRegistersModifiable.add(QRegister.instance);
26                 allRegistersModifiable.addAll(NumberedRegister.instancesCorrectOrder);
27                 allRegisters = Collections.unmodifiableSet(allRegistersModifiable);
28         }
29
30         @Override
31         public String getId()
32         {
33                 return AM2900_MACHINE_ID;
34         }
35
36         @Override
37         public Am2900Machine createNew()
38         {
39                 return createNew(new LogicModelModifiable());
40         }
41
42         public Am2900Machine createNew(LogicModelModifiable model)
43         {
44                 return new Am2900Machine(model, this);
45         }
46
47         @Override
48         public ISASchema getISASchema()
49         {
50                 // TODO Auto-generated method stub
51                 return null;
52         }
53
54         @Override
55         public Set<Register> getRegisters()
56         {
57                 return allRegisters;
58         }
59
60         @Override
61         public int getAddressBits()
62         {
63                 return 16;
64         }
65
66         @Override
67         public Am2900MainMemoryDefinition getMainMemoryDefinition()
68         {
69                 return Am2900MainMemoryDefinition.instance;
70         }
71
72         @Override
73         public int hashCode()
74         {
75                 return 12345;
76         }
77
78         @Override
79         public boolean equals(Object obj)
80         {
81                 return obj != null && obj instanceof Am2900MachineDefinition;
82         }
83
84         @Override
85         public Am2900MicroInstructionMemoryDefinition getMicroInstructionMemoryDefinition()
86         {
87                 return Am2900MicroInstructionMemoryDefinition.instance;
88         }
89
90 }