Skip to content

Commit

Permalink
cheriot-sim: init
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 authored and HU90m committed Jan 23, 2024
1 parent 89a453c commit c58a94f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
65 changes: 65 additions & 0 deletions pkgs/cheriot-sim.nix
Original file line number Diff line number Diff line change
@@ -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";
};
}
4 changes: 3 additions & 1 deletion pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down

0 comments on commit c58a94f

Please sign in to comment.