@@ -68,4 +68,72 @@ object DFHDLCommands {
68
68
69
69
state
70
70
}
71
+
72
+ val clearSandbox = Command .command(" clearSandbox" ) { state =>
73
+ // Remove the sandbox folder and all its contents before running the tests
74
+ val sandboxPath = java.nio.file.Paths .get(" sandbox" )
75
+ if (java.nio.file.Files .exists(sandboxPath)) {
76
+ import java .nio .file ._
77
+ import java .nio .file .attribute .BasicFileAttributes
78
+
79
+ Files .walkFileTree(
80
+ sandboxPath,
81
+ new SimpleFileVisitor [Path ] {
82
+ override def visitFile (file : Path , attrs : BasicFileAttributes ): FileVisitResult = {
83
+ Files .delete(file)
84
+ FileVisitResult .CONTINUE
85
+ }
86
+ override def postVisitDirectory (dir : Path , exc : java.io.IOException ): FileVisitResult = {
87
+ Files .delete(dir)
88
+ FileVisitResult .CONTINUE
89
+ }
90
+ }
91
+ )
92
+ }
93
+ state
94
+ }
95
+
96
+ val vhdlTools = List (" ghdl" , " nvc" , " questa" , " vivado" )
97
+ val verilogTools = List (" verilator" , " iverilog" , " questa" , " vivado" )
98
+ val vhdlDialects = List (" vhdl.v93" , " vhdl.v2008" )
99
+ val verilogDialects = List (" verilog.v95" , " verilog.v2001" , " verilog.sv2005" )
100
+
101
+ val testApps = Command .command(" testApps" ) { state =>
102
+ var newState = Command .process(" clearSandbox" , state, _ => ())
103
+ val extracted = Project .extract(newState)
104
+ val runMainTask = LocalProject (" lib" ) / Test / runMain
105
+ val existingTools : Set [String ] = {
106
+ import java .io .{ByteArrayOutputStream , PrintStream }
107
+ val baos = new ByteArrayOutputStream ()
108
+ val ps = new PrintStream (baos)
109
+ val oldOut = System .out
110
+ val oldErr = System .err
111
+ val arguments = s " util.top_EmptyDesign help simulate-tool -s "
112
+ try {
113
+ System .setOut(ps)
114
+ System .setErr(ps)
115
+ val extracted = Project .extract(state)
116
+ extracted.runInputTask(runMainTask, arguments, state)
117
+ } finally {
118
+ System .out.flush()
119
+ System .err.flush()
120
+ System .setOut(oldOut)
121
+ System .setErr(oldErr)
122
+ }
123
+ val helpStr = baos.toString(" UTF-8" )
124
+ val allTools = (vhdlTools ++ verilogTools).toSet
125
+ allTools.filter(tool => helpStr.linesIterator.exists(line => line.contains(tool) && line.contains(" Found version" )))
126
+ }
127
+ for (tool <- vhdlTools if existingTools.contains(tool); dialect <- vhdlDialects) {
128
+ val arguments = s " AES.top_CipherSim simulate -b $dialect -t $tool --Werror-tool "
129
+ val (updatedState, _) = extracted.runInputTask(runMainTask, arguments, newState)
130
+ newState = updatedState
131
+ }
132
+ for (tool <- verilogTools if existingTools.contains(tool); dialect <- verilogDialects) {
133
+ val arguments = s " AES.top_CipherSim simulate -b $dialect -t $tool --Werror-tool "
134
+ val (updatedState, _) = extracted.runInputTask(runMainTask, arguments, newState)
135
+ newState = updatedState
136
+ }
137
+ newState
138
+ }
71
139
}
0 commit comments