use of com.cburch.logisim.data.AttributeSet in project logisim-evolution by reds-heig.
the class AbstractFlipFlopHDLGeneratorFactory method GetPortMap.
@Override
public SortedMap<String, String> GetPortMap(Netlist Nets, NetlistComponent ComponentInfo, FPGAReport Reporter, String HDLType) {
SortedMap<String, String> PortMap = new TreeMap<String, String>();
Boolean GatedClock = false;
Boolean HasClock = true;
Boolean ActiveLow = false;
String OpenBracket = (HDLType.equals(VHDL)) ? "(" : "[";
String CloseBracket = (HDLType.equals(VHDL)) ? ")" : "]";
String ZeroBit = (HDLType.equals(VHDL)) ? "'0'" : "1'b0";
String SetBit = (HDLType.equals(VHDL)) ? "'1'" : "1'b1";
int nr_of_pins = ComponentInfo.NrOfEnds();
AttributeSet attrs = ComponentInfo.GetComponent().getAttributeSet();
if (!ComponentInfo.EndIsConnected(ComponentInfo.NrOfEnds() - 5)) {
Reporter.AddSevereWarning("Component \"" + ComponentName() + "\" in circuit \"" + Nets.getCircuitName() + "\" has no clock connection");
HasClock = false;
}
String ClockNetName = GetClockNetName(ComponentInfo, ComponentInfo.NrOfEnds() - 5, Nets);
if (ClockNetName.isEmpty()) {
GatedClock = true;
}
if (attrs.containsAttribute(StdAttr.EDGE_TRIGGER)) {
if (attrs.getValue(StdAttr.EDGE_TRIGGER) == StdAttr.TRIG_FALLING)
ActiveLow = true;
} else {
if (attrs.containsAttribute(StdAttr.TRIGGER)) {
if (attrs.getValue(StdAttr.TRIGGER) == StdAttr.TRIG_FALLING || attrs.getValue(StdAttr.TRIGGER) == StdAttr.TRIG_LOW)
ActiveLow = true;
}
}
PortMap.putAll(GetNetMap("Reset", true, ComponentInfo, nr_of_pins - 2, Reporter, HDLType, Nets));
PortMap.putAll(GetNetMap("Preset", true, ComponentInfo, nr_of_pins - 1, Reporter, HDLType, Nets));
if (HasClock && !GatedClock && Netlist.IsFlipFlop(attrs)) {
if (Nets.RequiresGlobalClockConnection()) {
PortMap.put("Tick", ClockNetName + OpenBracket + Integer.toString(ClockHDLGeneratorFactory.GlobalClockIndex) + CloseBracket);
} else {
if (ActiveLow)
PortMap.put("Tick", ClockNetName + OpenBracket + Integer.toString(ClockHDLGeneratorFactory.NegativeEdgeTickIndex) + CloseBracket);
else
PortMap.put("Tick", ClockNetName + OpenBracket + Integer.toString(ClockHDLGeneratorFactory.PositiveEdgeTickIndex) + CloseBracket);
}
PortMap.put("Clock", ClockNetName + OpenBracket + Integer.toString(ClockHDLGeneratorFactory.GlobalClockIndex) + CloseBracket);
} else if (!HasClock) {
PortMap.put("Tick", ZeroBit);
PortMap.put("Clock", ZeroBit);
} else {
PortMap.put("Tick", SetBit);
if (!GatedClock) {
if (ActiveLow)
PortMap.put("Clock", ClockNetName + OpenBracket + Integer.toString(ClockHDLGeneratorFactory.InvertedDerivedClockIndex) + CloseBracket);
else
PortMap.put("Clock", ClockNetName + OpenBracket + Integer.toString(ClockHDLGeneratorFactory.DerivedClockIndex) + CloseBracket);
} else {
PortMap.put("Clock", GetNetName(ComponentInfo, ComponentInfo.NrOfEnds() - 5, true, HDLType, Nets));
}
}
PortMap.putAll(GetInputMaps(ComponentInfo, Nets, Reporter, HDLType));
PortMap.putAll(GetNetMap("Q", true, ComponentInfo, nr_of_pins - 4, Reporter, HDLType, Nets));
PortMap.putAll(GetNetMap("Q_bar", true, ComponentInfo, nr_of_pins - 3, Reporter, HDLType, Nets));
return PortMap;
}
use of com.cburch.logisim.data.AttributeSet in project logisim-evolution by reds-heig.
the class SelectionAttributes method setValue.
@Override
public <V> void setValue(Attribute<V> attr, V value) {
Attribute<?>[] attrs = this.selAttrs;
Object[] values = this.selValues;
for (int i = 0; i < attrs.length; i++) {
if (attrs[i] == attr) {
boolean same = value == null ? values[i] == null : value.equals(values[i]);
if (!same) {
values[i] = value;
for (AttributeSet objAttrs : selected.keySet()) {
objAttrs.setValue(attr, value);
}
}
break;
}
}
}
use of com.cburch.logisim.data.AttributeSet in project logisim-evolution by reds-heig.
the class InstanceTextField method update.
void update(Attribute<String> labelAttr, Attribute<Font> fontAttr, int x, int y, int halign, int valign) {
boolean wasReg = shouldRegister();
this.labelAttr = labelAttr;
this.fontAttr = fontAttr;
this.fieldX = x;
this.fieldY = y;
this.halign = halign;
this.valign = valign;
boolean shouldReg = shouldRegister();
AttributeSet attrs = comp.getAttributeSet();
if (attrs.containsAttribute(StdAttr.LABEL_VISIBILITY))
LabelIsVisable = attrs.getValue(StdAttr.LABEL_VISIBILITY);
if (!wasReg && shouldReg)
attrs.addAttributeListener(this);
if (wasReg && !shouldReg)
attrs.removeAttributeListener(this);
updateField(attrs);
}
use of com.cburch.logisim.data.AttributeSet in project logisim-evolution by reds-heig.
the class ToolAttributeAction method doIt.
@Override
public void doIt(Project proj) {
AttributeSet attrs = config.getEvent().getAttributeSet();
Map<Attribute<?>, Object> newValues = config.getAttributeValues();
Map<Attribute<?>, Object> oldValues = new HashMap<Attribute<?>, Object>(newValues.size());
for (Map.Entry<Attribute<?>, Object> entry : newValues.entrySet()) {
@SuppressWarnings("unchecked") Attribute<Object> attr = (Attribute<Object>) entry.getKey();
oldValues.put(attr, attrs.getValue(attr));
attrs.setValue(attr, entry.getValue());
}
this.oldValues = oldValues;
}
use of com.cburch.logisim.data.AttributeSet in project logisim-evolution by reds-heig.
the class ToolAttributeAction method undo.
@Override
public void undo(Project proj) {
AttributeSet attrs = config.getEvent().getAttributeSet();
Map<Attribute<?>, Object> oldValues = this.oldValues;
for (Map.Entry<Attribute<?>, Object> entry : oldValues.entrySet()) {
@SuppressWarnings("unchecked") Attribute<Object> attr = (Attribute<Object>) entry.getKey();
attrs.setValue(attr, entry.getValue());
}
}
Aggregations