Skip to content

Commit

Permalink
[nix] refactor whole test attribute under emulator
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Aug 13, 2024
1 parent 7fbe2de commit b31aa6a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
13 changes: 6 additions & 7 deletions script/ci/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ object Main:

val testAttr = testType.toLowerCase() match
case "verilator" =>
s".#t1.$config.ip.cases.$caseName.emu-result.verilator-check"
case "vcs" => s".#t1.$config.ip.cases.$caseName.emu-result.vcs-check"
case "t1rocket" => s".#t1.t1rocketemu.cases.$caseName.emu-result.t1rocket-check"
s".#t1.$config.ip.verilator-emu.cases.$caseName.emu-result"
case "vcs" => s".#t1.$config.ip.vcs-emu.cases.$caseName.emu-result"
case _ => Logger.fatal(s"Invalid test type ${testType}")
val testResultPath =
try
Expand All @@ -187,7 +186,7 @@ object Main:
os.read(testResultPath / "offline-check-status").trim() == "0"
if !testSuccess then
Logger.error(s"Offline check FAILED for $caseName ($config)")
allFailedTest :+ s"t1.$config.ip.cases.$caseName"
allFailedTest :+ testAttr
else
Logger.info(s"Offline check PASS for $caseName ($config)")
allFailedTest
Expand Down Expand Up @@ -269,8 +268,8 @@ object Main:
Logger.info("Fetching CI results")
val resultAttr = emuType.toLowerCase() match
case "verilator" =>
s".#t1.$config.ip.cases._allEmuResult"
case "vcs" => s".#t1.$config.ip.cases._allVCSEmuResult"
s".#t1.$config.verilator-emu.ip.verilator-emu.cases._allEmuResult"
case "vcs" => s".#t1.$config.vcs-emu.ip.cases.vcs-emu._allVCSEmuResult"
case _ => Logger.fatal(s"Invalid test type ${emuType}")
val emuResultPath = os.Path(nixResolvePath(
resultAttr,
Expand Down Expand Up @@ -360,7 +359,7 @@ object Main:

import scala.util.chaining._
val testPlans: Seq[String] = emulatorConfigs.flatMap: configName =>
val allCasesPath = nixResolvePath(s".#t1.$configName.ip.cases._all")
val allCasesPath = nixResolvePath(s".#t1.$configName.verilator-emu.ip.cases._all")
os.walk(os.Path(allCasesPath) / "configs")
.filter: path =>
path.ext == "json"
Expand Down
3 changes: 3 additions & 0 deletions t1rocketemu/nix/rtl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ stdenvNoCC.mkDerivation {
mkdir -p $out
firtool ${mlirbc} ${mfcArgs} -o $out
echo "Fixing generated filelist.f"
cp $out/filelist.f original.f
cat $out/firrtl_black_box_resource_files.f original.f > $out/filelist.f
'';
}
3 changes: 2 additions & 1 deletion t1rocketemu/nix/vcs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, bash
, stdenv
, rtl
, rtlDesignMetadata
, callPackage
, vcs-dpi-lib
, vcs-fhs-env
Expand Down Expand Up @@ -40,7 +41,7 @@ let

passthru = {
inherit (vcs-dpi-lib) enable-trace;
inherit vcs-fhs-env;
inherit vcs-fhs-env rtlDesignMetadata;

cases = callPackage ../../tests {
configName = "t1rocket";
Expand Down
19 changes: 1 addition & 18 deletions t1rocketemu/nix/verilated-c-lib.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
{ lib
, fetchgit
, stdenv
, rtl
, verilator
, enable-trace ? true
, zlib
}:

let
rocket-chip-v-src = fetchgit {
url = "https://github.com/chipsalliance/rocket-chip.git";
rev = "833385404d9c722bdfad3e453c19a3ac6f40dbf0";
fetchSubmodules = false;
sparseCheckout = [
"src/main/resources/vsrc"
];
hash = "sha256-CUq9VDwb7ZtclosgOWfDZMOpH+U/yBjL5CNiXZRiB80=";
};
in
stdenv.mkDerivation {
name = "t1rocket-verilated";

Expand All @@ -27,22 +15,17 @@ stdenv.mkDerivation {

propagatedBuildInputs = [ zlib ];

env.rocketChipVSrc = "${rocket-chip-v-src}/src/main/resources/vsrc/";

buildPhase = ''
runHook preBuild
echo "[nix] running verilator"
# FIXME: fix all the warning and remove -Wno-<msg> flag here
verilator \
-I"$rocketChipVSrc" \
${lib.optionalString enable-trace "--trace-fst"} \
--timing \
--threads 8 \
--threads-max-mtasks 8000 \
-O1 \
-Wno-WIDTHEXPAND \
-Wno-LATCH \
--cc TestBench
echo "[nix] building verilated C lib"
Expand All @@ -63,7 +46,7 @@ stdenv.mkDerivation {
hardeningDisable = [ "fortify" ];

passthru = {
inherit enable-trace rocket-chip-v-src;
inherit enable-trace;
};

installPhase = ''
Expand Down

0 comments on commit b31aa6a

Please sign in to comment.