Added nodes to CUPL and TT2 export to allow a better fitting.

This commit is contained in:
hneemann 2017-03-13 19:59:18 +01:00
parent 22b5e497f5
commit c459bc6bf5
7 changed files with 52 additions and 20 deletions

View File

@ -121,22 +121,27 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
.append("Company unknown ;\r\n")
.append("Assembly None ;\r\n")
.append("Location unknown ;\r\n")
.append("Device " + devName + " ;\r\n");
.append("Device ").append(devName).append(" ;\r\n");
headerWritten(out);
out.append("\r\n/* inputs */\r\n");
if (!builder.getRegistered().isEmpty())
out.append("PIN " + clockPin + " = CLK;\r\n");
out.append("PIN ").append(String.valueOf(clockPin)).append(" = CLK;\r\n");
for (String in : builder.getInputs())
out.append("PIN ").append(Integer.toString(pinMap.getInputFor(in))).append(" = ").append(in).append(";\r\n");
out.append("\r\n/* outputs */\r\n");
for (String var : builder.getOutputs())
out.append("PIN ").append(Integer.toString(pinMap.getOutputFor(var))).append(" = ").append(var).append(";\r\n");
for (String var : builder.getOutputs()) {
int p = pinMap.isAssigned(var);
if (p >= 0)
out.append("PIN ").append(Integer.toString(p)).append(" = ").append(var).append(";\r\n");
else
out.append("NODE ").append(var).append(";\r\n");
}
try {
if (!builder.getRegistered().isEmpty()) {

View File

@ -227,6 +227,18 @@ public class PinMap {
return getPinFor(in, PinDescription.Direction.input);
}
/**
* gets the assigned pin.
*
* @param in the pins name
* @return the pin number or -1 if not assigned
*/
public int isAssigned(String in) {
Integer p = searchPinWithAlias(in);
if (p == null) return -1;
else return p;
}
private int getPinFor(String in, PinDescription.Direction direction) throws PinMapException {
Integer p = searchPinWithAlias(in);
if (p == null)

View File

@ -106,7 +106,8 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
line("#$ MODULE " + projectName);
line("#$ JEDECFILE " + projectName);
line("#$ DEVICE " + device);
line("#$ PINS " + getPins());
assignPinsAndNodes();
//line("#$ PINS " + getPins());
line(".i " + inputs.size());
line(".o " + outputs.size());
line(".type f");
@ -249,30 +250,38 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
return sb.toString();
}
private String getPins() throws PinMapException {
StringBuilder sb = new StringBuilder();
int numPins = builder.getInputs().size() + builder.getOutputs().size();
if (!builder.getRegistered().isEmpty())
numPins++;
sb.append(numPins);
private void assignPinsAndNodes() throws IOException, PinMapException {
int pinNum = 0;
StringBuilder pin = new StringBuilder();
int nodeNum = 0;
StringBuilder node = new StringBuilder();
for (String i : builder.getInputs()) {
int p = pinMap.getInputFor(i);
sb.append(" ").append(i).append("+:").append(p);
pin.append(" ").append(i).append("+:").append(p);
pinNum++;
}
if (!builder.getRegistered().isEmpty())
sb.append(" CLK+:").append(clockPin);
if (!builder.getRegistered().isEmpty()) {
pin.append(" CLK+:").append(clockPin);
pinNum++;
}
for (String o : builder.getOutputs()) {
int p = pinMap.getInputFor(o);
sb.append(" ").append(o).append("+:").append(p);
int p = pinMap.isAssigned(o);
if (p >= 0) {
pin.append(" ").append(o).append("+:").append(p);
pinNum++;
} else {
node.append(" ").append(o);
nodeNum++;
}
}
return sb.toString();
if (pinNum > 0)
line("#$ PINS " + pinNum + pin.toString());
if (nodeNum > 0)
line("#$ NODES " + nodeNum + node.toString());
}
private static class StateSet implements Comparable<StateSet> {

View File

@ -25,6 +25,7 @@ public class ATF1502CuplExporterTest extends TestCase {
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
ATF1502CuplExporter ce = new ATF1502CuplExporter("user", new Date(0), "f1502ispplcc44");
ce.getPinMapping().parseString("Y_0=4;Y_1=5;A=6");
ce.setProjectName("test");
ce.getBuilder()
.addSequential("Y_0", y0s)

View File

@ -26,6 +26,7 @@ public class Gal16V8CuplExporterTest extends TestCase {
Gal16v8CuplExporter ce = new Gal16v8CuplExporter("user", new Date(0))
.setProjectName("test");
ce.getPinMapping().parseString("Y_0=12;Y_1=13;A=14");
ce.getBuilder()
.addSequential("Y_0", y0s)
.addSequential("Y_1", y1s)

View File

@ -25,6 +25,7 @@ public class Gal22V10CuplExporterTest extends TestCase {
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
Gal22v10CuplExporter ce = new Gal22v10CuplExporter("user", new Date(0));
ce.getPinMapping().parseString("Y_0=14;Y_1=15;A=16");
ce.setProjectName("test");
ce.getBuilder()
.addSequential("Y_0", y0s)

View File

@ -19,6 +19,7 @@ public class TT2ExporterTest extends TestCase {
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
tt2.getBuilder().addCombinatorial("Y", and(v("A"), v("B")));
tt2.getBuilder().addCombinatorial("X", or(v("A1"), v("B1")));
tt2.getPinMapping().parseString("X=21;Y=20");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tt2.writeTo(baos);
@ -46,6 +47,7 @@ public class TT2ExporterTest extends TestCase {
TT2Exporter tt2 = new TT2Exporter();
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
tt2.getBuilder().addSequential("Yn", and(v("A"), not(v("Yn"))));
tt2.getPinMapping().parseString("Yn=5");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tt2.writeTo(baos);
@ -74,6 +76,7 @@ public class TT2ExporterTest extends TestCase {
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
tt2.getBuilder().addSequential("Yn", and(v("A"), not(v("Yn"))));
tt2.getBuilder().addSequential("Xn", or(v("B"), not(v("Xn"))));
tt2.getPinMapping().parseString("Xn=8;Yn=6");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tt2.writeTo(baos);