d7fbbaa6c76578edefbbddeebdc55028bb12cdb1
[Mograsim.git] /
1 package net.mograsim.machine.standard.memory;
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
13 public class WordAddressableMemoryAdapter implements ComponentAdapter<ModelWordAddressableMemory>
14 {
15         @Override
16         public Class<ModelWordAddressableMemory> getSupportedClass()
17         {
18                 return ModelWordAddressableMemory.class;
19         }
20
21         @Override
22         public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelWordAddressableMemory modelComponent,
23                         Map<Pin, CoreWire> logicWiresPerPin)
24         {
25                 ReadWriteEnd data = logicWiresPerPin.get(modelComponent.getDataPin()).createReadWriteEnd();
26                 ReadEnd address = logicWiresPerPin.get(modelComponent.getAddressPin()).createReadOnlyEnd();
27                 ReadEnd mode = logicWiresPerPin.get(modelComponent.getReadWritePin()).createReadOnlyEnd();
28                 CoreWordAddressableMemory mem = new CoreWordAddressableMemory(timeline, 2, modelComponent.getDefinition(), data, mode, address);
29                 modelComponent.setCoreModelBinding(mem);
30         }
31 }