Skip to content

Commit

Permalink
TTL 7447, LT, BI, RBI inputs for display decoder, compatible with jav…
Browse files Browse the repository at this point in the history
…a 1.5+
  • Loading branch information
LogisimIt committed Sep 29, 2017
1 parent 16406e5 commit 7e87458
Show file tree
Hide file tree
Showing 18 changed files with 381 additions and 236 deletions.
1 change: 1 addition & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
eclipse.preferences.version=1
encoding//Logisim-Fork/com/cburch/logisim/std/plexers/DisplayDecoder.java=UTF-8
encoding//Logisim-Fork/doc/pt/html/libs/io/digitaloscilloscope.html=UTF-8
encoding//Logisim-Fork/doc/ru/html/libs/index.html=UTF-8
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
Expand All @@ -18,6 +27,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
Expand Down Expand Up @@ -98,3 +108,4 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5
Binary file modified Compiled/Logisim-Fork.exe
Binary file not shown.
Binary file modified Compiled/Logisim-Fork.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion Logisim-Fork/com/cburch/logisim/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.cburch.logisim.gui.start.Startup;

public class Main {
public static final LogisimVersion VERSION = LogisimVersion.get(2, 9, 5, 0, "jar");
public static final LogisimVersion VERSION = LogisimVersion.get(2, 9, 6, 0, "jar");

public static final String VERSION_NAME = VERSION.toString();

Expand Down
419 changes: 237 additions & 182 deletions Logisim-Fork/com/cburch/logisim/std/plexers/DisplayDecoder.java

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Logisim-Fork/com/cburch/logisim/std/ttl/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
/Ttl7402.class
/Ttl7400.class
/Drawgates.class
/Ttl7447.class
114 changes: 68 additions & 46 deletions Logisim-Fork/com/cburch/logisim/std/ttl/AbstractTtlGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

public abstract class AbstractTtlGate extends InstanceFactory {

protected static final int pinwidth = 10, pinheight = 7, height = 60, width = 140;
protected static final int pinwidth = 10, pinheight = 7, height = 60;
private String name;
protected int pinnumber;

protected AbstractTtlGate(String name) {
super(name);
Expand All @@ -31,6 +32,10 @@ protected AbstractTtlGate(String name) {
new Object[] { Direction.EAST, false, false, "", StdAttr.DEFAULT_LABEL_FONT });
setFacingAttribute(StdAttr.FACING);
this.name = name;
if (this.name == "7447")
this.pinnumber = 16;
else
this.pinnumber = 14;
}

private void computeTextField(Instance instance) {
Expand All @@ -54,7 +59,7 @@ protected void configureNewInstance(Instance instance) {
@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
Direction dir = attrs.getValue(StdAttr.FACING);
return Bounds.create(0, -30, width, height).rotate(Direction.EAST, dir, 0, 0);
return Bounds.create(0, -30, this.pinnumber * 10, height).rotate(Direction.EAST, dir, 0, 0);
}

@Override
Expand All @@ -77,18 +82,18 @@ private void paintBase(InstancePainter painter, boolean drawname) {
int xp = x, yp = y;
int width = bds.getWidth();
int height = bds.getHeight();
for (int i = 0; i < 14; i++) {
if (i < 7) {
for (int i = 0; i < this.pinnumber; i++) {
if (i < this.pinnumber / 2) {
if (dir == Direction.WEST || dir == Direction.EAST)
xp = i * 20 + (10 - pinwidth / 2) + x;
else
yp = i * 20 + (10 - pinwidth / 2) + y;
} else {
if (dir == Direction.WEST || dir == Direction.EAST) {
xp = (i - 7) * 20 + (10 - pinwidth / 2) + x;
xp = (i - this.pinnumber / 2) * 20 + (10 - pinwidth / 2) + x;
yp = height + y - pinheight;
} else {
yp = (i - 7) * 20 + (10 - pinwidth / 2) + y;
yp = (i - this.pinnumber / 2) * 20 + (10 - pinwidth / 2) + y;
xp = width + x - pinheight;
}
}
Expand Down Expand Up @@ -147,8 +152,8 @@ public void paintInstance(InstancePainter painter) {
int xp = x, yp = y;
int width = bds.getWidth();
int height = bds.getHeight();
for (int i = 0; i < 14; i++) {
if (i == 7) {
for (int i = 0; i < this.pinnumber; i++) {
if (i == this.pinnumber / 2) {
xp = x;
yp = y;
g.setColor(Color.DARK_GRAY);
Expand Down Expand Up @@ -179,17 +184,17 @@ else if (dir == Direction.NORTH)
else // east
g.fillArc(xp - 7, yp + height / 2 - 7, 14, 14, 270, 180);
}
if (i < 7) {
if (i < this.pinnumber / 2) {
if (dir == Direction.WEST || dir == Direction.EAST)
xp = i * 20 + (10 - pinwidth / 2) + x;
else
yp = i * 20 + (10 - pinwidth / 2) + y;
} else {
if (dir == Direction.WEST || dir == Direction.EAST) {
xp = (i - 7) * 20 + (10 - pinwidth / 2) + x;
xp = (i - this.pinnumber / 2) * 20 + (10 - pinwidth / 2) + x;
yp = height + y - pinheight;
} else {
yp = (i - 7) * 20 + (10 - pinwidth / 2) + y;
yp = (i - this.pinnumber / 2) * 20 + (10 - pinwidth / 2) + y;
xp = width + x - pinheight;
}
}
Expand Down Expand Up @@ -240,7 +245,6 @@ else if (dir == Direction.NORTH)
private void paintInternalBase(InstancePainter painter) {
Direction dir = painter.getAttributeValue(StdAttr.FACING);
Bounds bds = painter.getBounds();
paintBase(painter, false);
int x = bds.getX();
int y = bds.getY();
int width = bds.getWidth();
Expand All @@ -251,18 +255,24 @@ private void paintInternalBase(InstancePainter painter) {
width = bds.getHeight();
height = bds.getWidth();
}
int c = this.name != "7404" ? 4 : 6;
for (int i = 0; i < c; i++) {
paintInternal(painter, x + (c != 6 ? i % 2 != 0 ? 60 : 0 : i % 3 * 40) + (i < c / 2 ? 0 : 20), y, height,
!(i < c / 2));
if (this.name != "7447") {
paintBase(painter, false);
int c = this.name != "7404" ? 4 : 6;
for (int i = 0; i < c; i++) {
paintInternal(painter, x + (c != 6 ? i % 2 != 0 ? 60 : 0 : i % 3 * 40) + (i < c / 2 ? 0 : 20), y,
height, !(i < c / 2));
}
} else {
paintBase(painter, true);
paintInternal(painter, x, y, height, false);
}
}

@Override
public void propagate(InstanceState state) {
if (state.getAttributeValue(TTL.VCC_GND)
&& (state.getPort(12) != Value.FALSE || state.getPort(13) != Value.TRUE))
for (int i = 0; i < 14; i++)
if (state.getAttributeValue(TTL.VCC_GND) && (state.getPort(this.pinnumber - 2) != Value.FALSE
|| state.getPort(this.pinnumber - 1) != Value.TRUE))
for (int i = 0; i < this.pinnumber; i++)
state.setPort(i, Value.UNKNOWN, 1);
else
ttlpropagate(state);
Expand All @@ -272,66 +282,78 @@ public void propagate(InstanceState state) {

private void updateports(Instance instance) {
Direction dir = instance.getAttributeValue(StdAttr.FACING);
Port[] ps = new Port[instance.getAttributeValue(TTL.VCC_GND) ? 14 : 12];
Port[] ps = new Port[instance.getAttributeValue(TTL.VCC_GND) ? this.pinnumber : this.pinnumber - 2];
int dx = 0, dy = 0, portnumber = 1;
for (int i = 0; i < ps.length; i++) {
if (i < 6 || i == 12) {
if (i == 12)
i = 6;
String Ttl7447portnames[] = { "B", "C", "LT", "BI", "RBI", "D", "A", "e", "d", "c", "b", "a", "g", "f" };
for (int i = 0; i < ps.length; i++) {// GND->12,Vcc->13
if (i < this.pinnumber / 2 - 1 || i == this.pinnumber - 2) {
if (i == this.pinnumber - 2)
i = this.pinnumber / 2 - 1;
if (dir == Direction.EAST) {
dx = i * 20 + 10;
dy = 30;
} else if (dir == Direction.WEST) {
dx = (6 - i) * 20 - 130;
dx = -10 - 20 * i;
dy = -30;
} else if (dir == Direction.NORTH) {
dx = 30;
dy = (5 - i) * 20 - 110;
dy = -10 - 20 * i;
} else {// SOUTH
dx = -30;
dy = i * 20 + 10;
}
if (i == 6)
i = 12;
if (i == this.pinnumber / 2 - 1)
i = this.pinnumber - 2;
else
portnumber = i + 1;
} else if (i > 5) {
if (i == 13)
i = 5;
} else if (i > this.pinnumber / 2 - 2) {
if (i == this.pinnumber - 1)
i = this.pinnumber / 2 - 2;
if (dir == Direction.EAST) {
dx = (i - 5) * 20 + 10;
dx = (i - (this.pinnumber / 2 - 1)) * 20 + 30;
dy = -30;
} else if (dir == Direction.WEST) {
dx = (11 - i) * 20 - 130;
dx = -30 - (i - (this.pinnumber / 2 - 1)) * 20;
dy = 30;
} else if (dir == Direction.NORTH) {
dx = -30;
dy = (10 - i) * 20 - 110;
dy = -30 - (i - (this.pinnumber / 2 - 1)) * 20;
} else {// SOUTH
dx = 30;
dy = (i - 5) * 20 + 10;
dy = (i - (this.pinnumber / 2 - 1)) * 20 + 30;
}
if (i == 5)
i = 13;
if (i == this.pinnumber / 2 - 2)
i = this.pinnumber - 1;
else
portnumber = 13 - (i - 6);
portnumber = this.pinnumber - 1 - (i - (this.pinnumber / 2 - 1));
}
if (i > 11) {
if (i > this.pinnumber - 3) {
ps[i] = new Port(dx, dy, Port.INPUT, 1);
if (i == 12)// GND
ps[i].setToolTip(Strings.getter("GND: 7"));
if (i == this.pinnumber - 2)// GND
ps[i].setToolTip(Strings.getter("GND: " + this.pinnumber / 2));
else// Vcc
ps[i].setToolTip(Strings.getter("Vcc: 14"));
} else if (this.name != "7404") {// 2 inputs 1 output
if ((i + 1) % 3 != 0) {
ps[i].setToolTip(Strings.getter("Vcc: " + this.pinnumber));
} else if (this.name == "7404") {// 1 inputs 1 output
if (i % 2 == 0) {
ps[i] = new Port(dx, dy, Port.INPUT, 1);
ps[i].setToolTip(Strings.getter("multiplexerInTip", ": " + String.valueOf(portnumber)));
} else {
ps[i] = new Port(dx, dy, Port.OUTPUT, 1);
ps[i].setToolTip(Strings.getter("demultiplexerOutTip", ": " + String.valueOf(portnumber)));
}
} else {// 1 input 1 output
if (i % 2 == 0) {
} else if (this.name == "7447") {
if (i < this.pinnumber / 2 - 1) {
ps[i] = new Port(dx, dy, Port.INPUT, 1);
ps[i].setToolTip(Strings.getter("multiplexerInTip",
String.valueOf(portnumber) + ": " + Ttl7447portnames[i]));
} else {
ps[i] = new Port(dx, dy, Port.OUTPUT, 1);
ps[i].setToolTip(Strings.getter("demultiplexerOutTip",
String.valueOf(portnumber) + ": " + Ttl7447portnames[i]));
}

} else {// 2 input 1 output
if ((i + 1) % 3 != 0) {
ps[i] = new Port(dx, dy, Port.INPUT, 1);
ps[i].setToolTip(Strings.getter("multiplexerInTip", ": " + String.valueOf(portnumber)));
} else {
Expand Down
1 change: 1 addition & 0 deletions Logisim-Fork/com/cburch/logisim/std/ttl/TTL.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class TTL extends Library {
new FactoryDescription("7404", Strings.getter("7404: hex inverter"), "ttl.gif", "Ttl7404"),
new FactoryDescription("7408", Strings.getter("7408: quad 2-input AND gate"), "ttl.gif", "Ttl7408"),
new FactoryDescription("7432", Strings.getter("7432: quad 2-input OR gate"), "ttl.gif", "Ttl7432"),
new FactoryDescription("7447", Strings.getter("7447: BCD to 7-segment decoder"), "ttl.gif", "Ttl7447"),
new FactoryDescription("7486", Strings.getter("7486: quad 2-input XOR gate"), "ttl.gif", "Ttl7486"),
new FactoryDescription("747266", Strings.getter("747266: quad 2-input XNOR gate"), "ttl.gif",
"Ttl747266"), };
Expand Down
37 changes: 37 additions & 0 deletions Logisim-Fork/com/cburch/logisim/std/ttl/Ttl7447.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.cburch.logisim.std.ttl;

import java.awt.Graphics;

import com.cburch.logisim.instance.InstancePainter;
import com.cburch.logisim.instance.InstanceState;
import com.cburch.logisim.std.plexers.DisplayDecoder;
import com.cburch.logisim.util.GraphicsUtil;

public class Ttl7447 extends AbstractTtlGate {

public Ttl7447() {
super("7447");
}

@Override
public void paintInternal(InstancePainter painter, int x, int y, int height, boolean up) {
String Ttl7447portnames[] = { "B", "C", "LT", "BI", "RBI", "D", "A", "f", "g", "a", "b", "c", "d", "e" };
Graphics g = painter.getGraphics();
g.drawRect(x + 10, y + AbstractTtlGate.pinheight + 10, super.pinnumber * 10 - 20,
height - 2 * AbstractTtlGate.pinheight - 20);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 7; j++) {
GraphicsUtil.drawCenteredText(g, Ttl7447portnames[j + (i * 7)], x + 10 + j * 20 + i * 20,
y + height - AbstractTtlGate.pinheight - 8 - i * (height - 2 * AbstractTtlGate.pinheight - 12));
}
}

}

@Override
public void ttlpropagate(InstanceState state) {
DisplayDecoder.ComputeDisplayDecoderOutputs(state, DisplayDecoder.getdecval(state, false, 0, 6, 0, 1, 5), 9, 10,
11, 12, 13, 7, 8, 2, 3, 4);
}

}
3 changes: 3 additions & 0 deletions Logisim-Fork/resources/logisim/de/std.properties
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ NegateBufferControl = Negiere Steuereingang
#
VccGndPorts = Fügen Sie Vcc/GND-Pins
ShowInternalStructure = Interne Struktur anzeigen
LampTestInTip = Lamp Test: wenn 0, setzt alle Ausgänge auf 1
BlankingInputInTip = Blanking Input: wenn 0, setzt alle Ausgänge auf 0
RippleBlankingInputInTip = Ripple Blanking Input: wenn es 0 ist und A, B, C, D 0 sind, setzt alle Ausgänge auf 0
#
# std/Memory.java
#
Expand Down
3 changes: 3 additions & 0 deletions Logisim-Fork/resources/logisim/en/std.properties
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ NegateBufferControl = Negate Control Input
#
VccGndPorts = Include Vcc/Gnd pins
ShowInternalStructure = Show Internal Structure
LampTestInTip = Lamp Test: when 0, sets all the outputs to 1
BlankingInputInTip = Blanking Input: when 0, sets all the outputs to 0
RippleBlankingInputInTip = Ripple Blanking Input: when it's 0 and A, B, C, D are 0, sets all the outputs to 0
#
# std/Memory.java
#
Expand Down
3 changes: 3 additions & 0 deletions Logisim-Fork/resources/logisim/es/std.properties
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ controlledInverterComponent = Inversor Controlado
#
VccGndPorts = Incluye pins Vcc/Gnd
ShowInternalStructure = Mostrar estructura interna
LampTestInTip = Lamp Test: cuando 0, fija todas las salidas en 1
BlankingInputInTip = Blanking Input: when 0, cuando 0, fija todas las salidas en 0
RippleBlankingInputInTip = Ripple Blanking Input: cuando es 0 y A, B, C, D son 0, fija todas las salidas a 0
# std/Memory.java
#
memoryLibrary = Memoria
Expand Down
3 changes: 3 additions & 0 deletions Logisim-Fork/resources/logisim/fr/std.properties
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ NegateBufferControl = Inverse Entr
#
VccGndPorts = Inclure les broches Vcc/Gnd
ShowInternalStructure = Afficher la structure interne
LampTestInTip = Lamp Test: lorsque 0, définit toutes les sorties à 1
BlankingInputInTip = Blanking Input: lorsque 0, définit toutes les sorties à 0
RippleBlankingInputInTip = Ripple Blanking Input: quand il est 0 et A, B, C, D sont 0, définit toutes les sorties à 0
#
# std/Memory.java
#
Expand Down
3 changes: 3 additions & 0 deletions Logisim-Fork/resources/logisim/it/std.properties
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ NegateBufferControl = Nega Input Controllo
#
VccGndPorts = Includi pin Vcc/Gnd
ShowInternalStructure = Mostra Struttura Interna
LampTestInTip = Lamp Test: quando è 0, imposta il valore di tutti gli output a 1
BlankingInputInTip = Blanking Input: quando è 0, imposta il valore di tutti gli output a 0
RippleBlankingInputInTip = Ripple Blanking Input: quando è 0 e A, B, C, D sono 0, imposta il valore di tutti gli output a 0
#
# std/Memory.java
#
Expand Down
3 changes: 3 additions & 0 deletions Logisim-Fork/resources/logisim/pt/std.properties
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ NegateBufferControl = Negar Controle
#
VccGndPorts = Inclua pinos Vcc/Gnd
ShowInternalStructure = Mostrar Estrutura Interna
LampTestInTip = Lamp Test: when 0, define todas as saídas para 1
BlankingInputInTip = Blanking Input: when 0, define todas as saídas para 0
RippleBlankingInputInTip = Ripple Blanking Input: quando é 0 e A, B, C, D são 0, define todas as saídas para 0
#
# std/Memory.java
#
Expand Down
Loading

0 comments on commit 7e87458

Please sign in to comment.