added a TT2 export

This commit is contained in:
hneemann 2017-03-04 15:01:21 +01:00
parent a8259aba99
commit ebd7df3851
6 changed files with 64 additions and 20 deletions

View File

@ -29,9 +29,9 @@ public class ATF1502CuplExporter extends Gal16v8CuplExporter {
*/
public ATF1502CuplExporter(String username, Date date) {
super(username, date, "f1502plcc44", new PinMap()
.setAvailBidirectional(4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17,
.setAvailBidirectional(4, 5, 6, 8, 9, 11, 12, 14, 16, 17,
18, 19, 20, 21, 24, 25, 26, 27, 28,
29, 31, 32, 33, 34, 36, 37, 38, 39, 40));
29, 31, 33, 34, 36, 37, 38, 39, 40));
setClockPin(43);
}

View File

@ -0,0 +1,33 @@
package de.neemann.digital.builder.ATF1502;
import de.neemann.digital.builder.tt2.TT2Exporter;
/**
* Creates a TT2 file suitable for the ATF1502
*
* @author hneemann
*/
public class ATF1502TT2Exporter extends TT2Exporter {
/**
* Creates a new project name
*/
public ATF1502TT2Exporter() {
this(System.getProperty("user.name"));
}
/**
* Creates a new project name
*
* @param projectName user name
*/
public ATF1502TT2Exporter(String projectName) {
super();
setProjectName(projectName);
getPinMapping().setAvailBidirectional(4, 5, 6, 8, 9, 11, 12, 14, 16, 17,
18, 19, 20, 21, 24, 25, 26, 27, 28,
29, 31, 33, 34, 36, 37, 38, 39, 40);
setClockPin(43);
}
}

View File

@ -17,10 +17,10 @@ import java.util.*;
* Created by hneemann on 03.03.17.
*/
public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
private BuilderCollector builder;
private PinMap pinMap;
private final BuilderCollector builder;
private final PinMap pinMap;
private int clockPin;
private String name;
private String projectName;
private String device;
private OutputStreamWriter writer;
private HashMap<String, Integer> varIndexMap;
@ -36,7 +36,7 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
builder = new BuilderCollector();
pinMap = new PinMap();
device = "f1502plcc44";
name = "unknown";
projectName = "unknown";
clockPin = 43;
}
@ -59,11 +59,11 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
/**
* Sets the project name used
*
* @param name the project name
* @param projectName the project name
* @return this for chained calls
*/
public TT2Exporter setName(String name) {
this.name = name;
public TT2Exporter setProjectName(String projectName) {
this.projectName = projectName;
return this;
}
@ -94,9 +94,9 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
this.writer = writer;
line("#$ TOOL CUPL");
line("# Berkeley PLA format generated using Digital");
line("#$ TITLE " + name);
line("#$ MODULE " + name);
line("#$ JEDECFILE " + name);
line("#$ TITLE " + projectName);
line("#$ MODULE " + projectName);
line("#$ JEDECFILE " + projectName);
line("#$ DEVICE " + device);
line("#$ PINS " + getPins());
line(".i " + inputs.size());
@ -346,7 +346,7 @@ public class TT2Exporter implements ExpressionExporter<TT2Exporter> {
if (var instanceof Variable) {
set(getVarNum(((Variable) var).getIdentifier()), invers ? 0 : 1);
} else
throw new FuseMapFillerException("invalid Expression");
throw new FuseMapFillerException("invalid expression");
}
}

View File

