mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-09 12:56:02 -04:00
improved error message on vhdl naming issues
This commit is contained in:
parent
1031b8ee56
commit
70b0f2e665
@ -34,6 +34,7 @@ import de.neemann.digital.hdl.printer.CodePrinter;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
import de.neemann.digital.testing.TestCaseElement;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@ -46,6 +47,7 @@ public class HDLCircuit implements Iterable<HDLNode>, HDLModel.BitProvider, Prin
|
||||
private final ArrayList<HDLPort> inputs;
|
||||
private final ArrayList<HDLNet> listOfNets;
|
||||
private final String description;
|
||||
private final File origin;
|
||||
private ArrayList<HDLPort> ports;
|
||||
private NetList netList;
|
||||
private ArrayList<HDLNode> nodes;
|
||||
@ -93,6 +95,7 @@ public class HDLCircuit implements Iterable<HDLNode>, HDLModel.BitProvider, Prin
|
||||
listOfNets = new ArrayList<>();
|
||||
netList = new NetList(circuit);
|
||||
description = circuit.getAttributes().get(Keys.DESCRIPTION);
|
||||
this.origin = circuit.getOrigin();
|
||||
|
||||
ArrayList<ClockInfo> clocks = new ArrayList<>();
|
||||
|
||||
@ -410,20 +413,25 @@ public class HDLCircuit implements Iterable<HDLNode>, HDLModel.BitProvider, Prin
|
||||
* @throws HDLException HDLException
|
||||
*/
|
||||
public void rename(HDLModel.Renaming renaming) throws HDLException {
|
||||
for (HDLPort p : outputs)
|
||||
p.rename(renaming);
|
||||
for (HDLPort p : inputs)
|
||||
p.rename(renaming);
|
||||
for (HDLNet p : listOfNets)
|
||||
p.rename(renaming);
|
||||
try {
|
||||
for (HDLPort p : outputs)
|
||||
p.rename(renaming);
|
||||
for (HDLPort p : inputs)
|
||||
p.rename(renaming);
|
||||
for (HDLNet p : listOfNets)
|
||||
p.rename(renaming);
|
||||
|
||||
for (HDLNode n : nodes)
|
||||
n.rename(renaming);
|
||||
for (HDLNode n : nodes)
|
||||
n.rename(renaming);
|
||||
|
||||
hdlEntityName = renaming.checkName(hdlEntityName);
|
||||
hdlEntityName = renaming.checkName(hdlEntityName);
|
||||
|
||||
checkUnique(getPorts());
|
||||
checkUnique(listOfNets);
|
||||
checkUnique(getPorts());
|
||||
checkUnique(listOfNets);
|
||||
} catch (HDLException e) {
|
||||
e.setOrigin(origin);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUnique(Collection<? extends HasName> names) throws HDLException {
|
||||
@ -498,7 +506,12 @@ public class HDLCircuit implements Iterable<HDLNode>, HDLModel.BitProvider, Prin
|
||||
* @throws HDLException HDLException
|
||||
*/
|
||||
public HDLCircuit apply(Optimization optimization) throws HDLException {
|
||||
optimization.optimize(this);
|
||||
try {
|
||||
optimization.optimize(this);
|
||||
} catch (HDLException e) {
|
||||
e.setOrigin(origin);
|
||||
throw e;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,12 @@
|
||||
*/
|
||||
package de.neemann.digital.hdl.model2;
|
||||
|
||||
import de.neemann.digital.core.ExceptionWithOrigin;
|
||||
|
||||
/**
|
||||
* Exception thrown during model building
|
||||
*/
|
||||
public class HDLException extends Exception {
|
||||
public class HDLException extends ExceptionWithOrigin {
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
|
@ -56,6 +56,8 @@ public class VHDLRenaming implements HDLModel.Renaming {
|
||||
sb.append(c);
|
||||
else {
|
||||
switch (c) {
|
||||
case '/':
|
||||
case '!':
|
||||
case '~':
|
||||
case '\u00AC':
|
||||
sb.append("not");
|
||||
|
@ -19,6 +19,8 @@ public class VHDLRenamingTest extends TestCase {
|
||||
assertEquals("a_o_o", r.checkName("a\"o\"o"));
|
||||
assertEquals("o", r.checkName("\"o\""));
|
||||
assertEquals("o", r.checkName("_o_"));
|
||||
assertEquals("notQ", r.checkName("/Q"));
|
||||
assertEquals("notQ", r.checkName("!Q"));
|
||||
assertEquals("notQ", r.checkName("~Q"));
|
||||
assertEquals("aleb", r.checkName("a<b"));
|
||||
assertEquals("agrb", r.checkName("a>b"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user