Apply formatter, optional problems, save actions to machine project
[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.MainMemoryDefinition;
7 import net.mograsim.machine.ModelMemory;
8
9 public abstract class ModelWordAddressableMemory extends ModelMemory
10 {
11         private final Pin addrPin, dataPin, rWPin;
12         private CoreWordAddressableMemory memory;
13         private MainMemoryDefinition definition;
14
15         public ModelWordAddressableMemory(LogicModelModifiable model, MainMemoryDefinition definition, String name)
16         {
17                 super(model, 120, 150, name, "RAM", false);
18                 this.definition = definition;
19
20                 addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, getWidth(), 30));
21                 addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, getWidth(), 50));
22                 addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, getWidth(), 70));
23
24                 init();
25         }
26
27         public MainMemoryDefinition getDefinition()
28         {
29                 return definition;
30         }
31
32         public Pin getAddressPin()
33         {
34                 return addrPin;
35         }
36
37         public Pin getDataPin()
38         {
39                 return dataPin;
40         }
41
42         public Pin getReadWritePin()
43         {
44                 return rWPin;
45         }
46
47         public void setCoreModelBinding(CoreWordAddressableMemory memory)
48         {
49                 this.memory = memory;
50         }
51
52         public CoreWordAddressableMemory getCoreMemory()
53         {
54                 return memory;
55         }
56 }