Search in sources :

Example 1 with ModelAnalyser

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

the class BuilderExpressionCreatorTest method check.

private void check(Model m) throws AnalyseException, NodeException, BacktrackException, PinException {
    TruthTable tt = new ModelAnalyser(m).analyse();
    m.close();
    assertEquals(1, tt.getResultCount());
    BoolTable r = tt.getResult(0);
    assertEquals(4, r.size());
    assertEquals(ThreeStateValue.zero, r.get(0));
    assertEquals(ThreeStateValue.one, r.get(1));
    assertEquals(ThreeStateValue.one, r.get(2));
    assertEquals(ThreeStateValue.zero, r.get(3));
}
Also used : ModelAnalyser(de.neemann.digital.analyse.ModelAnalyser) TruthTable(de.neemann.digital.analyse.TruthTable) BoolTable(de.neemann.digital.analyse.quinemc.BoolTable)

Example 2 with ModelAnalyser

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

the class Main method createAnalyseMenu.

/**
 * Creates the analyse menu
 *
 * @param menuBar the menu bar
 */
private void createAnalyseMenu(JMenuBar menuBar) {
    JMenu analyse = new JMenu(Lang.get("menu_analyse"));
    menuBar.add(analyse);
    analyse.add(new ToolTipAction(Lang.get("menu_analyse")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Model model = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false);
                try {
                    if (model.isInvalidSignal())
                        new ErrorMessage(Lang.get("msg_invalidSignalsAnalysed")).show(Main.this);
                    else
                        new TableDialog(Main.this, new ModelAnalyser(model).analyse(), library, shapeFactory, getBaseFileName()).setVisible(true);
                    ensureModelIsStopped();
                } finally {
                    model.close();
                }
            } catch (PinException | NodeException | AnalyseException | ElementNotFoundException | BacktrackException | RuntimeException e1) {
                showErrorWithoutARunningModel(Lang.get("msg_analyseErr"), e1);
            }
        }
    }.setToolTip(Lang.get("menu_analyse_tt")).setAccelerator("F9").createJMenuItem());
    analyse.add(new ToolTipAction(Lang.get("menu_synthesise")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            TruthTable tt = new TruthTable(3).addResult();
            new TableDialog(Main.this, tt, library, shapeFactory, getBaseFileName()).setVisible(true);
            ensureModelIsStopped();
        }
    }.setToolTip(Lang.get("menu_synthesise_tt")).createJMenuItem());
    analyse.add(new ToolTipAction(Lang.get("menu_expression")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new ExpressionDialog(Main.this, library, shapeFactory, getBaseFileName()).setVisible(true);
        }
    }.setToolTip(Lang.get("menu_expression_tt")).createJMenuItem());
}
Also used : ModelAnalyser(de.neemann.digital.analyse.ModelAnalyser) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException) AnalyseException(de.neemann.digital.analyse.AnalyseException) ModelCreator(de.neemann.digital.draw.model.ModelCreator) TableDialog(de.neemann.digital.gui.components.table.TableDialog) ValueTableDialog(de.neemann.digital.gui.components.testing.ValueTableDialog) TruthTable(de.neemann.digital.analyse.TruthTable) LibraryTreeModel(de.neemann.digital.gui.components.tree.LibraryTreeModel) ExpressionDialog(de.neemann.digital.gui.components.expression.ExpressionDialog)

Example 3 with ModelAnalyser

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

the class CircuitBuilderTest method testBus.

public void testBus() throws Exception {
    final ToBreakRunner runner = new ToBreakRunner("dig/circuitBuilder/busTest.dig", false);
    // create truth table incl. ModelAnalyzerInfo
    TruthTable tt = new ModelAnalyser(runner.getModel()).analyse();
    assertEquals(8, tt.getVars().size());
    assertEquals(8, tt.getResultCount());
    // create expressions based on truth table
    ExpressionListenerStore expr = new ExpressionListenerStore(null);
    new ExpressionCreator(tt).create(expr);
    // build a new circuit
    CircuitBuilder circuitBuilder = new CircuitBuilder(runner.getLibrary().getShapeFactory(), false, tt.getVars()).setModelAnalyzerInfo(tt.getModelAnalyzerInfo());
    new BuilderExpressionCreator(circuitBuilder).create(expr);
    Circuit circuit = circuitBuilder.createCircuit();
    // check
    List<VisualElement> in = circuit.findElements(v -> v.equalsDescription(In.DESCRIPTION));
    assertEquals(2, in.size());
    checkPin(in.get(0), "A", "1,2,3,4");
    checkPin(in.get(1), "B", "5,6,7,8");
    List<VisualElement> out = circuit.findElements(v -> v.equalsDescription(Out.DESCRIPTION));
    assertEquals(2, out.size());
    checkPin(out.get(0), "S", "9,10,11,12");
    checkPin(out.get(1), "U", "13,14,15,16");
}
Also used : ModelAnalyser(de.neemann.digital.analyse.ModelAnalyser) TruthTable(de.neemann.digital.analyse.TruthTable) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner) Circuit(de.neemann.digital.draw.elements.Circuit) VisualElement(de.neemann.digital.draw.elements.VisualElement) BuilderExpressionCreator(de.neemann.digital.gui.components.table.BuilderExpressionCreator) ExpressionListenerStore(de.neemann.digital.gui.components.table.ExpressionListenerStore) ExpressionCreator(de.neemann.digital.gui.components.table.ExpressionCreator) BuilderExpressionCreator(de.neemann.digital.gui.components.table.BuilderExpressionCreator)

Aggregations

ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)3 TruthTable (de.neemann.digital.analyse.TruthTable)3 AnalyseException (de.neemann.digital.analyse.AnalyseException)1 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)1 Circuit (de.neemann.digital.draw.elements.Circuit)1 VisualElement (de.neemann.digital.draw.elements.VisualElement)1 ElementNotFoundException (de.neemann.digital.draw.library.ElementNotFoundException)1 ModelCreator (de.neemann.digital.draw.model.ModelCreator)1 ExpressionDialog (de.neemann.digital.gui.components.expression.ExpressionDialog)1 BuilderExpressionCreator (de.neemann.digital.gui.components.table.BuilderExpressionCreator)1 ExpressionCreator (de.neemann.digital.gui.components.table.ExpressionCreator)1 ExpressionListenerStore (de.neemann.digital.gui.components.table.ExpressionListenerStore)1 TableDialog (de.neemann.digital.gui.components.table.TableDialog)1 ValueTableDialog (de.neemann.digital.gui.components.testing.ValueTableDialog)1 LibraryTreeModel (de.neemann.digital.gui.components.tree.LibraryTreeModel)1 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)1