From eb9c99b0fd94f7ea3e97f351044d522ef83c2d40 Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Wed, 3 Jan 2024 00:10:12 +0800 Subject: [PATCH] =?UTF-8?q?>=20nvboard=20ysyx=5F22040000=20=E6=9D=8E?= =?UTF-8?q?=E5=BF=83=E6=9D=A8=20Linux=20calcite=206.1.69=20#1-NixOS=20SMP?= =?UTF-8?q?=20PREEMPT=5FDYNAMIC=20Wed=20Dec=2020=2016:00:29=20UTC=202023?= =?UTF-8?q?=20x86=5F64=20GNU/Linux=20=2000:10:12=20=20up=202=20days=20=208?= =?UTF-8?q?:49,=20=202=20users,=20=20load=20average:=200.43,=200.56,=200.4?= =?UTF-8?q?9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- npc/.gitignore | 6 ++++ npc/Makefile | 1 - npc/build.sbt | 22 +++++++++++++++ npc/flake.nix | 76 +++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 npc/build.sbt diff --git a/npc/.gitignore b/npc/.gitignore index 7040bf9..27545c4 100644 --- a/npc/.gitignore +++ b/npc/.gitignore @@ -10,3 +10,9 @@ !.gitignore !README.md build/ + +*.class +*.log + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/npc/Makefile b/npc/Makefile index 1f78dc1..ee02342 100644 --- a/npc/Makefile +++ b/npc/Makefile @@ -61,7 +61,6 @@ sim: sim-bin git_trace_sim @echo "================================" @$(OBJDIR)/Vexample - compile_commands.json: clean bear --output nvboard.json -- $(MAKE) nvboard-bin bear --output all.json -- $(MAKE) sim-bin diff --git a/npc/build.sbt b/npc/build.sbt new file mode 100644 index 0000000..792a764 --- /dev/null +++ b/npc/build.sbt @@ -0,0 +1,22 @@ +ThisBuild / scalaVersion := "2.13.12" +ThisBuild / version := "0.1.0" + + +val chiselVersion = "5.1.0" + +lazy val root = (project in file(".")) + .settings( + name := "ChiselLearning", + libraryDependencies ++= Seq( + "org.chipsalliance" %% "chisel" % chiselVersion, + "edu.berkeley.cs" %% "chiseltest" % "5.0.2" % "test" + ), + scalacOptions ++= Seq( + "-language:reflectiveCalls", + "-deprecation", + "-feature", + "-Xcheckinit", + "-Ymacro-annotations", + ), + addCompilerPlugin("org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full), + ) \ No newline at end of file diff --git a/npc/flake.nix b/npc/flake.nix index 3eae8b3..42348c3 100644 --- a/npc/flake.nix +++ b/npc/flake.nix @@ -6,30 +6,98 @@ outputs = { self, ... }@inputs: with inputs; flake-utils.lib.eachDefaultSystem (system: - let pkgs = nixpkgs.legacyPackages.${system}; in + let pkgs = nixpkgs.legacyPackages.${system}; in { devShells.default = pkgs.mkShell { packages = with pkgs; [ - verilator gtkwave - gcc gdb jq bear clang-tools rnix-lsp + sbt ]; nativeBuildInputs = with pkgs; [ + verilator + gcc + python3 + scala + self.packages.${system}.circt + ]; + + buildInputs = with pkgs; [ SDL2 SDL2_image - python3 + jre ]; shellHook = '' export NEMU_HOME=/home/xin/repo/ysyx-workbench/nemu ''; }; + + # 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; + }; + }; } ); } +