use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderSequentialJK_JequalsK.
public void testBuilderSequentialJK_JequalsK() throws Exception {
Variable y0 = new Variable("Y_0");
Variable y1 = new Variable("Y_1");
// counter
Expression y0s = not(y0);
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library), true).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0);
te.checkC(1, 0);
te.checkC(0, 1);
te.checkC(1, 1);
te.checkC(0, 0);
}
use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.
the class FuseMapFillerTest method testFillExpression.
public void testFillExpression() throws Exception {
FuseMap fuseMap = new FuseMap(16);
Variable a = new Variable("A");
Variable b = new Variable("B");
Variable c = new Variable("C");
Variable d = new Variable("D");
Expression e = or(and(a, b, c, d), and(not(a), not(b), not(c), not(d)));
new FuseMapFiller(fuseMap, 4).addVariable(0, a).addVariable(1, b).addVariable(2, c).addVariable(3, d).fillExpression(0, e, 2);
byte[] data = fuseMap.getFuseData();
assertEquals(0xAA, data[0] & 0xff);
assertEquals(0x55, data[1] & 0xff);
}
use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.
the class KarnaughMapTest method testBUG_1.
// in 4x4 map a 8 cell block is drawn in wrong orientation
public void testBUG_1() throws IOException, ParseException, KarnaughException {
Expression exp = new Variable("D");
KarnaughMap c = new KarnaughMap(Variable.vars(4), exp);
assertEquals(1, c.size());
KarnaughMap.Cover co = c.iterator().next();
assertTrue(co.isDisconnected());
assertFalse(co.onlyEdges());
assertTrue(co.isVerticalDivided());
exp = new Variable("B");
c = new KarnaughMap(Variable.vars(4), exp);
assertEquals(1, c.size());
co = c.iterator().next();
assertTrue(co.isDisconnected());
assertFalse(co.onlyEdges());
assertFalse(co.isVerticalDivided());
}
use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.
the class BuilderExpressionCreatorTest method testSimple.
public void testSimple() throws FormatterException, ExpressionException, ElementNotFoundException, PinException, NodeException, AnalyseException, BacktrackException {
Variable a = v("A");
Variable b = v("B");
Expression xor = or(and(a, not(b)), and(not(a), b));
ExpressionListenerStore els = new ExpressionListenerStore(null);
els.resultFound("xor", xor);
els.close();
Model m = create(els, ExpressionModifier.IDENTITY);
assertEquals(5, m.size());
assertEquals(2, m.findNode(And.class).size());
assertEquals(1, m.findNode(Or.class).size());
assertEquals(2, m.findNode(Not.class).size());
check(m);
m = create(els, new de.neemann.digital.analyse.expression.modify.NAnd());
assertEquals(5, m.size());
assertEquals(2, m.findNode(Not.class).size());
assertEquals(3, m.findNode(NAnd.class).size());
check(m);
m = create(els, new de.neemann.digital.analyse.expression.modify.NOr());
assertEquals(6, m.size());
assertEquals(3, m.findNode(Not.class).size());
assertEquals(3, m.findNode(NOr.class).size());
check(m);
}
use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.
the class BoolTableExpandedTest method check.
private void check(BoolTableByteArray e, ArrayList<Signal> in1, ArrayList<Signal> in2, List<Variable> vars) {
BoolTableExpanded bt = new BoolTableExpanded(e, in1, in2);
TableReducer tr = new TableReducer(vars, bt);
assertTrue(tr.canReduceOnlyCheckTable());
List<Variable> v = tr.getVars();
assertEquals(in1.size(), v.size());
for (int i = 0; i < v.size(); i++) assertEquals(in1.get(i).getName(), v.get(i).getIdentifier());
BoolTable t1 = tr.getTable();
assertEquals(e.size(), t1.size());
for (int r = 0; r < e.size(); r++) assertEquals(e.get(r), t1.get(r));
}
Aggregations