use of de.neemann.digital.hdl.model2.expression.ExprConstant in project Digital by hneemann.
the class MergeConstants method optimize.
@Override
public void optimize(HDLCircuit circuit) throws HDLException {
this.circuit = circuit;
ArrayList<HDLNode> nodes = circuit.getNodes();
int n1 = 0;
while (n1 < nodes.size()) {
final HDLNode node1 = nodes.get(n1);
ExprConstant con1 = ExprConstant.isConstant(node1);
if (con1 != null) {
// CHECKSTYLE.OFF: ModifiedControlVariable
for (int n2 = n1 + 1; n2 < nodes.size(); n2++) {
final HDLNode node2 = nodes.get(n2);
ExprConstant con2 = ExprConstant.isConstant(node2);
if (con2 != null) {
if (con1.isEqualTo(con2)) {
merge(node1, node2);
nodes.remove(n2);
n2--;
}
}
}
// CHECKSTYLE.ON: ModifiedControlVariable
}
n1++;
}
}
use of de.neemann.digital.hdl.model2.expression.ExprConstant in project Digital by hneemann.
the class RemoveConstantSignals method optimize.
@Override
public void optimize(HDLCircuit circuit) {
Iterator<HDLNet> it = circuit.getNets().iterator();
while (it.hasNext()) {
HDLNet net = it.next();
final ExprConstant constant = net.isConstant();
if (constant != null && isOnlyUsedInSupportedNodes(net)) {
circuit.getNodes().remove(net.getOutput().getParent());
it.remove();
circuit.replaceNetByExpression(net, new ExprConstant(constant));
}
}
}
Aggregations