e5e34ebb398332bdfe52c614372f00b1f39fe718
[Mograsim.git] /
1 package net.mograsim.logic.model.am2900.components;
2
3 import java.util.Map;
4
5 import net.mograsim.logic.core.timeline.Timeline;
6 import net.mograsim.logic.core.wires.CoreWire;
7 import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
8 import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
9 import net.mograsim.logic.model.model.wires.Pin;
10 import net.mograsim.logic.model.modeladapter.CoreModelParameters;
11 import net.mograsim.logic.model.modeladapter.componentadapters.ComponentAdapter;
12 import net.mograsim.machine.standard.memory.CoreWordAddressableMemory;
13
14 public class ModelAm2900MainMemoryAdapter implements ComponentAdapter<ModelAm2900MainMemory>
15 {
16
17         @Override
18         public Class<ModelAm2900MainMemory> getSupportedClass()
19         {
20                 return ModelAm2900MainMemory.class;
21         }
22
23         @Override
24         public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelAm2900MainMemory modelComponent,
25                         Map<Pin, CoreWire> logicWiresPerPin)
26         {
27                 ReadWriteEnd data = logicWiresPerPin.get(modelComponent.getDataPin()).createReadWriteEnd();
28                 ReadEnd address = logicWiresPerPin.get(modelComponent.getAddressPin()).createReadOnlyEnd();
29                 ReadEnd mode = logicWiresPerPin.get(modelComponent.getReadWritePin()).createReadOnlyEnd();
30                 CoreWordAddressableMemory mem = new CoreWordAddressableMemory(timeline, 2, modelComponent.getMachine().getMainMemory(), data, mode,
31                                 address);
32                 modelComponent.setCoreModelBinding(mem);
33         }
34 }