Search in sources :

Example 41 with Variable

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

the class Gal16V8JEDECExporterTest 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));
    Gal16v8JEDECExporter gal = new Gal16v8JEDECExporter();
    gal.getPinMapping().assignPin("D", 2).assignPin("Q0", 12).assignPin("Q1", 13).assignPin("Q2", 14).assignPin("P0", 15).assignPin("P1", 16).assignPin("P2", 17).assignPin("P3", 18);
    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 GAL16v8 assembler*\r\n" + "QF2194*\r\n" + "G0*\r\n" + "F0*\r\n" + "L256 11111111111111111111111111111111*\r\n" + "L288 11111111111111111111110111111101*\r\n" + "L320 11111111111111111111110111011111*\r\n" + "L512 11111111111111111111111111111111*\r\n" + "L544 11111111111111111111111011011101*\r\n" + "L576 11111111111111111111110111101111*\r\n" + "L768 11111111111111111111111111111111*\r\n" + "L800 11111111111111111111111011111101*\r\n" + "L832 11111111111111111111111011011111*\r\n" + "L1024 11111111111111111111111111111111*\r\n" + "L1056 11111111111111111111110111011101*\r\n" + "L1088 11111111111111111111111011101111*\r\n" + "L1280 10111111111111111111111011011101*\r\n" + "L1312 10111111111111111111110111101111*\r\n" + "L1344 01111111111111111111111011101110*\r\n" + "L1376 01111111111111111111110111111101*\r\n" + "L1408 11111111111111111111110111011110*\r\n" + "L1536 10111111111111111111111111101101*\r\n" + "L1568 10111111111111111111111111011110*\r\n" + "L1600 01111111111111111111111111101110*\r\n" + "L1632 01111111111111111111111111011101*\r\n" + "L1792 11111111111111111111111111111110*\r\n" + // "L2048 01111111001100000011000000100000*\r\n" +  // WinCupl fills some bits to the signature! Don't know why!
    "L2048 01111111000000000000000000000000*\r\n" + "L2112 00000000111110001111111111111111*\r\n" + "L2144 11111111111111111111111111111111*\r\n" + "L2176 111111111111111101*\r\n" + "C5723*\r\n" + "\u0003CE43", baos.toString());
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 42 with Variable

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

the class Gal16V8JEDECExporterTest method testCombinatorial.

