From c58a94fe64f056eb82c7db029a701b1f06f2a17d Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Fri, 19 Jan 2024 15:15:25 +0000 Subject: [PATCH] cheriot-sim: init --- pkgs/cheriot-sim.nix | 65 ++++++++++++++++++++++++++++++++++++++++++++ pkgs/default.nix | 4 ++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 pkgs/cheriot-sim.nix diff --git a/pkgs/cheriot-sim.nix b/pkgs/cheriot-sim.nix new file mode 100644 index 0000000..05fcd50 --- /dev/null +++ b/pkgs/cheriot-sim.nix @@ -0,0 +1,65 @@ +# Copyright lowRISC contributors. +# +# SPDX-License-Identifier: MIT +{ + pkgs, + lib, + fetchFromGitHub, + stdenv, + zlib, + gmp, + ocaml, + ocamlPackages, + pkg-config, + gnumake, + z3, +}: +stdenv.mkDerivation rec { + pname = "cheriot-sim"; + version = "e5038a0"; + + src = fetchFromGitHub { + owner = "microsoft"; + repo = "cheriot-sail"; + rev = "e5038a0ec5fcdf2f672d0a7ddf8446225fd86cf7"; + fetchSubmodules = true; + hash = "sha256-umMN2ktOeV2Queocgi8qlYO464v/98+uTgbCkO9yLBA="; + }; + + buildInputs = [ + zlib + gmp + ]; + + nativeBuildInputs = [ + ocaml + pkg-config + gnumake + z3 + ]; + + postPatch = '' + for file in riscv_patches/*.patch; do + (cd sail-riscv; patch -p1 < "../$file") + done + ''; + + makeFlags = [ + "SAIL=${ocamlPackages.sail}/bin/sail" + "SAIL_DIR=${ocamlPackages.sail}/share/sail" + "LEM_DIR=${ocamlPackages.lem}/share/lem" + "csim" + ]; + + installPhase = '' + mkdir -p $out/bin + cp c_emulator/cheriot_sim $out/bin/ + ''; + + meta = { + description = "Simulator built from the sail code model of the CHERIoT ISA"; + homepage = "https://github.com/microsoft/cheriot-sail"; + license = lib.licenses.bsd2; + mainProgram = "cheriot_sim"; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index f504b33..0a83d7c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -12,9 +12,11 @@ verilator_ot = import ./verilator {inherit pkgs;}; python_ot = pkgs.callPackage ./python_ot {inherit inputs;}; bazel_ot = pkgs.callPackage ./bazel_ot {}; - llvm_cheriot = pkgs.callPackage ./llvm_cheriot.nix {}; ibex-cosim = pkgs.callPackage ./ibex-cosim.nix {}; + + llvm_cheriot = pkgs.callPackage ./llvm_cheriot.nix {}; xmake = import ./xmake.nix {inherit pkgs;}; + cheriot-sim = pkgs.callPackage ./cheriot-sim.nix {}; } // pkgs.lib.optionalAttrs (pkgs.system == "x86_64-linux") { lowrisc-toolchain-gcc-rv32imcb = pkgs.callPackage ./lowrisc-toolchain-gcc-rv32imcb.nix {};