mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 07:28:20 -04:00
fixed a bug in creating CUPL files for GAL16v8
This commit is contained in:
parent
ed9937c07a
commit
fb5537dba8
@ -1,6 +1,6 @@
|
|||||||
package de.neemann.digital.builder.ATF1502;
|
package de.neemann.digital.builder.ATF1502;
|
||||||
|
|
||||||
import de.neemann.digital.builder.Gal16v8.Gal16v8CuplExporter;
|
import de.neemann.digital.builder.Gal16v8.CuplExporter;
|
||||||
import de.neemann.digital.builder.PinMap;
|
import de.neemann.digital.builder.PinMap;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -12,7 +12,7 @@ import java.util.Date;
|
|||||||
*
|
*
|
||||||
* @author hneemann
|
* @author hneemann
|
||||||
*/
|
*/
|
||||||
public class ATF1502CuplExporter extends Gal16v8CuplExporter {
|
public class ATF1502CuplExporter extends CuplExporter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new project name
|
* Creates a new project name
|
||||||
@ -33,6 +33,7 @@ public class ATF1502CuplExporter extends Gal16v8CuplExporter {
|
|||||||
18, 19, 20, 21, 24, 25, 26, 27, 28,
|
18, 19, 20, 21, 24, 25, 26, 27, 28,
|
||||||
29, 31, 33, 34, 36, 37, 38, 39, 40));
|
29, 31, 33, 34, 36, 37, 38, 39, 40));
|
||||||
setClockPin(43);
|
setClockPin(43);
|
||||||
|
setCreateNodes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package de.neemann.digital.builder;
|
package de.neemann.digital.builder;
|
||||||
|
|
||||||
import de.neemann.digital.analyse.expression.Expression;
|
import de.neemann.digital.analyse.expression.Expression;
|
||||||
|
import de.neemann.digital.builder.Gal16v8.CuplExporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used to create a circuit
|
* Interface used to create a circuit
|
||||||
* There are two implementations: the {@link de.neemann.digital.builder.circuit.CircuitBuilder} creates a circuit and the
|
* There are two implementations: the {@link de.neemann.digital.builder.circuit.CircuitBuilder} creates a circuit and the
|
||||||
* {@link de.neemann.digital.builder.Gal16v8.Gal16v8CuplExporter} creates a CUPL file
|
* {@link CuplExporter} creates a CUPL file
|
||||||
* which contains the circuit.
|
* which contains the circuit.
|
||||||
*
|
*
|
||||||
* @param <T> concrete Builder Type
|
* @param <T> concrete Builder Type
|
||||||
|
@ -21,11 +21,12 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a CUPL file
|
* Creates a CUPL file.
|
||||||
|
* The default setting is usable for GAL16V8 chips.
|
||||||
*
|
*
|
||||||
* @author hneemann
|
* @author hneemann
|
||||||
*/
|
*/
|
||||||
public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExporter> {
|
public class CuplExporter implements ExpressionExporter<CuplExporter> {
|
||||||
private final DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
private final DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
@ -36,12 +37,13 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
private final String devName;
|
private final String devName;
|
||||||
|
|
||||||
private String projectName;
|
private String projectName;
|
||||||
|
private boolean createNodes = false;
|
||||||
private int clockPin = 1;
|
private int clockPin = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new project name
|
* Creates a new project name
|
||||||
*/
|
*/
|
||||||
public Gal16v8CuplExporter() {
|
public CuplExporter() {
|
||||||
this(System.getProperty("user.name"), new Date());
|
this(System.getProperty("user.name"), new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
* @param username user name
|
* @param username user name
|
||||||
* @param date date
|
* @param date date
|
||||||
*/
|
*/
|
||||||
public Gal16v8CuplExporter(String username, Date date) {
|
public CuplExporter(String username, Date date) {
|
||||||
this(username, date, "g16v8a", new PinMap()
|
this(username, date, "g16v8a", new PinMap()
|
||||||
.setAvailInputs(2, 3, 4, 5, 6, 7, 8, 9)
|
.setAvailInputs(2, 3, 4, 5, 6, 7, 8, 9)
|
||||||
.setAvailOutputs(12, 13, 14, 15, 16, 17, 18, 19));
|
.setAvailOutputs(12, 13, 14, 15, 16, 17, 18, 19));
|
||||||
@ -69,12 +71,12 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
*
|
*
|
||||||
* @param username
|
* @param username user name
|
||||||
* @param date
|
* @param date creation date
|
||||||
* @param devName
|
* @param devName device name
|
||||||
* @param pinMap
|
* @param pinMap the pin map to use
|
||||||
*/
|
*/
|
||||||
protected Gal16v8CuplExporter(String username, Date date, String devName, PinMap pinMap) {
|
protected CuplExporter(String username, Date date, String devName, PinMap pinMap) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.devName = devName;
|
this.devName = devName;
|
||||||
@ -88,11 +90,21 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
* @param projectName the project name
|
* @param projectName the project name
|
||||||
* @return this for call chaining
|
* @return this for call chaining
|
||||||
*/
|
*/
|
||||||
public Gal16v8CuplExporter setProjectName(String projectName) {
|
public CuplExporter setProjectName(String projectName) {
|
||||||
this.projectName = projectName;
|
this.projectName = projectName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the create nodes flag.
|
||||||
|
* If "create nodes" is enabled the CUPL file contains buried as NODE not as PIN assignment.
|
||||||
|
*
|
||||||
|
* @param createNodes true if the exporter should create nodes.
|
||||||
|
*/
|
||||||
|
public void setCreateNodes(boolean createNodes) {
|
||||||
|
this.createNodes = createNodes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuilderCollector getBuilder() {
|
public BuilderCollector getBuilder() {
|
||||||
return builder;
|
return builder;
|
||||||
@ -136,34 +148,35 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
out.append("\r\n/* outputs */\r\n");
|
out.append("\r\n/* outputs */\r\n");
|
||||||
|
|
||||||
for (String var : builder.getOutputs()) {
|
for (String var : builder.getOutputs()) {
|
||||||
|
if (createNodes) {
|
||||||
int p = pinMap.isAssigned(var);
|
int p = pinMap.isAssigned(var);
|
||||||
if (p >= 0)
|
if (p >= 0)
|
||||||
out.append("PIN ").append(Integer.toString(p)).append(" = ").append(var).append(";\r\n");
|
out.append("PIN ").append(Integer.toString(p)).append(" = ").append(var).append(";\r\n");
|
||||||
else
|
else
|
||||||
out.append("NODE ").append(var).append(";\r\n");
|
out.append("NODE ").append(var).append(";\r\n");
|
||||||
|
} else {
|
||||||
|
out.append("PIN ").append(Integer.toString(pinMap.getOutputFor(var))).append(" = ").append(var).append(";\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!builder.getRegistered().isEmpty()) {
|
if (!builder.getRegistered().isEmpty()) {
|
||||||
out.append("\r\n/* sequential logic */\r\n");
|
out.append("\r\n/* sequential logic */\r\n");
|
||||||
for (Map.Entry<String, Expression> c : builder.getRegistered().entrySet()) {
|
for (Map.Entry<String, Expression> c : builder.getRegistered().entrySet()) {
|
||||||
out
|
out.append(c.getKey()).append(".D = ");
|
||||||
.append(c.getKey())
|
breakLines(out, FormatToExpression.FORMATTER_CUPL.format(c.getValue()));
|
||||||
.append(".D = ")
|
out.append(";\r\n");
|
||||||
.append(FormatToExpression.FORMATTER_CUPL.format(c.getValue()))
|
|
||||||
.append(";\r\n");
|
|
||||||
sequentialWritten(out, c.getKey());
|
sequentialWritten(out, c.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!builder.getCombinatorial().isEmpty()) {
|
if (!builder.getCombinatorial().isEmpty()) {
|
||||||
out.append("\r\n/* combinatorial logic */\r\n");
|
out.append("\r\n/* combinatorial logic */\r\n");
|
||||||
for (Map.Entry<String, Expression> c : builder.getCombinatorial().entrySet())
|
for (Map.Entry<String, Expression> c : builder.getCombinatorial().entrySet()) {
|
||||||
out
|
out.append(c.getKey()).append(" = ");
|
||||||
.append(c.getKey()).append(" = ")
|
breakLines(out, FormatToExpression.FORMATTER_CUPL.format(c.getValue()));
|
||||||
.append(FormatToExpression.FORMATTER_CUPL.format(c.getValue()))
|
out.append(";\r\n");
|
||||||
.append(";\r\n");
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (FormatterException e) {
|
} catch (FormatterException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
@ -172,6 +185,19 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void breakLines(Writer out, String expression) throws IOException {
|
||||||
|
int pos = 0;
|
||||||
|
for (int i = 0; i < expression.length(); i++) {
|
||||||
|
char c = expression.charAt(i);
|
||||||
|
if (pos > 80 && c == '#') {
|
||||||
|
out.append("\r\n ");
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
out.append(c);
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(OutputStream out) throws FuseMapFillerException, IOException, PinMapException {
|
public void writeTo(OutputStream out) throws FuseMapFillerException, IOException, PinMapException {
|
||||||
writeTo(new OutputStreamWriter(out, "ISO-8859-1"));
|
writeTo(new OutputStreamWriter(out, "ISO-8859-1"));
|
@ -1,6 +1,6 @@
|
|||||||
package de.neemann.digital.builder.Gal22v10;
|
package de.neemann.digital.builder.Gal22v10;
|
||||||
|
|
||||||
import de.neemann.digital.builder.Gal16v8.Gal16v8CuplExporter;
|
import de.neemann.digital.builder.Gal16v8.CuplExporter;
|
||||||
import de.neemann.digital.builder.PinMap;
|
import de.neemann.digital.builder.PinMap;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -12,7 +12,7 @@ import java.util.Date;
|
|||||||
*
|
*
|
||||||
* @author hneemann
|
* @author hneemann
|
||||||
*/
|
*/
|
||||||
public class Gal22v10CuplExporter extends Gal16v8CuplExporter {
|
public class Gal22v10CuplExporter extends CuplExporter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new project name
|
* Creates a new project name
|
||||||
|
@ -15,7 +15,7 @@ import de.neemann.digital.analyse.format.TruthTableFormatterLaTeX;
|
|||||||
import de.neemann.digital.analyse.quinemc.BoolTableByteArray;
|
import de.neemann.digital.analyse.quinemc.BoolTableByteArray;
|
||||||
import de.neemann.digital.builder.ATF1502.*;
|
import de.neemann.digital.builder.ATF1502.*;
|
||||||
import de.neemann.digital.builder.*;
|
import de.neemann.digital.builder.*;
|
||||||
import de.neemann.digital.builder.Gal16v8.Gal16v8CuplExporter;
|
import de.neemann.digital.builder.Gal16v8.CuplExporter;
|
||||||
import de.neemann.digital.builder.Gal16v8.Gal16v8JEDECExporter;
|
import de.neemann.digital.builder.Gal16v8.Gal16v8JEDECExporter;
|
||||||
import de.neemann.digital.builder.Gal22v10.Gal22v10CuplExporter;
|
import de.neemann.digital.builder.Gal22v10.Gal22v10CuplExporter;
|
||||||
import de.neemann.digital.builder.Gal22v10.Gal22v10JEDECExporter;
|
import de.neemann.digital.builder.Gal22v10.Gal22v10JEDECExporter;
|
||||||
@ -396,7 +396,7 @@ public class TableDialog extends JDialog {
|
|||||||
gal16v8.add(new ToolTipAction(Lang.get("menu_table_createCUPL")) {
|
gal16v8.add(new ToolTipAction(Lang.get("menu_table_createCUPL")) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
createCUPL(new Gal16v8CuplExporter());
|
createCUPL(new CuplExporter());
|
||||||
}
|
}
|
||||||
}.setToolTip(Lang.get("menu_table_createCUPL_tt")).createJMenuItem());
|
}.setToolTip(Lang.get("menu_table_createCUPL_tt")).createJMenuItem());
|
||||||
gal16v8.add(new ToolTipAction(Lang.get("menu_table_create_jedec")) {
|
gal16v8.add(new ToolTipAction(Lang.get("menu_table_create_jedec")) {
|
||||||
@ -505,7 +505,7 @@ public class TableDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCUPL(Gal16v8CuplExporter cupl) {
|
private void createCUPL(CuplExporter cupl) {
|
||||||
try {
|
try {
|
||||||
File cuplPath;
|
File cuplPath;
|
||||||
if (filename == null) {
|
if (filename == null) {
|
||||||
@ -534,7 +534,7 @@ public class TableDialog extends JDialog {
|
|||||||
throw new IOException(Lang.get("err_couldNotCreateFolder_N0", cuplPath.getPath()));
|
throw new IOException(Lang.get("err_couldNotCreateFolder_N0", cuplPath.getPath()));
|
||||||
|
|
||||||
File f = new File(cuplPath, "CUPL.PLD");
|
File f = new File(cuplPath, "CUPL.PLD");
|
||||||
cupl.setProjectName(f.getName());
|
cupl.setProjectName(filename.getName());
|
||||||
cupl.getPinMapping().addAll(pinMap);
|
cupl.getPinMapping().addAll(pinMap);
|
||||||
new BuilderExpressionCreator(cupl.getBuilder(), ExpressionModifier.IDENTITY).create(lastGeneratedExpressions);
|
new BuilderExpressionCreator(cupl.getBuilder(), ExpressionModifier.IDENTITY).create(lastGeneratedExpressions);
|
||||||
try (FileOutputStream out = new FileOutputStream(f)) {
|
try (FileOutputStream out = new FileOutputStream(f)) {
|
||||||
|
@ -24,7 +24,7 @@ public class Gal16V8CuplExporterTest extends TestCase {
|
|||||||
Expression y0s = not(y0);
|
Expression y0s = not(y0);
|
||||||
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
|
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
|
||||||
|
|
||||||
Gal16v8CuplExporter ce = new Gal16v8CuplExporter("user", new Date(0))
|
CuplExporter ce = new CuplExporter("user", new Date(0))
|
||||||
.setProjectName("test");
|
.setProjectName("test");
|
||||||
ce.getPinMapping().parseString("Y_0=12;Y_1=13;A=14");
|
ce.getPinMapping().parseString("Y_0=12;Y_1=13;A=14");
|
||||||
ce.getBuilder()
|
ce.getBuilder()
|
||||||
@ -67,12 +67,12 @@ public class Gal16V8CuplExporterTest extends TestCase {
|
|||||||
Expression y0s = not(y0);
|
Expression y0s = not(y0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new Gal16v8CuplExporter("user", new Date(0))
|
new CuplExporter("user", new Date(0))
|
||||||
.setProjectName("test")
|
.setProjectName("test")
|
||||||
.getBuilder()
|
.getBuilder()
|
||||||
.addSequential("Y_0", y0s);
|
.addSequential("Y_0", y0s);
|
||||||
|
|
||||||
assertTrue(false);
|
fail();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
@ -84,12 +84,12 @@ public class Gal16V8CuplExporterTest extends TestCase {
|
|||||||
Expression y0s = not(y0);
|
Expression y0s = not(y0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new Gal16v8CuplExporter("user", new Date(0))
|
new CuplExporter("user", new Date(0))
|
||||||
.setProjectName("test")
|
.setProjectName("test")
|
||||||
.getBuilder()
|
.getBuilder()
|
||||||
.addCombinatorial("D", y0s);
|
.addCombinatorial("D", y0s);
|
||||||
|
|
||||||
assertTrue(false);
|
fail();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user