Search in sources :

Example 11 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class Gal16V8CuplExporterTest method testCUPLBuilderInvalidVars2.

public void testCUPLBuilderInvalidVars2() throws Exception {
    // D is not allowed in CUPL
    Variable y0 = new Variable("Y_0");
    Expression y0s = not(y0);
    try {
        new CuplExporter("user", new Date(0)).setProjectName("test").getBuilder().addCombinatorial("D", y0s);
        fail();
    } catch (RuntimeException e) {
        assertTrue(true);
    }
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) Date(java.util.Date)

Example 12 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class Gal22v10JEDECExporterTest method testSequential.

// stepper control; sequential and combinatorial
public void testSequential() throws Exception {
    Variable D = new Variable("D");
    Variable Q0 = new Variable("Q0");
    Variable Q1 = new Variable("Q1");
    Variable Q2 = new Variable("Q2");
    // Q0.d = !Q0;
    Expression Q0d = not(Q0);
    // Q1.d = !D & !Q1 & Q0 # !D & Q1 & !Q0 # D & !Q1 & !Q0 # D & Q1 & Q0;
    Expression Q1d = or(and(not(D), not(Q1), Q0), and(not(D), Q1, not(Q0)), and(D, not(Q1), not(Q0)), and(D, Q1, Q0));
    // Q2.d = !D & !Q2 & Q1 & Q0 #
    // !D & Q2 & !Q1 #
    // Q2 & Q1 & !Q0 #
    // D & !Q2 & !Q1 & !Q0 #
    // D & Q2 & Q0;
    Expression Q2d = or(and(not(D), not(Q2), Q1, Q0), and(not(D), Q2, not(Q1)), and(Q2, Q1, not(Q0)), and(D, not(Q2), not(Q1), not(Q0)), and(D, Q2, Q0));
    // P0 = !Q2 & !Q1 # Q2 & Q1 & Q0;
    Expression P0 = or(and(not(Q2), not(Q1)), and(Q2, Q1, Q0));
    // P1 = !Q2 & Q0 # !Q2 & Q1;
    Expression P1 = or(and(not(Q2), Q0), and(not(Q2), Q1));
    // P2 = !Q2 & Q1 & Q0 # Q2 & !Q1;
    Expression P2 = or(and(not(Q2), Q1, Q0), and(Q2, not(Q1)));
    // P3 = Q2 & Q0 # Q2 & Q1;
    Expression P3 = or(and(Q2, Q0), and(Q2, Q1));
    Gal22v10JEDECExporter gal = new Gal22v10JEDECExporter();
    gal.getBuilder().addSequential("Q0", Q0d).addSequential("Q1", Q1d).addSequential("Q2", Q2d).addCombinatorial("P0", P0).addCombinatorial("P1", P1).addCombinatorial("P2", P2).addCombinatorial("P3", P3);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    gal.writeTo(baos);
    assertEquals("\u0002Digital GAL22v10 assembler*\r\n" + "QF5892*\r\n" + "G0*\r\n" + "F0*\r\n" + // CUPL output
    "L1472 00000000000000000000000011111111*\r\n" + "L1504 11111111111111111111111111111111*\r\n" + "L1536 11111111111111111111111111111111*\r\n" + "L1568 11101111111011111111111111111111*\r\n" + "L1600 11111111111111101110111111110000*\r\n" + "L2144 00000000000011111111111111111111*\r\n" + "L2176 11111111111111111111111111111111*\r\n" + "L2208 11111111111111111111110111101110*\r\n" + "L2240 11111111111111111111111111111111*\r\n" + "L2272 11101101111111110000000000000000*\r\n" + "L2880 00000000000000000000000011111111*\r\n" + "L2912 11111111111111111111111111111111*\r\n" + "L2944 11111111111111111111111111111111*\r\n" + "L2976 11011111111011111111111111111111*\r\n" + "L3008 11111111111111011110111111110000*\r\n" + "L3648 00001111111111111111111111111111*\r\n" + "L3680 11111111111111111111111111111111*\r\n" + "L3712 11111111111111101110111011111111*\r\n" + "L3744 11111111111111111111111111011101*\r\n" + "L3776 11111111000000000000000000000000*\r\n" + "L4288 00000000000000000000000011111111*\r\n" + "L4320 11111111111111111111111111111111*\r\n" + "L4352 11111111101111111111111111111111*\r\n" + "L4384 11011110111011111111101111111111*\r\n" + "L4416 11111111111111101101111111111111*\r\n" + "L4448 01111111111111111111111111011101*\r\n" + "L4480 11011111111101111111111111111111*\r\n" + "L4512 11111110111111101111111111111111*\r\n" + "L4544 11111111111111111110111011011111*\r\n" + "L4864 00000000000000000000111111111111*\r\n" + "L4896 11111111111111111111111111111111*\r\n" + "L4928 11111011111111111111111111111111*\r\n" + "L4960 11011110111111111011111111111111*\r\n" + "L4992 11111111111111101101111111110111*\r\n" + "L5024 11111111111111111111111111011101*\r\n" + "L5056 11111111011111111111111111111111*\r\n" + "L5088 11111110111011110000000000000000*\r\n" + "L5344 00000000000000000000000011111111*\r\n" + "L5376 11111111111111111111111111111111*\r\n" + "L5408 11111111111111111111111111111111*\r\n" + "L5440 11111111110111110000000000000000*\r\n" + "L5792 00000000000000000000001111111110*\r\n" + "L5824 10100000000000000000000000000000*\r\n" + /* CUPL writes some data to the signature
                "L5824 10100011000000110000001000000000*\r\n" +
                */
    "C8241*\r\n" + "\u000353C9", baos.toString());
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 13 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class CircuitBuilderTest method testBuilderCombinatorial.

public void testBuilderCombinatorial() throws Exception {
    Variable a = new Variable("a");
    Variable b = new Variable("b");
    // xor
    Expression y = and(or(a, b), not(and(a, b)));
    ElementLibrary library = new ElementLibrary();
    Circuit circuit = new CircuitBuilder(new ShapeFactory(library)).addCombinatorial("y", y).createCircuit();
    ModelCreator m = new ModelCreator(circuit, library);
    TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
    te.check(0, 0, 0);
    te.check(0, 1, 1);
    te.check(1, 0, 1);
    te.check(1, 1, 0);
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) TestExecuter(de.neemann.digital.TestExecuter) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Example 14 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class CircuitBuilderTest method testBuilderSequential.

public void testBuilderSequential() 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)).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);
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) TestExecuter(de.neemann.digital.TestExecuter) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Example 15 with Variable

