From edde3e3011e4f3dfe04dcd885ebc80ead3aacddd Mon Sep 17 00:00:00 2001 From: Charles Papon Date: Sun, 21 Apr 2019 02:56:44 +0200 Subject: [PATCH] Add zephyr tests --- src/main/scala/vexriscv/demo/Linux.scala | 1 + src/test/cpp/regression/main.cpp | 88 ++++++++++++++++++- src/test/cpp/regression/makefile | 14 ++- src/test/resources/VexRiscvRegressionData | 2 +- .../vexriscv/TestIndividualFeatures.scala | 8 +- 5 files changed, 103 insertions(+), 10 deletions(-) diff --git a/src/main/scala/vexriscv/demo/Linux.scala b/src/main/scala/vexriscv/demo/Linux.scala index 9b32dc9..f5bad23 100644 --- a/src/main/scala/vexriscv/demo/Linux.scala +++ b/src/main/scala/vexriscv/demo/Linux.scala @@ -122,6 +122,7 @@ cd cpio cpio -idv < ../rootfs.cpio cd .. +make clean run IBUS=CACHED DBUS=CACHED DEBUG_PLUGIN=STD DHRYSTONE=yes SUPERVISOR=yes MMU=yes CSR=yes COMPRESSED=no MUL=yes DIV=yes LRSC=yes AMO=yes REDO=10 TRACE=no COREMARK=yes LINUX_REGRESSION=yes RUN_HEX=~/pro/riscv/zephyr/samples/synchronization/build/zephyr/zephyr.hex */ diff --git a/src/test/cpp/regression/main.cpp b/src/test/cpp/regression/main.cpp index 8631351..7a170a9 100644 --- a/src/test/cpp/regression/main.cpp +++ b/src/test/cpp/regression/main.cpp @@ -1675,12 +1675,15 @@ public: *error = addr == 0xF00FFF60u; } + virtual void dutPutChar(char c){} + virtual void dBusAccess(uint32_t addr,bool wr, uint32_t size,uint32_t mask, uint32_t *data, bool *error) { if(wr){ switch(addr){ case 0xF0010000u: { cout << (char)*data; logTraces << (char)*data; + dutPutChar((char)*data); break; } #ifdef EXTERNAL_INTERRUPT @@ -1695,6 +1698,7 @@ public: case 0xF00FFF00u: { cout << (char)*data; logTraces << (char)*data; + dutPutChar((char)*data); break; } #ifndef DEBUG_PLUGIN_EXTERNAL @@ -1755,6 +1759,34 @@ public: }; + +class ZephyrRegression : public WorkspaceRegression{ +public: + + + uint32_t regFileWriteRefIndex = 0; + char *target = "PROJECT EXECUTION SUCCESSFUL", *hit = target; + + ZephyrRegression(string name) : WorkspaceRegression(name) { + cout << endl << endl; + + } + + virtual void dutPutChar(char c){ + if(*hit == c) hit++; else hit = target; + if(*hit == NULL) { + cout << endl << "T=" << i <loadHex("../../resources/freertos/" + name + "_rv32i_O0.hex")->bootAt(0x80000000u)->run(4e6*15);}); tasks.push_back([=]() { WorkspaceRegression(name + "_rv32i_O3").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32i_O3.hex")->bootAt(0x80000000u)->run(4e6*15);}); #ifdef COMPRESSED -// tasks.push_back([=]() { Workspace(name + "_rv32ic_O0").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32ic_O0.hex")->bootAt(0x80000000u)->run(5e6*15);}); - tasks.push_back([=]() { Workspace(name + "_rv32ic_O3").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32ic_O3.hex")->bootAt(0x80000000u)->run(4e6*15);}); +// tasks.push_back([=]() { WorkspaceRegression(name + "_rv32ic_O0").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32ic_O0.hex")->bootAt(0x80000000u)->run(5e6*15);}); + tasks.push_back([=]() { WorkspaceRegression(name + "_rv32ic_O3").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32ic_O3.hex")->bootAt(0x80000000u)->run(4e6*15);}); #endif #if defined(MUL) && defined(DIV) // #ifdef COMPRESSED -// tasks.push_back([=]() { Workspace(name + "_rv32imac_O3").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32imac_O3.hex")->bootAt(0x80000000u)->run(4e6*15);}); +// tasks.push_back([=]() { WorkspaceRegression(name + "_rv32imac_O3").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32imac_O3.hex")->bootAt(0x80000000u)->run(4e6*15);}); // #else - tasks.push_back([=]() { Workspace(name + "_rv32im_O3").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32im_O3.hex")->bootAt(0x80000000u)->run(4e6*15);}); + tasks.push_back([=]() { WorkspaceRegression(name + "_rv32im_O3").withRiscvRef()->loadHex("../../resources/freertos/" + name + "_rv32im_O3.hex")->bootAt(0x80000000u)->run(4e6*15);}); // #endif #endif } @@ -3788,8 +3836,40 @@ int main(int argc, char **argv, char **env) { queue > tasksSelected(std::deque>(tasks.begin(), tasks.end())); multiThreadedExecute(tasksSelected); + } #endif + #ifdef ZEPHYR + { + #ifdef SEED + srand48(SEED); + #endif + //redo(1,WorkspaceRegression("freeRTOS_demo").loadHex("../../resources/hex/freeRTOS_demo.hex")->bootAt(0x80000000u)->run(100e6);) + vector > tasks; + + /*for(int redo = 0;redo < 4;redo++)*/{ + for(const string &name : zephyrTests){ + #ifdef COMPRESSED + tasks.push_back([=]() { ZephyrRegression(name + "_rv32ic").withRiscvRef()->loadHex("../../resources/VexRiscvRegressionData/sim/zephyr/" + name + "_rv32ic.hex")->bootAt(0x80000000u)->run(180e6);}); + #else + tasks.push_back([=]() { ZephyrRegression(name + "_rv32i").withRiscvRef()->loadHex("../../resources/VexRiscvRegressionData/sim/zephyr/" + name + "_rv32i.hex")->bootAt(0x80000000u)->run(180e6);}); + #endif + #if defined(MUL) && defined(DIV) + tasks.push_back([=]() { ZephyrRegression(name + "_rv32im").withRiscvRef()->loadHex("../../resources/VexRiscvRegressionData/sim/zephyr/" + name + "_rv32im.hex")->bootAt(0x80000000u)->run(180e6);}); + #endif + } + } + + while(tasks.size() > ZEPHYR_COUNT){ + tasks.erase(tasks.begin() + (VL_RANDOM_I(32)%tasks.size())); + } + + + queue > tasksSelected(std::deque>(tasks.begin(), tasks.end())); + multiThreadedExecute(tasksSelected); + } + #endif + #if defined(LINUX_REGRESSION) { diff --git a/src/test/cpp/regression/makefile b/src/test/cpp/regression/makefile index 9c4294f..9b0418b 100644 --- a/src/test/cpp/regression/makefile +++ b/src/test/cpp/regression/makefile @@ -23,7 +23,8 @@ RUN_HEX=no CUSTOM_SIMD_ADD?=no CUSTOM_CSR?=no DHRYSTONE=yes -FREERTOS=no +FREERTOS?=no +ZEPHYR?=no REDO?=10 REF=no TRACE_WITH_TIME=no @@ -241,6 +242,17 @@ ifneq ($(FREERTOS),no) endif endif + +ifeq ($(ZEPHYR),yes) + ADDCFLAGS += -CFLAGS -DZEPHYR + ADDCFLAGS += -CFLAGS -DZEPHYR_COUNT=99999 +else +ifneq ($(ZEPHYR),no) + ADDCFLAGS += -CFLAGS -DZEPHYR + ADDCFLAGS += -CFLAGS -DZEPHYR_COUNT=$(ZEPHYR) +endif +endif + all: clean run run: compile diff --git a/src/test/resources/VexRiscvRegressionData b/src/test/resources/VexRiscvRegressionData index 77b66d3..f9dff46 160000 --- a/src/test/resources/VexRiscvRegressionData +++ b/src/test/resources/VexRiscvRegressionData @@ -1 +1 @@ -Subproject commit 77b66d304f888369176fb9ac2f9d6302dd4d276d +Subproject commit f9dff4688dea851f41892a3f88cae8d1e513cc93 diff --git a/src/test/scala/vexriscv/TestIndividualFeatures.scala b/src/test/scala/vexriscv/TestIndividualFeatures.scala index 65bbfcd..ee933a9 100644 --- a/src/test/scala/vexriscv/TestIndividualFeatures.scala +++ b/src/test/scala/vexriscv/TestIndividualFeatures.scala @@ -434,13 +434,13 @@ class MmuDimension extends VexRiscvDimension("DBus") { trait CatchAllPosition -class CsrDimension(freertos : String) extends VexRiscvDimension("Csr") { +class CsrDimension(freertos : String, zephyr : String) extends VexRiscvDimension("Csr") { override def randomPositionImpl(universes: Seq[ConfigUniverse], r: Random) = { val catchAll = universes.contains(VexRiscvUniverse.CATCH_ALL) if(catchAll){ new VexRiscvPosition("All") with CatchAllPosition{ override def applyOn(config: VexRiscvConfig): Unit = config.plugins += new CsrPlugin(CsrPluginConfig.linuxFull(0x80000020l)) - override def testParam = s"FREERTOS=$freertos LINUX_REGRESSION=yes SUPERVISOR=yes" + override def testParam = s"FREERTOS=$freertos ZEPHYR=$zephyr LINUX_REGRESSION=yes SUPERVISOR=yes" } } else if(r.nextDouble() < 0.2){ new VexRiscvPosition("AllNoException") with CatchAllPosition{ @@ -516,7 +516,7 @@ class TestIndividualFeatures extends FunSuite { new HazardDimension, new RegFileDimension, new SrcDimension, - new CsrDimension("no"),//sys.env.getOrElse("VEXRISCV_REGRESSION_FREERTOS_COUNT", "4")), TODO + new CsrDimension("no", sys.env.getOrElse("VEXRISCV_REGRESSION_ZEPHYR_COUNT", "4")),//sys.env.getOrElse("VEXRISCV_REGRESSION_FREERTOS_COUNT", "4")), TODO new DecoderDimension, new DebugDimension, new MmuDimension @@ -554,7 +554,7 @@ class TestIndividualFeatures extends FunSuite { test(prefix + name + "_test") { val debug = true - val stdCmd = (s"make clean run WITH_USER_IO=no REDO=10 TRACE=${if(debug) "yes" else "no"} TRACE_START=9999924910246l FLOW_INFO=no STOP_ON_ERROR=no DHRYSTONE=yes COREMARK=yes THREAD_COUNT=${sys.env.getOrElse("VEXRISCV_REGRESSION_THREAD_COUNT", Runtime.getRuntime().availableProcessors().toString)} ") + s" SEED=${testSeed} " + val stdCmd = (s"make clean run WITH_USER_IO=no REDO=10 TRACE=${if(debug) "yes" else "no"} TRACE_START=9999924910246l FLOW_INFO=no STOP_ON_ERROR=no DHRYSTONE=yes COREMARK=yes THREAD_COUNT=${sys.env.getOrElse("VEXRISCV_REGRESSION_THREAD_COUNT", 1)} ") + s" SEED=${testSeed} " // val stdCmd = "make clean run REDO=40 DHRYSTONE=no STOP_ON_ERROR=yes TRACE=yess " val testCmd = stdCmd + (positionsToApply).map(_.testParam).mkString(" ")