@ -15,6 +15,7 @@ import de.neemann.digital.analyse.expression.modify.TwoInputs;
import de.neemann.digital.analyse.format.TruthTableFormatterLaTeX;
import de.neemann.digital.analyse.quinemc.BoolTableIntArray;
import de.neemann.digital.builder.ATF1502.ATF1502CuplExporter;
import de.neemann.digital.builder.ATF1502.ATF1502TT2Exporter;
import de.neemann.digital.builder.*;
import de.neemann.digital.builder.Gal16v8.Gal16v8CuplExporter;
import de.neemann.digital.builder.Gal16v8.Gal16v8JEDECExporter;
@ -401,7 +402,7 @@ public class TableDialog extends JDialog {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Gal16v8JEDECExporter jedecExporter = new Gal16v8JEDECExporter();
createHardware(jedecExporter, filename);
createHardware(jedecExporter, filename, "jed");
new ShowStringDialog(parent, Lang.get("win_pinMapDialog"), jedecExporter.getPinMapping().toString()).setVisible(true);
}
}.setToolTip(Lang.get("menu_table_create_jedec_tt")).createJMenuItem());
@ -418,7 +419,7 @@ public class TableDialog extends JDialog {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Gal22v10JEDECExporter jedecExporter = new Gal22v10JEDECExporter();
createHardware(jedecExporter, filename);
createHardware(jedecExporter, filename, "jed");
new ShowStringDialog(parent, Lang.get("win_pinMapDialog"), jedecExporter.getPinMapping().toString()).setVisible(true);
}
}.setToolTip(Lang.get("menu_table_create_jedec_tt")).createJMenuItem());
@ -432,6 +433,12 @@ public class TableDialog extends JDialog {
createCUPL(new ATF1502CuplExporter());
}
}.setToolTip(Lang.get("menu_table_createCUPL_tt")).createJMenuItem());
atf1502.add(new ToolTipAction(Lang.get("menu_table_createTT2")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createHardware(new ATF1502TT2Exporter(), filename, "tt2");
}
}.setToolTip(Lang.get("menu_table_createTT2_tt")).createJMenuItem());
hardware.add(atf1502);
@ -440,18 +447,18 @@ public class TableDialog extends JDialog {
return createMenu;
}
private void createHardware(ExpressionExporter expressionExporter, File filename) {
private void createHardware(ExpressionExporter expressionExporter, File filename, String suffix) {
if (filename == null)
filename = new File("circuit.jed");
filename = new File("circuit." + suffix);
else
filename = Main.checkSuffix(filename, "jed");
filename = Main.checkSuffix(filename, suffix);
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileNameExtensionFilter("JEDEC", "jed"));
fileChooser.setFileFilter(new FileNameExtensionFilter("JEDEC", suffix));
fileChooser.setSelectedFile(filename);
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
try {
try (OutputStream out = new FileOutputStream(Main.checkSuffix(fileChooser.getSelectedFile(), "jed"))) {
try (OutputStream out = new FileOutputStream(Main.checkSuffix(fileChooser.getSelectedFile(), suffix))) {
expressionExporter.getPinMapping().addAll(pinMap);
new BuilderExpressionCreator(expressionExporter.getBuilder(), ExpressionModifier.IDENTITY).create();
expressionExporter.writeTo(out);

View File

@ -586,6 +586,8 @@ Zur Analyse können Sie die Schaltung im Gatterschrittmodus ausführen.</string>
<string name="menu_table_create">Erzeugen</string>
<string name="menu_table_createCUPL">CUPL</string>
<string name="menu_table_createCUPL_tt">Erzeugt eine CUPL Quelldatei welche die Schaltung beschreibt.</string>
<string name="menu_table_createTT2">TT2</string>
<string name="menu_table_createTT2_tt">Erzeugt eine dem Berkeley Logic Interchange Format (BLIF) ähnliche Beschreibung der Logik.</string>
<string name="menu_table_createCircuit">Schaltung</string>
<string name="menu_table_createCircuit_tt">Erzeugt eine Schaltung, welche der Wahrheitstabelle entspricht.</string>
<string name="menu_table_createCircuitJK">Schaltung mit JK Flipflops</string>

View File

@ -572,6 +572,8 @@ To analyse you can run the circuit in single gate step mode.</string>
<string name="menu_table_create">Create</string>
<string name="menu_table_createCUPL">CUPL source</string>
<string name="menu_table_createCUPL_tt">Creates a CUPL source file containing the define circuit.</string>
<string name="menu_table_createTT2">TT2</string>
<string name="menu_table_createTT2_tt">Creates a file containing the circuit similar to the Berkeley Logic Interchange Format (BLIF).</string>
<string name="menu_table_createCircuit">Circuit</string>
<string name="menu_table_createCircuit_tt">Creates a circuit which reproduces the truth table.</string>
<string name="menu_table_createCircuitJK">Circuit with JK flip-flops</string>