Search in sources :

Example 1 with Transition

use of com.jopdesign.wcet.uppaal.model.Transition in project jop by jop-devel.

the class TemplateBuilder method addSyncLoop.

/** add a synchronization loop from end to start */
public void addSyncLoop() {
    Transition cont = new Transition(getEnd(), getInitial());
    String channel = SystemBuilder.methodChannel(pid);
    cont.getAttrs().setSync(channel + "!");
    if (loopBounds.size() > 0) {
        cont.getAttrs().appendUpdate("rst()");
    }
    template.addTransition(cont);
    getOutgoingAttrs(getInitial()).setSync(channel + "?");
}
Also used : Transition(com.jopdesign.wcet.uppaal.model.Transition)

Example 2 with Transition

use of com.jopdesign.wcet.uppaal.model.Transition in project jop by jop-devel.

the class TemplateBuilder method getFinalTemplate.

public Template getFinalTemplate() {
    if (outgoingAttrs == null)
        return this.template;
    for (int i = 0; i < loopVarBounds.size(); i++) {
        template.appendDeclaration(String.format("int[0,%s] %s;", loopVarBounds.get(i), loopVarName(i)));
    }
    if (loopVarBounds.size() > 0) {
        StringBuilder rst = new StringBuilder();
        rst.append("void rst() {\n");
        for (int i = 0; i < loopVarBounds.size(); i++) {
            rst.append(String.format("  %s = 0;\n", loopVarName(i)));
        }
        rst.append("} \n");
        template.appendDeclaration(rst.toString());
    }
    for (Location l : template.getLocations()) {
        TransitionAttributes in = incomingAttrs.get(l);
        if (in != null) {
            for (Transition t : l.getPredecessors()) {
                t.getAttrs().addAttributes(in);
            }
        }
        TransitionAttributes out = outgoingAttrs.get(l);
        if (out != null) {
            for (Transition t : l.getSuccessors()) {
                t.getAttrs().addAttributes(out);
            }
        }
    }
    outgoingAttrs = incomingAttrs = null;
    /* debug: create dot file */
    if (config.debug) {
        File dbgFile = config.getOutFile("template_" + template.getId() + ".dot");
        try {
            template.exportDOT(dbgFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    new LayoutCFG(100, 120).layoutCfgModel(template);
    return template;
}
Also used : TransitionAttributes(com.jopdesign.wcet.uppaal.model.TransitionAttributes) Transition(com.jopdesign.wcet.uppaal.model.Transition) IOException(java.io.IOException) File(java.io.File) Location(com.jopdesign.wcet.uppaal.model.Location) LayoutCFG(com.jopdesign.wcet.uppaal.model.LayoutCFG)

Example 3 with Transition

use of com.jopdesign.wcet.uppaal.model.Transition in project jop by jop-devel.

the class TemplateBuilder method addPostEnd.

/** add a final node */
public void addPostEnd() {
    if (postEnd != null)
        throw new AssertionError("Called addPostEnd twice");
    postEnd = new Location("EE");
    template.addLocation(postEnd);
    template.addTransition(new Transition(getEnd(), postEnd));
}
Also used : Transition(com.jopdesign.wcet.uppaal.model.Transition) Location(com.jopdesign.wcet.uppaal.model.Location)

Example 4 with Transition

use of com.jopdesign.wcet.uppaal.model.Transition in project jop by jop-devel.

the class TemplateBuilder method createTransition.

public Transition createTransition(Location src, Location target) {
    Transition t = new Transition(src, target);
    this.template.addTransition(t);
    return t;
}
Also used : Transition(com.jopdesign.wcet.uppaal.model.Transition)

Example 5 with Transition

use of com.jopdesign.wcet.uppaal.model.Transition in project jop by jop-devel.

the class MethodBuilder method buildEdge.

private void buildEdge(ControlFlowGraph.CFGEdge edge) {
    Set<CFGNode> hols = cfg.getLoopColoring().getHeadOfLoops();
    Set<ControlFlowGraph.CFGEdge> backEdges = cfg.getLoopColoring().getBackEdges();
    Map<ControlFlowGraph.CFGEdge, LoopColoring.IterationBranchLabel<CFGNode>> edgeColoring = cfg.getLoopColoring().getIterationBranchEdges();
    CFGNode src = cfg.getEdgeSource(edge);
    CFGNode target = cfg.getEdgeTarget(edge);
    if (src == cfg.getEntry() && target == cfg.getExit())
        return;
    Transition transition = tBuilder.createTransition(nodeTemplates.get(src).getExit(), nodeTemplates.get(target).getEntry());
    TransitionAttributes attrs = transition.getAttrs();
    LoopColoring.IterationBranchLabel<CFGNode> edgeColor = edgeColoring.get(edge);
    if (jTrans.getConfig().useProgressMeasure) {
        if (src instanceof ControlFlowGraph.InvokeNode) {
            attrs.appendUpdate("pm := pm + 1");
        } else {
            RelativeProgress<CFGNode> progress = jTrans.getProgress(cfg.getMethodInfo()).get(edge);
            String progressExpr = "pm := pm + " + progress.staticDiff;
            for (Entry<CFGNode, Long> loopDiff : progress.loopDiff.entrySet()) {
                progressExpr += String.format(" - %d * %s", loopDiff.getValue(), tBuilder.getLoopVar(loopDiff.getKey()));
            }
            attrs.appendUpdate(progressExpr);
        }
    }
    if (edgeColor != null) {
        for (CFGNode loop : edgeColor.getContinues()) {
            attrs.appendGuard(tBuilder.contLoopGuard(loop));
            attrs.appendUpdate(tBuilder.incrLoopCounter(loop));
        }
        for (CFGNode loop : edgeColor.getExits()) {
            attrs.appendGuard(tBuilder.exitLoopGuard(loop));
            attrs.appendUpdate(tBuilder.resetLoopCounter(loop));
        }
    }
    if (hols.contains(target) && !backEdges.contains(edge)) {
        attrs.appendUpdate(tBuilder.resetLoopCounter(target));
    }
}
Also used : CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) TransitionAttributes(com.jopdesign.wcet.uppaal.model.TransitionAttributes) CallString(com.jopdesign.common.code.CallString) LoopColoring(com.jopdesign.common.graphutils.LoopColoring) Transition(com.jopdesign.wcet.uppaal.model.Transition)

Aggregations

Transition (com.jopdesign.wcet.uppaal.model.Transition)5 Location (com.jopdesign.wcet.uppaal.model.Location)2 TransitionAttributes (com.jopdesign.wcet.uppaal.model.TransitionAttributes)2 CallString (com.jopdesign.common.code.CallString)1 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)1 LoopColoring (com.jopdesign.common.graphutils.LoopColoring)1 LayoutCFG (com.jopdesign.wcet.uppaal.model.LayoutCFG)1 File (java.io.File)1 IOException (java.io.IOException)1