2022-04-03 18:54:34 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, 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
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
${riscvPkgs.stdenv.cc}/bin/riscv64-none-elf-gcc -o hello hello.c
|
|
|
|
$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; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A RISC-V ISA Simulator";
|
|
|
|
homepage = "https://github.com/riscv/riscv-isa-sim";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
|
|
|
maintainers = with maintainers; [ blitz ];
|
|
|
|
};
|
|
|
|
}
|