import net.mograsim.logic.model.SimpleLogicUIStandalone;
import net.mograsim.logic.model.am2900.Am2900Loader;
+import net.mograsim.logic.model.am2900.machine.Am2900ExpertMachineDefinition;
import net.mograsim.logic.model.model.LogicModelModifiable;
import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.components.atomic.ModelBitDisplay;
import net.mograsim.logic.model.model.wires.ModelWire;
import net.mograsim.logic.model.model.wires.Pin;
import net.mograsim.logic.model.model.wires.PinUsage;
-import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
public class ModelComponentTestbench
{
public static void createTestbench(LogicModelModifiable model)
{
Am2900Loader.setup();
-// ModelComponent comp = new Am2900ExpertMachineDefinition().createNew(model).getAm2900();
- ModelComponent comp = IndirectModelComponentCreator.createComponent(model, "ram5_12");
+ ModelComponent comp = new Am2900ExpertMachineDefinition().createNew(model).getAm2900();
+// ModelComponent comp = IndirectModelComponentCreator.createComponent(model, "ram5_12");
List<String> inputPinNames = new ArrayList<>();
List<String> outputPinNames = new ArrayList<>();
package net.mograsim.logic.model;
import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_ONE_COLOR;
+import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_ONE_DASH;
import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_U_COLOR;
+import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_U_DASH;
import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_X_COLOR;
+import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_X_DASH;
import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_ZERO_COLOR;
+import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_ZERO_DASH;
import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_Z_COLOR;
+import static net.mograsim.logic.model.preferences.RenderPreferences.BIT_Z_DASH;
import java.math.BigInteger;
return bitvector;
}
+ public static double[] formatAsLineDash(RenderPreferences renderPrefs, ReadEnd end)
+ {
+ return formatAsLineDash(renderPrefs, end == null ? null : end.getValues());
+ }
+
+ public static double[] formatAsLineDash(RenderPreferences renderPrefs, BitVector bitVector)
+ {
+ // TODO maybe find a line dash assignment for multiple-bit bit vectors?
+ if (bitVector == null || bitVector.length() != 1)
+ return null;
+ String prefName;
+ switch (bitVector.getLSBit(0))
+ {
+ case ONE:
+ prefName = BIT_ONE_DASH;
+ break;
+ case U:
+ prefName = BIT_U_DASH;
+ break;
+ case X:
+ prefName = BIT_X_DASH;
+ break;
+ case Z:
+ prefName = BIT_Z_DASH;
+ break;
+ case ZERO:
+ prefName = BIT_ZERO_DASH;
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown enum constant: " + bitVector.getLSBit(0));
+ }
+ return parseLineDashes(renderPrefs.getString(prefName));
+ }
+
+ // TODO this method does not belong here
+ public static double[] parseLineDashes(String dashesString)
+ {
+ if (dashesString.isEmpty())
+ return null;
+ String[] dashesStrings = dashesString.split(",");
+ double[] dashes = new double[dashesStrings.length];
+ for (int i = 0; i < dashesStrings.length; i++)
+ dashes[i] = Double.parseDouble(dashesStrings[i]);
+ return dashes;
+ }
+
public static ColorDefinition formatAsColor(RenderPreferences renderPrefs, ReadEnd end)
{
return formatAsColor(renderPrefs, end == null ? null : end.getValues());
if (wireColor != null)
gc.setForeground(ColorManager.current().toColor(wireColor));
gc.setLineWidth(renderPrefs.getDouble(logicWidth == 1 ? WIRE_WIDTH_SINGLEBIT : WIRE_WIDTH_MULTIBIT));
+ gc.setLineDash(BitVectorFormatter.formatAsLineDash(renderPrefs, end));
gc.drawPolyline(effectivePath);
+ gc.setLineDash(null);
gc.setLineWidth(renderPrefs.getDouble(DEFAULT_LINE_WIDTH));
}
{
switch (name)
{
+ case BIT_ZERO_DASH:
+ return "10, 2.5";
+ case BIT_Z_DASH:
+ return "10, 0.25, 0.25, 1.5, 0.25, 0.25";
+ case BIT_X_DASH:
+ return "10, 0.25, 0.25, 0.25, 0.25, 0.5, 0.25, 0.25, 0.25, 0.25";
+ case BIT_U_DASH:
+ return "10, 0.25, 0.25, 0.25, 1, 0.25, 0.25, 0.25";
+ case BIT_ONE_DASH:
+ return "10, 0.5, 1.5, 0.5";
default:
throw new IllegalArgumentException("Unknown string preference name: " + name);
}
public static final String WIRE_WIDTH_MULTIBIT = PREFIX + "linewidth.wire.multibit";
public static final String WIRE_WIDTH_SINGLEBIT = PREFIX + "linewidth.wire.singlebit";
public static final String DEFAULT_LINE_WIDTH = PREFIX + "linewidth.default";
+ public static final String BIT_ZERO_DASH = PREFIX + "linedash.bit.zero";
+ public static final String BIT_Z_DASH = PREFIX + "linedash.bit.z";
+ public static final String BIT_X_DASH = PREFIX + "linedash.bit.x";
+ public static final String BIT_U_DASH = PREFIX + "linedash.bit.u";
+ public static final String BIT_ONE_DASH = PREFIX + "linedash.bit.one";
public static final String ZOOM_BUTTON = PREFIX + "button.zoom";
public static final String DRAG_BUTTON = PREFIX + "button.drag";
public static final String ACTION_BUTTON = PREFIX + "button.action";