2024-02-29 20:09:43 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, dtc, pkgsCross }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "spike";
|
2022-04-03 18:54:34 +00:00
|
|
|
version = "1.1.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "riscv";
|
|
|
|
repo = "riscv-isa-sim";
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
2022-04-03 18:54:34 +00:00
|
|
|
sha256 = "sha256-4D2Fezej0ioOOupw3kgMT5VLs+/jXQjwvek6v0AVMzI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fesvr-fix-compilation-with-gcc-13.patch";
|
|
|
|
url = "https://github.com/riscv-software-src/riscv-isa-sim/commit/0a7bb5403d0290cea8b2356179d92e4c61ffd51d.patch";
|
|
|
|
hash = "sha256-JUMTbGawvLkoOWKkruzLzUFQytVR3wqTlGu/eegRFEE=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ dtc ];
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-03-15 08:37:03 +00:00
|
|
|
postPatch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
patchShebangs scripts/*.sh
|
|
|
|
patchShebangs tests/ebreak.py
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# To test whether spike is working, we run the RISC-V hello applications using the RISC-V proxy
|
|
|
|
# kernel on the Spike emulator and see whether we get the expected output.
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase =
|
|
|
|
let
|
2022-01-03 16:56:52 +00:00
|
|
|
riscvPkgs = pkgsCross.riscv64-embedded;
|
2021-12-06 16:07:01 +00:00
|
|
|
in
|
|
|
|
''
|
|
|
|
runHook preInstallCheck
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
echo -e "#include<stdio.h>\nint main() {printf(\"Hello, world\");return 0;}" > hello.c
|
2023-08-10 07:59:29 +00:00
|
|
|
${riscvPkgs.stdenv.cc}/bin/${riscvPkgs.stdenv.cc.targetPrefix}cc -o hello hello.c
|
2022-04-03 18:54:34 +00:00
|
|
|
$out/bin/spike -m64 ${riscvPkgs.riscv-pk}/bin/pk hello | grep -Fq "Hello, world"
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "RISC-V ISA Simulator";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/riscv/riscv-isa-sim";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
|
|
|
maintainers = with maintainers; [ blitz ];
|
|
|
|
};
|
|
|
|
}
|