From: Las Safin Date: Thu, 16 Sep 2021 13:21:56 +0000 (+0000) Subject: Split up into several derivations X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=34310e5a448092d843ec33e853d14f45b3c46486;p=soc.git Split up into several derivations --- diff --git a/flake.nix b/flake.nix index 60314d1a..08e00e5f 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,7 @@ bigfloat = pfinal.callPackage ./nix/bigfloat.nix {}; modgrammar = pfinal.callPackage ./nix/modgrammar.nix {}; libresoc-nmutil = pfinal.callPackage ./nix/nmutil.nix {}; + libresoc-soc = pfinal.callPackage (import ./nix/soc.nix { version = getv self; }) {}; nmigen-soc = pprev.nmigen-soc.overrideAttrs (_: { doCheck = false; @@ -48,16 +49,19 @@ }; }; - libresoc-verilog = final.callPackage (import ./nix/verilog.nix { version = getv self; }) {}; + libresoc-pre-litex = final.callPackage (import ./nix/pre-litex.nix { version = getv self; }) {}; libresoc-ilang = final.callPackage (import ./nix/ilang.nix { version = getv self; litexPkgs = litexPkgs final; }) {}; + libresoc-pinmux = final.callPackage (import ./nix/pinmux.nix { version = getv self; }) {}; }; packages = forAllSystems (system: { - verilog = nixpkgsFor.${system}.libresoc-verilog; + soc = nixpkgsFor.${system}.python3Packages.libresoc-soc; + pre-litex = nixpkgsFor.${system}.libresoc-pre-litex; + pinmux = nixpkgsFor.${system}.libresoc-pinmux; ilang = nixpkgsFor.${system}.libresoc-ilang; openpower-isa = nixpkgsFor.${system}.python3Packages.libresoc-openpower-isa; }); - defaultPackage = forAllSystems (system: self.packages.${system}.verilog); + defaultPackage = forAllSystems (system: self.packages.${system}.pre-litex); }; } diff --git a/nix/pinmux.nix b/nix/pinmux.nix new file mode 100644 index 00000000..fc9ca7e8 --- /dev/null +++ b/nix/pinmux.nix @@ -0,0 +1,28 @@ +{ version }: + +{ stdenv, python2 }: + +stdenv.mkDerivation { + pname = "libresoc-pinmux"; + inherit version; + + src = ../pinmux; + + nativeBuildInputs = [ python2 ]; + + configurePhase = "true"; + + buildPhase = '' + runHook preBuild + python src/pinmux_generator.py -v -s ls180 -o ls180 + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mv ls180 $out + runHook postInstall + ''; + + fixupPhase = "true"; +} diff --git a/nix/pre-litex.nix b/nix/pre-litex.nix new file mode 100644 index 00000000..7f259e33 --- /dev/null +++ b/nix/pre-litex.nix @@ -0,0 +1,20 @@ +{ version }: + +{ runCommand, python3Packages, libresoc-pinmux }: + +let script = '' + mkdir pinmux + ln -s ${libresoc-pinmux} pinmux/ls180 + export PINMUX="$(realpath ./pinmux)" + python3 -m soc.simple.issuer_verilog \ + --debug=jtag --enable-core --enable-pll \ + --enable-xics --enable-sram4x4kblock --disable-svp64 \ + $out +''; in +runCommand "libresoc-pre-litex.v" { + inherit version; + + nativeBuildInputs = (with python3Packages; [ + libresoc-soc + ]) ++ [ libresoc-pinmux ]; +} script diff --git a/nix/soc.nix b/nix/soc.nix index 3df35810..a4ed1368 100644 --- a/nix/soc.nix +++ b/nix/soc.nix @@ -10,8 +10,9 @@ let src = runCommand "libresoc-soc-source" {} '' mkdir $out cp -r ${../src} -T $out/src - cp -r ${../pinmux} -T $out/pinmux cp -r ${../setup.py} -T $out/setup.py + cp -r ${../README.md} -T $out/README.md + cp -r ${../NEWS.txt} -T $out/NEWS.txt ''; in buildPythonPackage { @@ -24,6 +25,10 @@ buildPythonPackage { doCheck = false; + prePatch = '' + rm -r src/soc/litex + ''; + pythonImportsCheck = [ "soc" ]; meta = with lib; { diff --git a/nix/verilog.nix b/nix/verilog.nix deleted file mode 100644 index 89bbdb83..00000000 --- a/nix/verilog.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ version }: - -{ stdenv, python3Packages, runCommand, python2, yosys }: - -let - # If we use ../. as source, then any change to - # any unrelated Nix file would cause a rebuild, - # since the build would have access to it. - src = runCommand "libresoc-verilog-source" {} '' - mkdir $out - cp -r ${../src} -T $out/src - cp -r ${../mkpinmux.sh} -T $out/mkpinmux.sh - cp -r ${../pinmux} -T $out/pinmux - cp -r ${../Makefile} -T $out/Makefile - ''; -in -stdenv.mkDerivation { - pname = "libresoc.v"; - inherit version src; - - strictDeps = true; - - nativeBuildInputs = (with python3Packages; [ - c4m-jtag nmigen-soc python libresoc-ieee754fpu libresoc-openpower-isa - ]) ++ [ yosys ]; - - configurePhase = "true"; - - buildPhase = '' - runHook preBuild - env -C pinmux ${python2}/bin/python src/pinmux_generator.py -v -s ls180 -o ls180 - cp pinmux/ls180/ls180_pins.py src/soc/debug - cp pinmux/ls180/ls180_pins.py src/soc/litex/florent/libresoc - cd src - export PYTHONPATH="$PWD:$PYTHONPATH" - python3 soc/simple/issuer_verilog.py \ - --debug=jtag --enable-core --enable-pll \ - --enable-xics --enable-sram4x4kblock --disable-svp64 \ - libresoc.v - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - mv libresoc.v $out - runHook postInstall - ''; - - fixupPhase = "true"; -} diff --git a/src/soc/config/pinouts.py b/src/soc/config/pinouts.py index a1828c6a..03cfa974 100644 --- a/src/soc/config/pinouts.py +++ b/src/soc/config/pinouts.py @@ -62,7 +62,8 @@ def load_pinouts(chipname=None): pth = os.path.split(pth)[0] # path is relative to this filename, in the pinmux submodule - fname = "%s/../../../pinmux/%s/litex_pinpads.json" % (pth, chipname) + pinmux = os.getenv("PINMUX", "%s/../../../pinmux" % pth) + fname = "%s/%s/litex_pinpads.json" % (pinmux, chipname) with open(fname) as f: txt = f.read()