2023-12-20 16:31:43 +00:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
2023-12-23 09:27:29 +00:00
|
|
|
outputs = { self, ... }@inputs: with inputs;
|
2023-12-20 16:31:43 +00:00
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
2024-01-02 16:10:12 +00:00
|
|
|
let pkgs = nixpkgs.legacyPackages.${system}; in
|
2023-12-20 16:31:43 +00:00
|
|
|
{
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
packages = with pkgs; [
|
2023-12-22 13:49:04 +00:00
|
|
|
gtkwave
|
2024-01-01 05:29:52 +00:00
|
|
|
gdb
|
2024-01-01 06:26:46 +00:00
|
|
|
jq
|
2023-12-23 09:27:29 +00:00
|
|
|
bear
|
2024-01-01 03:09:46 +00:00
|
|
|
clang-tools
|
|
|
|
rnix-lsp
|
2024-01-02 16:10:12 +00:00
|
|
|
sbt
|
2023-12-20 16:31:43 +00:00
|
|
|
];
|
2024-01-01 03:09:46 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
2024-01-02 16:10:12 +00:00
|
|
|
verilator
|
|
|
|
gcc
|
|
|
|
python3
|
|
|
|
scala
|
|
|
|
self.packages.${system}.circt
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = with pkgs; [
|
2024-01-01 05:29:52 +00:00
|
|
|
SDL2
|
|
|
|
SDL2_image
|
2024-01-02 16:10:12 +00:00
|
|
|
jre
|
2024-01-01 03:09:46 +00:00
|
|
|
];
|
|
|
|
|
2023-12-20 16:31:43 +00:00
|
|
|
shellHook = ''
|
|
|
|
export NEMU_HOME=/home/xin/repo/ysyx-workbench/nemu
|
|
|
|
'';
|
|
|
|
};
|
2024-01-02 16:10:12 +00:00
|
|
|
|
|
|
|
# This version (1.43.0) of circt does not exist in nixpkgs
|
|
|
|
# and Chisel 5.1.0 specifically build against it, so here we are.
|
|
|
|
# Ref: https://github.com/NixOS/nixpkgs/blob/b6465c8/pkgs/development/compilers/circt/default.nix
|
|
|
|
packages.circt =
|
|
|
|
with pkgs;
|
|
|
|
let
|
|
|
|
pythonEnv = python3.withPackages (ps: [ ps.psutil ]);
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "circt";
|
|
|
|
version = "1.43.0";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "llvm";
|
|
|
|
repo = "circt";
|
|
|
|
rev = "firtool-${version}";
|
|
|
|
sha256 = "sha256-RkjigboswLkLgLkgOGahQLIygCkC3Q9rbVw3LqIzREY=";
|
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
requiredSystemFeatures = [ "big-parallel" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ninja git pythonEnv ];
|
|
|
|
|
|
|
|
cmakeDir = "../llvm/llvm";
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DLLVM_ENABLE_BINDINGS=OFF"
|
|
|
|
"-DLLVM_ENABLE_OCAMLDOC=OFF"
|
|
|
|
"-DLLVM_BUILD_EXAMPLES=OFF"
|
|
|
|
"-DLLVM_OPTIMIZED_TABLEGEN=ON"
|
|
|
|
"-DLLVM_ENABLE_PROJECTS=mlir"
|
|
|
|
"-DLLVM_EXTERNAL_PROJECTS=circt"
|
|
|
|
"-DLLVM_EXTERNAL_CIRCT_SOURCE_DIR=.."
|
|
|
|
"-DCIRCT_LLHD_SIM_ENABLED=OFF"
|
|
|
|
];
|
|
|
|
|
|
|
|
LIT_FILTER_OUT = if stdenv.cc.isClang then "CIRCT :: Target/ExportSystemC/.*\.mlir" else null;
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
find ./test -name '*.mlir' -exec sed -i 's|/usr/bin/env|${coreutils}/bin/env|g' {} \;
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin
|
|
|
|
mv bin/{{fir,hls}tool,circt-{as,dis,lsp-server,opt,reduce,translate}} $out/bin
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkTarget = "check-circt check-circt-integration";
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Circuit IR compilers and tools";
|
|
|
|
homepage = "https://circt.org/";
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ sharzy ];
|
|
|
|
platforms = lib.platforms.all;
|
|
|
|
};
|
|
|
|
};
|
2023-12-20 16:31:43 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2024-01-02 16:10:12 +00:00
|
|
|
|