-
Notifications
You must be signed in to change notification settings - Fork 0
/
regen.sc
168 lines (130 loc) · 6.78 KB
/
regen.sc
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
::#! 2> /dev/null #
@ 2>/dev/null # 2>nul & echo off & goto BOF #
if [ -f "$0.com" ] && [ "$0.com" -nt "$0" ]; then #
exec "$0.com" "$@" #
fi #
rm -f "$0.com" #
if [ -z ${SIREUM_HOME} ]; then #
echo "Please set SIREUM_HOME env var" #
exit -1 #
fi #
exec ${SIREUM_HOME}/bin/sireum slang run -s -n "$0" "$@" #
:BOF
if not defined SIREUM_HOME (
echo Please set SIREUM_HOME env var
exit /B -1
)
%SIREUM_HOME%\bin\sireum.bat slang run -s -n "%0" %*
exit /B %errorlevel%
::!#
// #Sireum
import org.sireum._
val(sel4, sel4_tb, sel4_only) = (Cli.SireumHamrCodegenHamrPlatform.SeL4, Cli.SireumHamrCodegenHamrPlatform.SeL4_TB, Cli.SireumHamrCodegenHamrPlatform.SeL4_Only)
val case_tool_evaluation_dir = Os.home / "devel/case/CASE-loonwerks/TA5/tool-evaluation-4/HAMR/examples"
def gen(name: String, json: String, platforms: ISZ[Cli.SireumHamrCodegenHamrPlatform.Type]): (String, Os.Path, Os.Path, ISZ[Cli.SireumHamrCodegenHamrPlatform.Type]) = {
val modelDir = case_tool_evaluation_dir / name
val simpleName = Os.path(name).name // get last dir name
return (simpleName, modelDir, modelDir / ".slang" / json, platforms)
}
val tests: ISZ[(String, Os.Path, Os.Path, ISZ[Cli.SireumHamrCodegenHamrPlatform.Type])] = ISZ(
gen("simple_uav", "UAV_UAV_Impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_data_port", "test_data_port_top_impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_data_port_periodic", "test_data_port_periodic_top_impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_data_port_periodic_fan_out", "test_data_port_periodic_fan_out_top_impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_event_data_port", "test_event_data_port_top_impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_event_data_port_fan_out", "test_event_data_port_fan_out_top_impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_event_port", "test_event_port_top_impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_event_port_fan_out", "test_event_port_fan_out_top_impl_Instance.json", ISZ(sel4_tb, sel4_only)),
gen("test_data_port_periodic_domains", "test_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_tb, sel4_only, sel4)),
gen("test_event_data_port_periodic_domains", "test_event_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_tb, sel4_only, sel4)),
gen("test_event_port_periodic_domains", "test_event_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_tb, sel4_only, sel4)),
// VMs
gen("test_data_port_periodic_domains_VM/both_vm", "test_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_only, sel4)),
gen("test_data_port_periodic_domains_VM/receiver_vm", "test_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_only, sel4)),
gen("test_data_port_periodic_domains_VM/sender_vm", "test_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_only, sel4)),
gen("test_event_data_port_periodic_domains_VM/both_vm", "test_event_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_only, sel4)),
gen("test_event_data_port_periodic_domains_VM/receiver_vm", "test_event_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_only, sel4)),
gen("test_event_data_port_periodic_domains_VM/sender_vm", "test_event_data_port_periodic_domains_top_impl_Instance.json", ISZ(sel4_only, sel4)),
)
def run(runCAmkESBuild: B): Unit = {
for (project <- tests) {
val projectDir = project._2
val slangFile = project._3
if(!projectDir.exists) {
halt(s"${projectDir} does not exist");
}
var readmeEntries: ISZ[ST] = ISZ()
for (platform <- project._4) {
val outputDir = platform match {
case Cli.SireumHamrCodegenHamrPlatform.SeL4_TB => projectDir / "CAmkES_seL4_TB"
case Cli.SireumHamrCodegenHamrPlatform.SeL4_Only => projectDir / "CAmkES_seL4_Only"
case Cli.SireumHamrCodegenHamrPlatform.SeL4 => projectDir / "CAmkES_seL4"
case _ => halt("??")
}
val camkesOutputDir = platform match {
case Cli.SireumHamrCodegenHamrPlatform.SeL4_TB => outputDir
case Cli.SireumHamrCodegenHamrPlatform.SeL4_Only => outputDir
case Cli.SireumHamrCodegenHamrPlatform.SeL4 => outputDir / "src/c/CAmkES_seL4"
case _ => halt("??")
}
val o = Cli.SireumHamrCodegenOption(
help = "",
args = ISZ(slangFile.value),
json = T,
verbose = T,
platform = platform,
packageName = Some(project._1),
embedArt = T,
devicesAsThreads = F,
excludeComponentImpl = T,
bitWidth = 32,
maxStringSize = 256,
maxArraySize = 1,
slangAuxCodeDirs = ISZ(),
slangOutputCDir = None(),
outputDir = Some(outputDir.value),
camkesOutputDir = Some(camkesOutputDir.value),
camkesAuxCodeDirs = ISZ(),
aadlRootDir = Some(projectDir.value)
)
// outputDir.removeAll()
// run HAMR
// cli.HAMR.codeGen(o)
if(runCAmkESBuild) {
val scriptLoc = camkesOutputDir / "bin/run-camkes.sh"
assert(scriptLoc.exists)
val args: ISZ[String] = ISZ("sh", scriptLoc.value)
println(args)
val results = Os.proc(args).run()
println(results.exitCode)
println(results.err)
println(results.out)
if(results.exitCode != 0) halt("No")
}
val dot = camkesOutputDir / "graph.dot"
if(dot.exists) {
val tool_eval_4_diagrams = projectDir / "diagrams"
//val dotPDFOutput = tool_eval_4_diagrams / s"CAmkES-arch-${platform}.pdf"
//val proc:ISZ[String] = ISZ("dot", "-Tpdf", dot.canon.value, "-o", dotPDFOutput.canon.value)
//Os.proc(proc).console.run()
val dotPNGOutput = tool_eval_4_diagrams / s"CAmkES-arch-${platform}.png"
val proc2:ISZ[String] = ISZ("dot", "-Tpng", dot.canon.value, "-o", dotPNGOutput.canon.value)
Os.proc(proc2).console.run()
val readmePath = s"diagrams/${dotPNGOutput.name}"
readmeEntries = readmeEntries :+ st"""## ${platform} Arch
| ![${platform}](${readmePath})"""
}
}
val readme = projectDir / "readme_autogen.md"
val aadlArch = "diagrams/aadl-arch.png"
val readmest = st"""# ${project._1}
|
|## AADL Arch
| ![aadl](${aadlArch})
|
|${(readmeEntries, "\n\n")}
|"""
readme.writeOver(readmest.render)
}
}
run(T)