Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.machine / src / net / mograsim / machine / standard / memory / ModelWordAddressableMemory.java
1 package net.mograsim.machine.standard.memory;
2
3 import net.mograsim.logic.model.model.LogicModelModifiable;
4 import net.mograsim.logic.model.model.wires.Pin;
5 import net.mograsim.logic.model.model.wires.PinUsage;
6 import net.mograsim.machine.Machine;
7 import net.mograsim.machine.MainMemoryDefinition;
8 import net.mograsim.machine.ModelMemory;
9
10 public abstract class ModelWordAddressableMemory<M extends Machine> extends ModelMemory<M>
11 {
12         private final Pin addrPin, dataPin, rWPin;
13         private CoreWordAddressableMemory memory;
14         private MainMemoryDefinition definition;
15
16         public ModelWordAddressableMemory(LogicModelModifiable model, MainMemoryDefinition definition, String name)
17         {
18                 super(model, 120, 150, name, "RAM", false);
19                 this.definition = definition;
20
21                 addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, getWidth(), 30));
22                 addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, getWidth(), 50));
23                 addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, getWidth(), 70));
24
25                 init();
26         }
27
28         public MainMemoryDefinition getDefinition()
29         {
30                 return definition;
31         }
32
33         public Pin getAddressPin()
34         {
35                 return addrPin;
36         }
37
38         public Pin getDataPin()
39         {
40                 return dataPin;
41         }
42
43         public Pin getReadWritePin()
44         {
45                 return rWPin;
46         }
47
48         public void setCoreModelBinding(CoreWordAddressableMemory memory)
49         {
50                 this.memory = memory;
51         }
52
53         public CoreWordAddressableMemory getCoreMemory()
54         {
55                 return memory;
56         }
57 }