Skip to content

Commit

Permalink
Created a reproducible simulation build
Browse files Browse the repository at this point in the history
Signed-off-by: Hugo McNally <[email protected]>
  • Loading branch information
HU90m committed Feb 14, 2024
1 parent aa46e0b commit 25b1e43
Show file tree
Hide file tree
Showing 2 changed files with 222 additions and 0 deletions.
174 changes: 174 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
description = "Sonata System";
inputs = {
lowrisc-nix.url = "github:lowRISC/lowrisc-nix";
nixpkgs.follows = "lowrisc-nix/nixpkgs";
flake-utils.follows = "lowrisc-nix/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
lowrisc-nix,
}: let
system_outputs = system: let
sonata_version = "0.0.1";

pkgs = import nixpkgs {
inherit system;
};
lr_pkgs = lowrisc-nix.outputs.packages.${system};

sonata-simulator = pkgs.stdenv.mkDerivation {
pname = "sonata-system-simulator";
version = sonata_version;
src = ./.;
buildInputs = with pkgs; [libelf zlib];
nativeBuildInputs = [pkgs.python311Packages.pip] ++ (with lr_pkgs; [python_ot verilator_ot]);
buildPhase = ''
HOME=$TMPDIR fusesoc --cores-root=. run \
--target=sim --tool=verilator --setup \
--build lowrisc:sonata:system
'';
installPhase = ''
mkdir -p $out/bin/
cp -r build/lowrisc_sonata_system_0/sim-verilator/Vsonata_system $out/bin/
'';
};
in {
formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell {
name = "sonata-system-devshell";
packages = [pkgs.gtkwave] ++ (with sonata-simulator; buildInputs ++ nativeBuildInputs);
};
packages = {inherit sonata-simulator;};
};
in
flake-utils.lib.eachDefaultSystem system_outputs;
}

0 comments on commit 25b1e43

Please sign in to comment.