2024-09-26 11:04:55 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, dtc, pkgsCross }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "spike";
|
2024-09-26 11:04:55 +00:00
|
|
|
version = "1.1.0-unstable-2024-09-21";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "riscv";
|
|
|
|
repo = "riscv-isa-sim";
|
2024-09-26 11:04:55 +00:00
|
|
|
rev = "de5094a1a901d77ff44f89b38e00fefa15d4018e";
|
|
|
|
sha256 = "sha256-mAgR2VzDgeuIdmPEgrb+MaA89BnWfmNanOVidqn0cgc=";
|
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
|
|
|
|
'';
|
|
|
|
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|