Skip to content

Commit

Permalink
[nix] add vsrc build support
Browse files Browse the repository at this point in the history
  • Loading branch information
FanShupei committed Nov 3, 2024
1 parent 4e77996 commit 705d523
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
18 changes: 15 additions & 3 deletions nix/t1/conversion/sv-to-vcs-simulator.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

{ mainProgram
, rtl
, vsrc ? [ ]
, enableTrace ? false
, vcsLinkLibs ? [ ]
, topModule ? null
}:

assert lib.assertMsg (builtins.typeOf vcsLinkLibs == "list") "vcsLinkLibs should be list of strings";
Expand All @@ -22,7 +24,12 @@ stdenv.mkDerivation rec {
dontPatchELF = true;
enableCover = true;

src = rtl;
srcs = [
rtl
vsrc
];

dontUnpack = true;

vcsArgs = [
"-sverilog"
Expand All @@ -31,8 +38,13 @@ stdenv.mkDerivation rec {
"-y"
"$DWBB_DIR/sim_ver"
"+libext+.v"
"-file"
"filelist.f"
"-F"
"${rtl}/filelist.f"
]
++ vsrc
++ lib.optionals (topModule != null) [
"-top"
topModule
]
++ lib.optionals enableCover [
"-cm"
Expand Down
17 changes: 13 additions & 4 deletions nix/t1/conversion/sv-to-verilator-emulator.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

{ mainProgram
, rtl
, vsrc ? [ ]
, enableTrace ? false
, extraVerilatorArgs ? [ ]
, topModule ? null
, ...
}@overrides:

Expand All @@ -19,15 +21,19 @@ rec {

__noChroot = true;

src = rtl;
srcs = [
rtl
vsrc
];

dontUnpack = true;

nativeBuildInputs = [ verilator ];

# zlib is required for Rust to link against
propagatedBuildInputs = [ zlib ];

verilatorFilelist = "filelist.f";
verilatorTop = "TestBench";
verilatorFilelist = "${rtl}/filelist.f";
verilatorThreads = 8;
verilatorArgs = [
"--cc"
Expand All @@ -44,8 +50,11 @@ rec {
"-Wno-lint"
"-F"
verilatorFilelist
]
++ vsrc
++ lib.optionals (topModule != null) [
"--top"
verilatorTop
topModule
]
++ extraVerilatorArgs
++ lib.optionals enableTrace [
Expand Down
8 changes: 8 additions & 0 deletions nix/t1/t1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ lib.mapAttrs

verilator-emu = t1Scope.sv-to-verilator-emulator {
mainProgram = "${topName}-verilated-simulator";
topModule = "TestBench";
rtl = innerMostScope.rtl;
vsrc = [ ../../${topName}/vsrc/ClockGen.sv ];
extraVerilatorArgs = [ "${innerMostScope.verilator-dpi-lib}/lib/libdpi_${topName}.a" ];
};
verilator-emu-trace = t1Scope.sv-to-verilator-emulator {
mainProgram = "${topName}-verilated-trace-simulator";
topModule = "TestBench";
rtl = innerMostScope.rtl;
vsrc = [ ../../${topName}/vsrc/ClockGen.sv ];
enableTrace = true;
extraVerilatorArgs = [ "${innerMostScope.verilator-dpi-lib-trace}/lib/libdpi_${topName}.a" ];
};
Expand All @@ -139,12 +143,16 @@ lib.mapAttrs

vcs-emu = t1Scope.sv-to-vcs-simulator {
mainProgram = "${topName}-vcs-simulator";
topModule = "TestBench";
rtl = innerMostScope.rtl;
vsrc = [ ../../${topName}/vsrc/ClockGen.sv ];
vcsLinkLibs = [ "${innerMostScope.vcs-dpi-lib}/lib/libdpi_${topName}.a" ];
};
vcs-emu-trace = t1Scope.sv-to-vcs-simulator {
mainProgram = "${topName}-vcs-trace-simulator";
topModule = "TestBench";
rtl = innerMostScope.rtl;
vsrc = [ ../../${topName}/vsrc/ClockGen.sv ];
enableTrace = true;
vcsLinkLibs = [ "${innerMostScope.vcs-dpi-lib-trace}/lib/libdpi_${topName}.a" ];
};
Expand Down

0 comments on commit 705d523

Please sign in to comment.