diff --git a/.github/workflows/t1rocket.yml b/.github/workflows/t1rocket.yml index d00d04f1f..3ad52649e 100644 --- a/.github/workflows/t1rocket.yml +++ b/.github/workflows/t1rocket.yml @@ -102,8 +102,24 @@ jobs: run: | nix run ".#ci-helper" -- postCI \ --case-dir t1rocket-cases \ + --cycle-update-file-path ./cycle-update.md \ --failed-tests-file-path ./failed-tests.md \ --cycle-update-file-path ./cycle-update.md \ --emu-type vcs cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY + echo >> $GITHUB_STEP_SUMMARY cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY + - name: "Commit cycle updates" + run: | + git config user.name github-actions + git config user.email github-actions@github.com + changed_cases=$(git diff --name-only '.github/**/default.json') + + if [ -n "$changed_cases" ]; then + echo "changed cases: $changed_cases" + git add '.github/**/default.json' + git commit -m "[ci] update test case cycle data" + git push origin ${{ github.head_ref }} + else + echo "No cycle change detect" + fi diff --git a/.github/workflows/vcs.yml b/.github/workflows/vcs.yml index 75751d78d..47de5fc28 100644 --- a/.github/workflows/vcs.yml +++ b/.github/workflows/vcs.yml @@ -100,6 +100,24 @@ jobs: ref: ${{ github.head_ref }} - name: "Print step summary" run: | - nix run ".#ci-helper" -- postCI --failed-tests-file-path ./failed-tests.md --emu-type vcs --cycle-update-file-path ./cycle-update.md - cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY + nix run ".#ci-helper" -- postCI \ + --cycle-update-file-path ./cycle-update.md \ + --failed-tests-file-path ./failed-tests.md \ + --emu-type vcs cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY + echo >> $GITHUB_STEP_SUMMARY + cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY + - name: "Commit cycle updates" + run: | + git config user.name github-actions + git config user.email github-actions@github.com + changed_cases=$(git diff --name-only '.github/**/default.json') + + if [ -n "$changed_cases" ]; then + echo "changed cases: $changed_cases" + git add '.github/**/default.json' + git commit -m "[ci] update test case cycle data" + git push origin ${{ github.head_ref }} + else + echo "No cycle change detect" + fi diff --git a/.github/workflows/verilator.yml b/.github/workflows/verilator.yml index 6785f7009..cfe7eb774 100644 --- a/.github/workflows/verilator.yml +++ b/.github/workflows/verilator.yml @@ -108,4 +108,19 @@ jobs: --failed-tests-file-path ./failed-tests.md \ --cycle-update-file-path ./cycle-update.md cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY + echo >> $GITHUB_STEP_SUMMARY cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY + - name: "Commit cycle updates" + run: | + git config user.name github-actions + git config user.email github-actions@github.com + changed_cases=$(git diff --name-only '.github/**/default.json') + + if [ -n "$changed_cases" ]; then + echo "changed cases: $changed_cases" + git add '.github/**/default.json' + git commit -m "[ci] update test case cycle data" + git push origin ${{ github.head_ref }} + else + echo "No cycle change detect" + fi diff --git a/nix/t1/default.nix b/nix/t1/default.nix index cc03bccc2..01c91d11c 100644 --- a/nix/t1/default.nix +++ b/nix/t1/default.nix @@ -87,7 +87,7 @@ lib.makeScope newScope # Grouped emulator packages # --------------------------------------------------------------------------------- # Nix specification for t1rocket (with rocket-chip as Scalar core) emulator - t1rocket = t1Scope.callPackage ./t1rocket { }; + t1rocket = t1Scope.callPackage ./t1rocket.nix { }; # Nix specification for rocket (rocket-chip only) emulator rocketv = t1Scope.callPackage ../../rocketemu { }; diff --git a/nix/t1/t1rocket/default.nix b/nix/t1/t1rocket.nix similarity index 97% rename from nix/t1/t1rocket/default.nix rename to nix/t1/t1rocket.nix index 15c2a82d9..1ffc9176b 100644 --- a/nix/t1/t1rocket/default.nix +++ b/nix/t1/t1rocket.nix @@ -87,12 +87,12 @@ }; vcs-emu = sv-to-vcs-simulator { - mainProgram = "t1-vcs-simulator"; + mainProgram = "t1rocket-vcs-simulator"; rtl = scope.rtl; vcsLinkLibs = [ "${scope.vcs-dpi-lib}/lib/libdpi_t1rocket.a" ]; }; vcs-emu-trace = sv-to-vcs-simulator { - mainProgram = "t1-vcs-trace-simulator"; + mainProgram = "t1rocket-vcs-trace-simulator"; rtl = scope.rtl; enableTrace = true; vcsLinkLibs = [ "${scope.vcs-dpi-lib-trace}/lib/libdpi_t1rocket.a" ]; diff --git a/nix/t1/t1rocket/verilated-c-lib.nix b/nix/t1/t1rocket/verilated-c-lib.nix deleted file mode 100644 index 97d1310fd..000000000 --- a/nix/t1/t1rocket/verilated-c-lib.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ lib -, stdenv -, rtl -, verilator -, enableTrace ? true -, zlib -}: - -stdenv.mkDerivation { - name = "t1rocket-verilated"; - - src = rtl; - - nativeBuildInputs = [ verilator ]; - - propagatedBuildInputs = [ zlib ]; - - buildPhase = '' - runHook preBuild - - echo "[nix] running verilator" - verilator \ - ${lib.optionalString enableTrace "--trace-fst"} \ - --cc \ - --timing \ - --threads 8 \ - --threads-max-mtasks 8000 \ - -O1 \ - -F filelist.f \ - --top TestBench - - echo "[nix] building verilated C lib" - - # backup srcs - mkdir -p $out/share - cp -r obj_dir $out/share/verilated_src - - rm $out/share/verilated_src/*.dat - - # We can't use -C here because VTestBench.mk is generated with relative path - cd obj_dir - make -j "$NIX_BUILD_CORES" -f VTestBench.mk libVTestBench - - runHook postBuild - ''; - - hardeningDisable = [ "fortify" ]; - - passthru = { - inherit enableTrace; - }; - - installPhase = '' - runHook preInstall - - mkdir -p $out/include $out/lib - cp *.h $out/include - cp *.a $out/lib - - runHook postInstall - ''; -} diff --git a/script/ci/src/Main.scala b/script/ci/src/Main.scala index 9a50df237..127c6d497 100644 --- a/script/ci/src/Main.scala +++ b/script/ci/src/Main.scala @@ -213,7 +213,7 @@ object Main: @arg( name = "cycle-update-file-path", doc = "specify the cycle update markdown file output path" - ) cycleUpdateFilePath: Option[String], + ) cycleUpdateFilePath: String, @arg( name = "emu-type", doc = "Specify emulation type" @@ -226,11 +226,10 @@ object Main: val failedTestsFile = os.Path(failedTestsFilePath, os.pwd) os.write.over(failedTestsFile, "## Failed Tests\n") - if cycleUpdateFilePath.nonEmpty then - os.write.over( - os.Path(cycleUpdateFilePath.get, os.pwd), - "## Cycle Update\n" - ) + os.write.over( + os.Path(cycleUpdateFilePath, os.pwd), + "## Cycle Update\n" + ) os.walk(os.pwd / ".github" / caseDir) .filter(_.last == "default.json") @@ -261,15 +260,11 @@ object Main: if cycleUpdateFilePath.nonEmpty then Logger.info("Collecting cycle update info") - val perfCycleRegex = raw"total_cycles:\s(\d+)".r val allCycleUpdates = os .walk(emuResultPath) - .filter(path => path.last == "perf.txt") + .filter(path => path.last == "perf.json") .map(path => { - val cycle = os.read.lines(path).head match - case perfCycleRegex(cycle) => cycle.toInt - case _ => - throw new Exception("perf.txt file is not format as expected") + val cycle = ujson.read(os.read(path)).obj("total_cycles").num.toInt val caseName = path.segments.toSeq.reverse.drop(1).head (caseName, cycle, cycleRecord.obj(caseName).num.toInt) }) @@ -282,7 +277,7 @@ object Main: else s"* 🐢 $caseName($config): $oldCycle -> $newCycle" os.write.append( - os.Path(cycleUpdateFilePath.get, os.pwd), + os.Path(cycleUpdateFilePath, os.pwd), allCycleUpdates.mkString("\n") + "\n" )