tinyriscv/tools/riscv-torture/gen_loop.diff

62 lines
2.3 KiB
Diff

diff --git a/Makefile b/Makefile
index a85579f..5ec0ed6 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ C_SIM := ../emulator/emulator-rocketchip-$(RTL_CONFIG)
R_SIM := ../vsim/simv-rocketchip-$(RTL_CONFIG)
TEST := output/test.S
OPTIONS := $(empty)
+NUM := 0
SUITE := output
CONFIG := config/default.config
COMMIT := none
@@ -20,7 +21,7 @@ GITCMT := $(subst $(space),$(gitopt),$(COMMIT))
cnight rnight crnight csuite rsuite \
gen:
- $(SBT) 'generator/run $(OPTIONS)'
+ $(SBT) 'generator/run -n $(NUM)'
csuite:
for i in `ls $(SUITE) | grep .S` ; do echo $$i ; \
diff --git a/generator/src/main/scala/main.scala b/generator/src/main/scala/main.scala
index d5a79f5..a7b3b49 100644
--- a/generator/src/main/scala/main.scala
+++ b/generator/src/main/scala/main.scala
@@ -8,7 +8,7 @@ import java.util.Properties
import scala.collection.JavaConversions._
case class Options(var outFileName: String = "test",
- var confFileName: String = "config/default.config")
+ var confFileName: String = "config/default.config", var numOutFiles: Int = 0)
object Generator extends App
{
@@ -17,15 +17,25 @@ object Generator extends App
val parser = new OptionParser[Options]("generator/run") {
opt[String]('C', "config") valueName("<file>") text("config file") action {(s: String, c) => c.copy(confFileName = s)}
opt[String]('o', "output") valueName("<filename>") text("output filename") action {(s: String, c) => c.copy(outFileName = s)}
+ opt[Int]('n', "numfiles") valueName("<num_files>") text("number of output files") action {(n: Int, c) => c.copy(numOutFiles = n)}
}
parser.parse(args, Options()) match {
case Some(opts) =>
- generate(opts.confFileName, opts.outFileName)
+ generate_loop(opts.confFileName, opts.outFileName, opts.numOutFiles)
case None =>
System.exit(1) //error message printed by parser
}
}
+ def generate_loop(confFile: String, outFileName: String, numOutFiles: Int) = {
+ if (numOutFiles > 0) {
+ for (i <- 0 to (numOutFiles-1))
+ generate(confFile, outFileName + ("_%03d" format (i)))
+ } else {
+ generate(confFile, outFileName)
+ }
+ }
+
def generate(confFile: String, outFileName: String): String = {
val config = new Properties()
val in = new FileInputStream(confFile)