Search in sources :

Example 6 with AgreeNodeBuilder

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder in project AGREE by loonwerks.

the class AgreeInlineLatchedConnections method visit.

@Override
public AgreeNode visit(AgreeNode node) {
    AgreeNodeBuilder builder = new AgreeNodeBuilder(node);
    builder.clearSubNodes();
    for (AgreeNode subNode : node.subNodes) {
        AgreeNode newSubNode = (AgreeNode) subNode.accept(this);
        builder.addSubNode(newSubNode);
    }
    if (node.timing == AgreeNode.TimingModel.LATCHED) {
        for (AgreeNode subNode : builder.build().subNodes) {
            addLatchedInputEqs(builder, subNode);
        }
    }
    AgreeNode finalNode = builder.build();
    nodes.add(finalNode);
    return finalNode;
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)

Example 7 with AgreeNodeBuilder

use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder in project AGREE by loonwerks.

the class LustreAstBuilder method flattenAgreeNode.

protected static AgreeNode flattenAgreeNode(AgreeProgram agreeProgram, AgreeNode agreeNode, String nodePrefix) {
    List<AgreeVar> inputs = new ArrayList<>();
    List<AgreeVar> outputs = new ArrayList<>();
    List<AgreeVar> locals = new ArrayList<>();
    List<AgreeStatement> patternProps = new ArrayList<>();
    List<AgreeEquation> equations = new ArrayList<>();
    List<AgreeStatement> assertions = new ArrayList<>();
    Set<AgreeVar> timeEvents = new HashSet<>(agreeNode.eventTimes);
    Expr someoneTicks = null;
    for (AgreeNode subAgreeNode : agreeNode.subNodes) {
        String prefix = subAgreeNode.id + AgreeASTBuilder.dotChar;
        Expr clockExpr = getClockExpr(agreeNode, subAgreeNode);
        if (someoneTicks == null) {
            someoneTicks = clockExpr;
        } else {
            someoneTicks = new BinaryExpr(someoneTicks, BinaryOp.OR, clockExpr);
        }
        AgreeNode flatNode = flattenAgreeNode(agreeProgram, subAgreeNode, nodePrefix + subAgreeNode.id + AgreeASTBuilder.dotChar);
        Node lustreNode = addSubNodeLustre(agreeProgram, agreeNode, nodePrefix, flatNode);
        addInputsAndOutputs(agreeNode, inputs, outputs, patternProps, flatNode, lustreNode, prefix);
        addTimeEvents(timeEvents, flatNode, prefix, assertions);
        addNodeCall(agreeNode, assertions, prefix, clockExpr, lustreNode);
        addHistoricalAssumptionConstraint(agreeNode, prefix, clockExpr, assertions, lustreNode);
    }
    if (agreeNode.timing == TimingModel.ASYNC) {
        if (someoneTicks == null) {
            throw new AgreeException("Somehow we generated a clock constraint without any clocks." + " Perhaps none of your subcomponents have an agree annex?");
        }
        assertions.add(new AgreeStatement("someone ticks", someoneTicks, null));
    }
    addConnectionConstraints(agreeNode, assertions);
    // add any clock constraints
    assertions.addAll(agreeNode.assertions);
    assertions.add(new AgreeStatement("", agreeNode.clockConstraint, null));
    inputs.addAll(agreeNode.inputs);
    outputs.addAll(agreeNode.outputs);
    locals.addAll(agreeNode.locals);
    equations.addAll(agreeNode.localEquations);
    patternProps.addAll(agreeNode.patternProps);
    AgreeNodeBuilder builder = new AgreeNodeBuilder(agreeNode.id);
    builder.addInput(inputs);
    builder.addOutput(outputs);
    builder.addLocal(locals);
    builder.addLocalEquation(equations);
    builder.addIvcElements(agreeNode.getivcElements());
    builder.addSubNode(agreeNode.subNodes);
    builder.addAssertion(assertions);
    builder.addAssumption(agreeNode.assumptions);
    builder.addGuarantee(agreeNode.guarantees);
    builder.addLemma(agreeNode.lemmas);
    builder.addPatternProp(patternProps);
    builder.setClockConstraint(new BoolExpr(true));
    builder.setInitialConstraint(agreeNode.initialConstraint);
    builder.setClockVar(agreeNode.clockVar);
    builder.setReference(agreeNode.reference);
    builder.setTiming(null);
    builder.addEventTime(timeEvents);
    builder.setCompInst(agreeNode.compInst);
    builder.setFaultTreeFlag(agreeNode.faultTreeFlag);
    return builder.build();
}
Also used : BoolExpr(jkind.lustre.BoolExpr) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) BinaryExpr(jkind.lustre.BinaryExpr) Node(jkind.lustre.Node) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) ArrayList(java.util.ArrayList) AgreeEquation(com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) HashSet(java.util.HashSet)

Aggregations

AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)7 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)6 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)5 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)5 ArrayList (java.util.ArrayList)5 Expr (jkind.lustre.Expr)5 IdExpr (jkind.lustre.IdExpr)4 NodeCallExpr (jkind.lustre.NodeCallExpr)4 BinaryExpr (jkind.lustre.BinaryExpr)3 BoolExpr (jkind.lustre.BoolExpr)3 UnaryExpr (jkind.lustre.UnaryExpr)3 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)2 AgreeConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection)2 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)2 Node (jkind.lustre.Node)2 TimingModel (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode.TimingModel)1 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 SafetyNodeBuilder (edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder)1 BaseFault (edu.umn.cs.crisys.safety.analysis.transform.BaseFault)1 Fault (edu.umn.cs.crisys.safety.analysis.transform.Fault)1