Skip to content

Commit

Permalink
Add function to set max possible frequency for dram
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-g committed Sep 6, 2015
1 parent 79f19fa commit bb7e613
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/com/custom_computing_ic/dfe_snippets/manager/ManagerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@
import com.maxeler.maxcompiler.v2.managers.custom.stdlib.MemoryControlGroup;
import com.maxeler.maxcompiler.v2.managers.custom.blocks.KernelBlock;

import static com.maxeler.maxcompiler.v2.managers.custom.CustomManager.LMemFrequency.*;

import java.util.HashMap;

public class ManagerUtils {

public static void setDRAMMaxDeviceFrequency(CustomManager manager, EngineParameters ep) {
if (ep.getDFEModel() == DFEModel.MAIA) {
setDRAMFreq(manager, ep, 800);
} else {
setDRAMFreq(manager, ep, 400);
}
}

public static void setDRAMFreq(CustomManager manager, EngineParameters ep, int freq) {
MemoryControllerConfig memCfg = new MemoryControllerConfig();

Expand All @@ -29,20 +39,27 @@ public static void setDRAMFreq(CustomManager manager, EngineParameters ep, int f
memCfg.setMAX4qMode(true);
memCfg.setDataReadFIFOExtraPipelineRegInFabric(true); // for easier meeting LMem timing

intToFreq.put(400, CustomManager.LMemFrequency.MAX4MAIA_400);
intToFreq.put(533, CustomManager.LMemFrequency.MAX4MAIA_533);
intToFreq.put(666, CustomManager.LMemFrequency.MAX4MAIA_666);
intToFreq.put(733, CustomManager.LMemFrequency.MAX4MAIA_733);
intToFreq.put(800, CustomManager.LMemFrequency.MAX4MAIA_800);
intToFreq.put(400, MAX4MAIA_400);
intToFreq.put(533, MAX4MAIA_533);
intToFreq.put(666, MAX4MAIA_666);
intToFreq.put(733, MAX4MAIA_733);
intToFreq.put(800, MAX4MAIA_800);
}
else
{
intToFreq.put(300, CustomManager.LMemFrequency.MAX3_300);
intToFreq.put(333, CustomManager.LMemFrequency.MAX3_333);
intToFreq.put(350, CustomManager.LMemFrequency.MAX3_350);
intToFreq.put(400, CustomManager.LMemFrequency.MAX3_400);
intToFreq.put(300, MAX3_300);
intToFreq.put(333, MAX3_333);
intToFreq.put(350, MAX3_350);
intToFreq.put(400, MAX3_400);
}
manager.config.setOnCardMemoryFrequency(intToFreq.get(freq));

CustomManager.LMemFrequency frequency = intToFreq.get(freq);
if (frequency != null) {
manager.config.setOnCardMemoryFrequency(intToFreq.get(freq));
} else {
throw new RuntimeException("Unsupported memory frequency " + freq + " for device mode " + ep.getDFEModel());
}

manager.config.setMemoryControllerConfig(memCfg);
}

Expand Down

0 comments on commit bb7e613

Please sign in to comment.