Merge branch 'development' of
[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, clock;
12         private CoreWordAddressableMemory memory;
13         private MainMemoryDefinition definition;
14
15         public ModelWordAddressableMemory(LogicModelModifiable model, MainMemoryDefinition definition, String name)
16         {
17                 super(model, 100, 300, name, "RAM", false);
18                 this.definition = definition;
19                 
20                 addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, width, 20));
21                 addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, width, 50));
22                 addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, width, 80));
23                 addPin(clock = new Pin(model, this, "C", 1, PinUsage.INPUT, width, 110));
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 Pin getClockPin()
49         {
50                 return clock;
51         }
52
53         public void setCoreModelBinding(CoreWordAddressableMemory memory)
54         {
55                 this.memory = memory;
56         }
57
58         public CoreWordAddressableMemory getCoreMemory()
59         {
60                 return memory;
61         }
62 }