fixed a bug which makes it impossible to edit the LUT data if the LUT has two inputs.

This commit is contained in:
hneemann 2017-03-06 20:10:23 +01:00
parent 2b02cdcc58
commit f72e5dac4b
3 changed files with 21 additions and 8 deletions

View File

@ -132,8 +132,8 @@ public class Key<VALUE> {
static final class KeyBits extends KeyInteger { static final class KeyBits extends KeyInteger {
private static final Integer[] VALUES = new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32}; private static final Integer[] VALUES = new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32};
KeyBits(String key) { KeyBits(String key, Integer def) {
super(key, 1); super(key, def);
setMin(1); setMin(1);
setMax(64); setMax(64);
setComboBoxValues(VALUES); setComboBoxValues(VALUES);

View File

@ -22,20 +22,22 @@ public final class Keys {
* number of bits in simple gates like And and Or * number of bits in simple gates like And and Or
*/ */
public static final Key.KeyBits BITS public static final Key.KeyBits BITS
= new Key.KeyBits("Bits"); = new Key.KeyBits("Bits", 1);
/** /**
* number of inputs in simple gates like And and Or * number of inputs in simple gates like And and Or
*/ */
public static final Key.KeyInteger INPUT_COUNT public static final Key.KeyInteger INPUT_COUNT // // needs to have the same default value as ADDR_BITS!!! see de.neemann.digital.gui.components.EditorFactory#DataFieldEditor
= new Key.KeyInteger("Inputs", 2) = new Key.KeyInteger("Inputs", 2)
.setComboBoxValues(new Integer[]{2, 3, 4, 5}) .setComboBoxValues(new Integer[]{2, 3, 4, 5})
.setMin(2); .setMin(2);
/** /**
* The elements label * The elements label
*/ */
public static final Key<String> LABEL public static final Key<String> LABEL
= new Key<>("Label", ""); = new Key<>("Label", "");
/** /**
* The size of a LED * The size of a LED
*/ */
@ -43,6 +45,7 @@ public final class Keys {
= new Key.KeyInteger("Size", 1) = new Key.KeyInteger("Size", 1)
.setComboBoxValues(new Integer[]{1, 2, 3, 4, 5}) .setComboBoxValues(new Integer[]{1, 2, 3, 4, 5})
.setMin(1); .setMin(1);
/** /**
* The value of constants * The value of constants
*/ */
@ -86,16 +89,18 @@ public final class Keys {
= new Key.KeyInteger("Frequency", 1) = new Key.KeyInteger("Frequency", 1)
.setComboBoxValues(new Integer[]{1, 2, 5, 10, 20, 50, 100, 200, 500, 5000, 50000, 500000}) .setComboBoxValues(new Integer[]{1, 2, 5, 10, 20, 50, 100, 200, 500, 5000, 50000, 500000})
.setMin(1); .setMin(1);
/** /**
* the bit count of a muxer or decoder * the bit count of a muxer or decoder
*/ */
public static final Key.KeyBits SELECTOR_BITS public static final Key.KeyBits SELECTOR_BITS
= new Key.KeyBits("Selector Bits"); = new Key.KeyBits("Selector Bits", 1);
/** /**
* number of address bits of memory * number of address bits of memory
*/ */
public static final Key.KeyBits ADDR_BITS public static final Key.KeyBits ADDR_BITS
= new Key.KeyBits("Addr Bits"); = new Key.KeyBits("Addr Bits", 2); // needs to have the same default value as INPUT_COUNT!!! see de.neemann.digital.gui.components.EditorFactory#DataFieldEditor
/** /**
* indicates a diode as blown fuse or as programmed * indicates a diode as blown fuse or as programmed
@ -120,11 +125,13 @@ public final class Keys {
*/ */
public static final Key<DataField> DATA public static final Key<DataField> DATA
= new Key<>("Data", DataField.DEFAULT); = new Key<>("Data", DataField.DEFAULT);
/** /**
* flag for flipping selector pos in muxers, decoders and drivers * flag for flipping selector pos in muxers, decoders and drivers
*/ */
public static final Key<Boolean> FLIP_SEL_POSITON public static final Key<Boolean> FLIP_SEL_POSITON
= new Key<>("flipSelPos", false); = new Key<>("flipSelPos", false);
/** /**
* the rotation of the elements * the rotation of the elements
*/ */
@ -158,6 +165,7 @@ public final class Keys {
public static final Key.KeyInteger CYCLES public static final Key.KeyInteger CYCLES
= new Key.KeyInteger("Cycles", 100000) = new Key.KeyInteger("Cycles", 100000)
.setComboBoxValues(new Integer[]{1000, 10000, 100000, 1000000}); .setComboBoxValues(new Integer[]{1000, 10000, 100000, 1000000});
/** /**
* flag to make a value a probe * flag to make a value a probe
*/ */
@ -181,6 +189,7 @@ public final class Keys {
*/ */
public static final Key<Boolean> SHOW_DATA_TABLE public static final Key<Boolean> SHOW_DATA_TABLE
= new Key<>("showDataTable", false); = new Key<>("showDataTable", false);
/** /**
* flag to show the data graph window * flag to show the data graph window
*/ */
@ -205,6 +214,7 @@ public final class Keys {
public static final Key.KeyInteger MAX_STEP_COUNT public static final Key.KeyInteger MAX_STEP_COUNT
= new Key.KeyInteger("maxStepCount", 25) = new Key.KeyInteger("maxStepCount", 25)
.setMin(5); .setMin(5);
/** /**
* flag to enable high z mode at an input * flag to enable high z mode at an input
*/ */
@ -240,20 +250,19 @@ public final class Keys {
*/ */
public static final Key<Language> SETTINGS_LANGUAGE public static final Key<Language> SETTINGS_LANGUAGE
= new Key<>("Language", new Language()); = new Key<>("Language", new Language());
/** /**
* The GUI expression string representation * The GUI expression string representation
*/ */
public static final Key<FormatToExpression> SETTINGS_EXPRESSION_FORMAT public static final Key<FormatToExpression> SETTINGS_EXPRESSION_FORMAT
= new Key<>("ExpressionFormat", FormatToExpression.FORMATTER_UNICODE); = new Key<>("ExpressionFormat", FormatToExpression.FORMATTER_UNICODE);
/** /**
* output format for numbers * output format for numbers
*/ */
public static final Key.KeyEnum<IntFormat> INTFORMAT public static final Key.KeyEnum<IntFormat> INTFORMAT
= new Key.KeyEnum<>("intFormat", IntFormat.def, IntFormat.values()); = new Key.KeyEnum<>("intFormat", IntFormat.def, IntFormat.values());
/** /**
* width of the terminal * width of the terminal
*/ */

View File

@ -267,6 +267,10 @@ public final class EditorFactory {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int bits = attr.get(Keys.BITS); int bits = attr.get(Keys.BITS);
int size; int size;
// INPUT_COUNT and ADDR_BITS must have the same input value!!!
// If INPUT_COUNT is not present (default value is used) the default value of
// ADDR_BITS is used. This works only if both have the same default value!!!
if (attr.contains(Keys.INPUT_COUNT)) { if (attr.contains(Keys.INPUT_COUNT)) {
// used to handle the LUT // used to handle the LUT
size = 1 << attr.get(Keys.INPUT_COUNT); size = 1 << attr.get(Keys.INPUT_COUNT);