-
Notifications
You must be signed in to change notification settings - Fork 0
/
Splitter.java
97 lines (83 loc) · 3.19 KB
/
Splitter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package ece351.vhdl;
import java.util.LinkedHashSet;
import java.util.Set;
import org.parboiled.common.ImmutableList;
import ece351.common.ast.AndExpr;
import ece351.common.ast.AssignmentStatement;
import ece351.common.ast.ConstantExpr;
import ece351.common.ast.EqualExpr;
import ece351.common.ast.Expr;
import ece351.common.ast.NAndExpr;
import ece351.common.ast.NOrExpr;
import ece351.common.ast.NaryAndExpr;
import ece351.common.ast.NaryOrExpr;
import ece351.common.ast.NotExpr;
import ece351.common.ast.OrExpr;
import ece351.common.ast.VarExpr;
import ece351.common.ast.XNOrExpr;
import ece351.common.ast.XOrExpr;
import ece351.common.visitor.PostOrderExprVisitor;
import ece351.util.CommandLine;
import ece351.vhdl.ast.Architecture;
import ece351.vhdl.ast.DesignUnit;
import ece351.vhdl.ast.IfElseStatement;
import ece351.vhdl.ast.Process;
import ece351.vhdl.ast.Statement;
import ece351.vhdl.ast.VProgram;
/**
* Process splitter.
*/
public final class Splitter extends PostOrderExprVisitor {
private final Set<String> usedVarsInExpr = new LinkedHashSet<String>();
public static void main(String[] args) {
System.out.println(split(args));
}
public static VProgram split(final String[] args) {
return split(new CommandLine(args));
}
public static VProgram split(final CommandLine c) {
final VProgram program = DeSugarer.desugar(c);
return split(program);
}
public static VProgram split(final VProgram program) {
VProgram p = Elaborator.elaborate(program);
final Splitter s = new Splitter();
return s.splitit(p);
}
private VProgram splitit(final VProgram program) {
// Determine if the process needs to be split into multiple processes
// Split the process if there are if/else statements so that the if/else statements only assign values to one pin
// TODO: 35 lines snipped
throw new ece351.util.Todo351Exception();
}
// You do not have to use this helper method, but we found it useful
private ImmutableList<Statement> splitIfElseStatement(final IfElseStatement ifStmt) {
// loop over each statement in the ifBody
// loop over each statement in the elseBody
// check if outputVars are the same
// initialize/clear this.usedVarsInExpr
// call traverse a few times to build up this.usedVarsInExpr
// build sensitivity list from this.usedVarsInExpr
// build the resulting list of split statements
// return result
// TODO: 34 lines snipped
throw new ece351.util.Todo351Exception();
}
@Override
public Expr visitVar(final VarExpr e) {
this.usedVarsInExpr.add(e.identifier);
return e;
}
// no-ops
@Override public Expr visitConstant(ConstantExpr e) { return e; }
@Override public Expr visitNot(NotExpr e) { return e; }
@Override public Expr visitAnd(AndExpr e) { return e; }
@Override public Expr visitOr(OrExpr e) { return e; }
@Override public Expr visitXOr(XOrExpr e) { return e; }
@Override public Expr visitNAnd(NAndExpr e) { return e; }
@Override public Expr visitNOr(NOrExpr e) { return e; }
@Override public Expr visitXNOr(XNOrExpr e) { return e; }
@Override public Expr visitEqual(EqualExpr e) { return e; }
@Override public Expr visitNaryAnd(NaryAndExpr e) { return e; }
@Override public Expr visitNaryOr(NaryOrExpr e) { return e; }
}