// BitCount
public void testCombinatorial() throws Exception {
    Variable A = new Variable("A");
    Variable B = new Variable("B");
    Variable C = new Variable("C");
    // Y_0 = (!A & !B & C) #
    // (!A & B & !C) #
    // (A & !B & !C) #
    // (A & B & C);
    Expression Y_0 = or(and(not(A), not(B), C), and(not(A), B, not(C)), and(A, not(B), not(C)), and(A, B, C));
    // Y_1 = (A & C) # (A & B) # (B & C);
    Expression Y_1 = or(and(A, C), and(A, B), and(B, C));
    Gal16v8JEDECExporter gal = new Gal16v8JEDECExporter();
    gal.getPinMapping().assignPin("A", 2).assignPin("B", 3).assignPin("C", 4).assignPin("Y_1", 12).assignPin("Y_0", 13);
    gal.getBuilder().addCombinatorial("Y_0", Y_0).addCombinatorial("Y_1", Y_1);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    gal.writeTo(baos);
    assertEquals("\u0002Digital GAL16v8 assembler*\r\n" + "QF2194*\r\n" + "G0*\r\n" + "F0*\r\n" + "L1536 10111011011111111111111111111111*\r\n" + "L1568 10110111101111111111111111111111*\r\n" + "L1600 01111011101111111111111111111111*\r\n" + "L1632 01110111011111111111111111111111*\r\n" + "L1792 01111111011111111111111111111111*\r\n" + "L1824 01110111111111111111111111111111*\r\n" + "L1856 11110111011111111111111111111111*\r\n" + // "L2048 00000011001100000011000000100000*\r\n" + // this is cupls line; WinCupl fills some bits to the signature! Don't know why!
    "L2048 00000011000000000000000000000000*\r\n" + "L2112 00000000111111001111111111111111*\r\n" + "L2144 11111111111111111111111111111111*\r\n" + "L2176 111111111111111110*\r\n" + "C244C*\r\n" + "\u00035E24", baos.toString());
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 43 with Variable

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

the class Gal22V10CuplExporterTest method testCUPLExporter.

public void testCUPLExporter() 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)));
    Gal22v10CuplExporter ce = new Gal22v10CuplExporter("user", null);
    ce.getPinMapping().parseString("Y_0=14;Y_1=15;A=16");
    ce.setProjectName("test");
    ce.getBuilder().addSequential("Y_0", y0s).addSequential("Y_1", y1s).addCombinatorial("A", and(y0, y1));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ce.writeTo(baos);
    assertEquals("Name     test ;\r\n" + "PartNo   00 ;\r\n" + "Date     unknownDate ;\r\n" + "Revision 01 ;\r\n" + "Designer user ;\r\n" + "Company  unknown ;\r\n" + "Assembly None ;\r\n" + "Location unknown ;\r\n" + "Device   g22v10 ;\r\n" + "\r\n" + "ar = 'b'0 ;\r\n" + "sp = 'b'0 ;\r\n" + "\r\n" + "/* inputs */\r\n" + "PIN 1 = CLK;\r\n" + "\r\n" + "/* outputs */\r\n" + "PIN 14 = Y_0;\r\n" + "PIN 15 = Y_1;\r\n" + "PIN 16 = A;\r\n" + "\r\n" + "/* sequential logic */\r\n" + "Y_0.D = !Y_0;\r\n" + "Y_0.ar = ar ;\r\n" + "Y_0.sp = sp ;\r\n" + "Y_1.D = (!Y_0 & Y_1) # (Y_0 & !Y_1);\r\n" + "Y_1.ar = ar ;\r\n" + "Y_1.sp = sp ;\r\n" + "\r\n" + "/* combinatorial logic */\r\n" + "A = Y_0 & Y_1;\r\n", baos.toString());
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 44 with Variable

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

the class Gal22v10JEDECExporterTest method testPin13.

public void testPin13() throws Exception {
    Variable Q0 = new Variable("Q0");
    Variable Q1 = new Variable("Q1");
    Variable Q2 = new Variable("Q2");
    Expression Y = and(Q0, Q1, Q2);
    Gal22v10JEDECExporter gal = new Gal22v10JEDECExporter();
    gal.getPinMapping().assignPin("Q0", 10).assignPin("Q1", 11).assignPin("Q2", 13).assignPin("Y", 23);
    gal.getBuilder().addCombinatorial("Y", Y);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    gal.writeTo(baos);
    assertEquals("\u0002Digital GAL22v10 assembler*\r\n" + "QF5892*\r\n" + "G0*\r\n" + "F0*\r\n" + // fuses generated with WinCupl
    "L32 00000000000011111111111111111111*\r\n" + "L64 11111111111111111111111111111111*\r\n" + "L96 11111111111111111111111111110111*\r\n" + "L128 01010000000000000000000000000000*\r\n" + "L5792 00000000000000001100000000000000*\r\n" + // "L5824 00000011000000110000001000000000*\r\n" +  // CUPL writes data to the signature bytes, don't know why
    "C0AE3*\r\n" + "\u00033205", baos.toString());
}
Also used : Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 45 with Variable

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

the class CircuitBuilderTest method testBuilderSequentialJK.

public void testBuilderSequentialJK() throws Exception {
    Variable y0 = new Variable("Y_0");
    Variable y1 = new Variable("Y_1");
    // counter
    Expression y0s = not(y0);
    Expression y1s = or(not(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, 1);
    te.checkC(0, 0);
    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)

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