mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 06:51:37 -04:00
Added nodes to CUPL and TT2 export to allow a better fitting.
This commit is contained in:
parent
22b5e497f5
commit
c459bc6bf5
@ -121,22 +121,27 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
.append("Company unknown ;\r\n")
|
.append("Company unknown ;\r\n")
|
||||||
.append("Assembly None ;\r\n")
|
.append("Assembly None ;\r\n")
|
||||||
.append("Location unknown ;\r\n")
|
.append("Location unknown ;\r\n")
|
||||||
.append("Device " + devName + " ;\r\n");
|
.append("Device ").append(devName).append(" ;\r\n");
|
||||||
|
|
||||||
|
|
||||||
headerWritten(out);
|
headerWritten(out);
|
||||||
|
|
||||||
out.append("\r\n/* inputs */\r\n");
|
out.append("\r\n/* inputs */\r\n");
|
||||||
if (!builder.getRegistered().isEmpty())
|
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())
|
for (String in : builder.getInputs())
|
||||||
out.append("PIN ").append(Integer.toString(pinMap.getInputFor(in))).append(" = ").append(in).append(";\r\n");
|
out.append("PIN ").append(Integer.toString(pinMap.getInputFor(in))).append(" = ").append(in).append(";\r\n");
|
||||||
|
|
||||||
out.append("\r\n/* outputs */\r\n");
|
out.append("\r\n/* outputs */\r\n");
|
||||||
|
|
||||||
for (String var : builder.getOutputs())
|
for (String var : builder.getOutputs()) {
|
||||||
out.append("PIN ").append(Integer.toString(pinMap.getOutputFor(var))).append(" = ").append(var).append(";\r\n");
|
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 {
|
try {
|
||||||
if (!builder.getRegistered().isEmpty()) {
|
if (!builder.getRegistered().isEmpty()) {
|
||||||
|
@ -227,6 +227,18 @@ public class PinMap {
|
|||||||
return getPinFor(in, PinDescription.Direction.input);
|
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 {
|
private int getPinFor(String in, PinDescription.Direction direction) throws PinMapException {
|
||||||
Integer p = searchPinWithAlias(in);
|
Integer p = searchPinWithAlias(in);
|
||||||
if (p == null)
|
if (p == null)
|
||||||
|
@ -106,7 +106,8 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
|
|||||||
line("#$ MODULE " + projectName);
|
line("#$ MODULE " + projectName);
|
||||||
line("#$ JEDECFILE " + projectName);
|
line("#$ JEDECFILE " + projectName);
|
||||||
line("#$ DEVICE " + device);
|
line("#$ DEVICE " + device);
|
||||||
line("#$ PINS " + getPins());
|
assignPinsAndNodes();
|
||||||
|
//line("#$ PINS " + getPins());
|
||||||
line(".i " + inputs.size());
|
line(".i " + inputs.size());
|
||||||
line(".o " + outputs.size());
|
line(".o " + outputs.size());
|
||||||
line(".type f");
|
line(".type f");
|
||||||
@ -249,30 +250,38 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPins() throws PinMapException {
|
private void assignPinsAndNodes() throws IOException, PinMapException {
|
||||||
StringBuilder sb = new StringBuilder();
|
int pinNum = 0;
|
||||||
int numPins = builder.getInputs().size() + builder.getOutputs().size();
|
StringBuilder pin = new StringBuilder();
|
||||||
if (!builder.getRegistered().isEmpty())
|
int nodeNum = 0;
|
||||||
numPins++;
|
StringBuilder node = new StringBuilder();
|
||||||
|
|
||||||
sb.append(numPins);
|
|
||||||
|
|
||||||
|
|
||||||
for (String i : builder.getInputs()) {
|
for (String i : builder.getInputs()) {
|
||||||
int p = pinMap.getInputFor(i);
|
int p = pinMap.getInputFor(i);
|
||||||
sb.append(" ").append(i).append("+:").append(p);
|
pin.append(" ").append(i).append("+:").append(p);
|
||||||
|
pinNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!builder.getRegistered().isEmpty())
|
if (!builder.getRegistered().isEmpty()) {
|
||||||
sb.append(" CLK+:").append(clockPin);
|
pin.append(" CLK+:").append(clockPin);
|
||||||
|
pinNum++;
|
||||||
|
}
|
||||||
|
|
||||||
for (String o : builder.getOutputs()) {
|
for (String o : builder.getOutputs()) {
|
||||||
int p = pinMap.getInputFor(o);
|
int p = pinMap.isAssigned(o);
|
||||||
sb.append(" ").append(o).append("+:").append(p);
|
if (p >= 0) {
|
||||||
|
pin.append(" ").append(o).append("+:").append(p);
|
||||||
|
pinNum++;
|
||||||
|
} else {
|
||||||
|
node.append(" ").append(o);
|
||||||
|
nodeNum++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pinNum > 0)
|
||||||
return sb.toString();
|
line("#$ PINS " + pinNum + pin.toString());
|
||||||
|
if (nodeNum > 0)
|
||||||
|
line("#$ NODES " + nodeNum + node.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StateSet implements Comparable<StateSet> {
|
private static class StateSet implements Comparable<StateSet> {
|
||||||
|
@ -25,6 +25,7 @@ public class ATF1502CuplExporterTest extends TestCase {
|
|||||||
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
|
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
|
||||||
|
|
||||||
ATF1502CuplExporter ce = new ATF1502CuplExporter("user", new Date(0), "f1502ispplcc44");
|
ATF1502CuplExporter ce = new ATF1502CuplExporter("user", new Date(0), "f1502ispplcc44");
|
||||||
|
ce.getPinMapping().parseString("Y_0=4;Y_1=5;A=6");
|
||||||
ce.setProjectName("test");
|
ce.setProjectName("test");
|
||||||
ce.getBuilder()
|
ce.getBuilder()
|
||||||
.addSequential("Y_0", y0s)
|
.addSequential("Y_0", y0s)
|
||||||
|
@ -26,6 +26,7 @@ public class Gal16V8CuplExporterTest extends TestCase {
|
|||||||
|
|
||||||
Gal16v8CuplExporter ce = new Gal16v8CuplExporter("user", new Date(0))
|
Gal16v8CuplExporter ce = new Gal16v8CuplExporter("user", new Date(0))
|
||||||
.setProjectName("test");
|
.setProjectName("test");
|
||||||
|
ce.getPinMapping().parseString("Y_0=12;Y_1=13;A=14");
|
||||||
ce.getBuilder()
|
ce.getBuilder()
|
||||||
.addSequential("Y_0", y0s)
|
.addSequential("Y_0", y0s)
|
||||||
.addSequential("Y_1", y1s)
|
.addSequential("Y_1", y1s)
|
||||||
|
@ -25,6 +25,7 @@ public class Gal22V10CuplExporterTest extends TestCase {
|
|||||||
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
|
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
|
||||||
|
|
||||||
Gal22v10CuplExporter ce = new Gal22v10CuplExporter("user", new Date(0));
|
Gal22v10CuplExporter ce = new Gal22v10CuplExporter("user", new Date(0));
|
||||||
|
ce.getPinMapping().parseString("Y_0=14;Y_1=15;A=16");
|
||||||
ce.setProjectName("test");
|
ce.setProjectName("test");
|
||||||
ce.getBuilder()
|
ce.getBuilder()
|
||||||
.addSequential("Y_0", y0s)
|
.addSequential("Y_0", y0s)
|
||||||
|
@ -19,6 +19,7 @@ public class TT2ExporterTest extends TestCase {
|
|||||||
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
|
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
|
||||||
tt2.getBuilder().addCombinatorial("Y", and(v("A"), v("B")));
|
tt2.getBuilder().addCombinatorial("Y", and(v("A"), v("B")));
|
||||||
tt2.getBuilder().addCombinatorial("X", or(v("A1"), v("B1")));
|
tt2.getBuilder().addCombinatorial("X", or(v("A1"), v("B1")));
|
||||||
|
tt2.getPinMapping().parseString("X=21;Y=20");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
tt2.writeTo(baos);
|
tt2.writeTo(baos);
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ public class TT2ExporterTest extends TestCase {
|
|||||||
TT2Exporter tt2 = new TT2Exporter();
|
TT2Exporter tt2 = new TT2Exporter();
|
||||||
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
|
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
|
||||||
tt2.getBuilder().addSequential("Yn", and(v("A"), not(v("Yn"))));
|
tt2.getBuilder().addSequential("Yn", and(v("A"), not(v("Yn"))));
|
||||||
|
tt2.getPinMapping().parseString("Yn=5");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
tt2.writeTo(baos);
|
tt2.writeTo(baos);
|
||||||
|
|
||||||
@ -74,6 +76,7 @@ public class TT2ExporterTest extends TestCase {
|
|||||||
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
|
tt2.getPinMapping().setAvailBidirectional(4,5,6,8,20,21);
|
||||||
tt2.getBuilder().addSequential("Yn", and(v("A"), not(v("Yn"))));
|
tt2.getBuilder().addSequential("Yn", and(v("A"), not(v("Yn"))));
|
||||||
tt2.getBuilder().addSequential("Xn", or(v("B"), not(v("Xn"))));
|
tt2.getBuilder().addSequential("Xn", or(v("B"), not(v("Xn"))));
|
||||||
|
tt2.getPinMapping().parseString("Xn=8;Yn=6");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
tt2.writeTo(baos);
|
tt2.writeTo(baos);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user