use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class RegisterFileTest method testRegisterFile.
public void testRegisterFile() throws Exception {
ObservableValue ra = new ObservableValue("ra", 2);
ObservableValue rb = new ObservableValue("rb", 2);
ObservableValue rw = new ObservableValue("rw", 2);
ObservableValue in = new ObservableValue("in", 4);
ObservableValue we = new ObservableValue("we", 1);
ObservableValue clk = new ObservableValue("clk", 1);
Model model = new Model();
RegisterFile out = model.add(new RegisterFile(new ElementAttributes().set(Keys.ADDR_BITS, 2).setBits(4)));
out.setInputs(ovs(in, we, rw, clk, ra, rb));
TestExecuter sc = new TestExecuter(model).setInputs(clk, in, we, rw, ra, rb).setOutputs(out.getOutputs());
// c in we rw ra rb da db
sc.check(0, 0, 0, 0, 0, 0, 0, 0);
sc.check(1, 7, 1, 1, 0, 0, 0, 0);
sc.check(0, 0, 0, 0, 1, 1, 7, 7);
sc.check(1, 5, 1, 2, 1, 1, 7, 7);
sc.check(0, 0, 0, 0, 1, 2, 7, 5);
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class BitSelectorTest method testBitSel.
public void testBitSel() throws Exception {
Model model = new Model();
ObservableValue d = new ObservableValue("d", 4);
ObservableValue sel = new ObservableValue("sel", 2);
BitSelector out = model.add(new BitSelector(new ElementAttributes().set(Keys.SELECTOR_BITS, 2)));
out.setInputs(ovs(d, sel));
TestExecuter te = new TestExecuter(model).setInputs(d, sel).setOutputs(out.getOutputs());
te.check(5, 0, 1);
te.check(5, 1, 0);
te.check(5, 2, 1);
te.check(5, 3, 0);
te.check(10, 0, 0);
te.check(10, 1, 1);
te.check(10, 2, 0);
te.check(10, 3, 1);
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class EditorFactoryTest method testKeyConstrains.
public void testKeyConstrains() {
ElementAttributes attr = new ElementAttributes();
assertEquals(attr.get(Keys.INPUT_COUNT), attr.get(Keys.ADDR_BITS));
// see comments in EditorFactory$DataFieldEditor
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class ModelAnalyser method replaceJKFF.
private void replaceJKFF() throws NodeException, AnalyseException {
List<FlipflopJK> jkList = model.findNode(FlipflopJK.class);
for (FlipflopJK jk : jkList) {
checkClock(jk);
jk.getClockVal().removeObserver(jk);
jk.getjVal().removeObserver(jk);
jk.getkVal().removeObserver(jk);
// create d ff
ObservableValue q = jk.getOutputs().get(0);
ObservableValue qn = jk.getOutputs().get(1);
FlipflopD d = new FlipflopD(jk.getLabel(), q, qn);
And a1 = new And(new ElementAttributes());
a1.setInputs(new ObservableValues(jk.getjVal(), qn));
And a2 = new And(new ElementAttributes());
Not nk = new Not(new ElementAttributes());
nk.setInputs(jk.getkVal().asList());
a2.setInputs(new ObservableValues(nk.getOutput(), q));
Or or = new Or(new ElementAttributes());
or.setInputs(new ObservableValues(a1.getOutput(), a2.getOutput()));
d.setInputs(new ObservableValues(or.getOutputs().get(0), jk.getClockVal()));
model.add(a1);
model.add(a2);
model.add(nk);
model.add(or);
model.replace(jk, d);
}
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class LibraryNode method getToolTipText.
/**
* @return the tool tip text
*/
public String getToolTipText() {
if (isCustom()) {
if (isUnique()) {
if (description == null) {
if (toolTipText == null) {
try {
LOGGER.debug("load tooltip from " + file);
Circuit c = Circuit.loadCircuit(file, null);
toolTipText = new LineBreaker().toHTML().breakLines(c.getAttributes().get(Keys.DESCRIPTION));
} catch (Exception e) {
toolTipText = Lang.get("msg_fileNotImportedYet");
}
}
return toolTipText;
} else
return new LineBreaker().toHTML().breakLines(description.getDescription(new ElementAttributes()));
} else
return Lang.get("msg_fileIsNotUnique");
} else
return new LineBreaker().toHTML().breakLines(Lang.getNull("elem_" + getName() + "_tt"));
}
Aggregations