1 /* 2 * Copyright (c) 2018 Helmut Neemann. 3 * Use of this source code is governed by the GPL v3 license 4 * that can be found in the LICENSE file. 5 */ 6 package de.neemann.digital.hdl.model2.optimizations; 7 8 import de.neemann.digital.hdl.model2.*; 9 import de.neemann.digital.hdl.model2.expression.ExprConstant; 10 11 /** 12 * Create proper constant signals names. 13 * Use only if {@link MergeConstants} is applied at first. 14 */ 15 public class NameConstantSignals implements Optimization { 16 @Override optimize(HDLCircuit circuit)17 public void optimize(HDLCircuit circuit) throws HDLException { 18 for (HDLNode n : circuit.getNodes()) { 19 ExprConstant con = ExprConstant.isConstant(n); 20 if (con != null) { 21 HDLNet net = ((HDLNodeAssignment) n).getTargetNet(); 22 if (net.getName() == null) 23 net.setName("const" + con.getBits() + "b" + con.getValue()); 24 } 25 } 26 } 27 } 28