use of de.neemann.digital.analyse.expression.Variable in project Digital by hneemann.

the class BoolTableExpandedTest method testCombined.

public void testCombined() {
    ArrayList<Signal> in1 = new Signals("b", "c").list();
    ArrayList<Signal> in2 = new Signals("a", "b", "c", "d").list();
    List<Variable> vars = new Vars("a", "b", "c", "d").list();
    BoolTableExpanded bt = new BoolTableExpanded(new BoolTableByteArray(new byte[] { 1, 1, 0, 0 }), in1, in2);
    TableReducer tr = new TableReducer(vars, bt);
    assertTrue(tr.canReduce());
    List<Variable> v = tr.getVars();
    assertEquals(1, v.size());
    assertEquals("b", v.get(0).getIdentifier());
    BoolTable t1 = tr.getTable();
    assertEquals(ThreeStateValue.one, t1.get(0));
    assertEquals(ThreeStateValue.zero, t1.get(1));
}
Also used : Signal(de.neemann.digital.core.Signal) Variable(de.neemann.digital.analyse.expression.Variable) BoolTableByteArray(de.neemann.digital.analyse.quinemc.BoolTableByteArray) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) TableReducer(de.neemann.digital.analyse.quinemc.TableReducer)

Aggregations

Variable (de.neemann.digital.analyse.expression.Variable)51 Expression (de.neemann.digital.analyse.expression.Expression)34 ContextFiller (de.neemann.digital.analyse.expression.ContextFiller)10 NamedExpression (de.neemann.digital.analyse.expression.NamedExpression)8 ArrayList (java.util.ArrayList)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BoolTableByteArray (de.neemann.digital.analyse.quinemc.BoolTableByteArray)6 FormatToExpression (de.neemann.digital.analyse.expression.format.FormatToExpression)5 TestExecuter (de.neemann.digital.TestExecuter)4 Circuit (de.neemann.digital.draw.elements.Circuit)4 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)4 ModelCreator (de.neemann.digital.draw.model.ModelCreator)4 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)4 ExpressionException (de.neemann.digital.analyse.expression.ExpressionException)3 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)3 TableReducer (de.neemann.digital.analyse.quinemc.TableReducer)3 TruthTable (de.neemann.digital.analyse.TruthTable)2 FormatterException (de.neemann.digital.analyse.expression.format.FormatterException)2 FuseMapFillerException (de.neemann.digital.builder.jedec.FuseMapFillerException)2 JedecWriter (de.neemann.digital.builder.jedec.JedecWriter)2