From: Las Safin Date: Sat, 18 Sep 2021 20:09:45 +0000 (+0000) Subject: Litex work X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7992b4c965edce3c4709efc014528d99d549502a;p=soc.git Litex work --- diff --git a/flake.lock b/flake.lock index 0fd76ec0..adb20696 100644 --- a/flake.lock +++ b/flake.lock @@ -19,16 +19,17 @@ "nix-litex": { "flake": false, "locked": { - "lastModified": 1631733568, - "narHash": "sha256-2w63+QxzZS1jX9GXDhXFEIL1C9JcdJUlZ12Sg4GGiZ0=", - "owner": "L-as", - "repo": "tock-litex", - "rev": "46910f86e5610795efe9a9aa71a25592df429c6b", + "lastModified": 1631995585, + "narHash": "sha256-DOkmQo/Y7Oorhj4ayNZpzL/HDNPiZnaqssAHwLEv3F4=", + "owner": "lschuermann", + "repo": "nix-litex", + "rev": "032c4f53bc70a32b217aaf634ee9a1bbce43f2bb", "type": "github" }, "original": { - "owner": "L-as", - "repo": "tock-litex", + "owner": "lschuermann", + "ref": "staging", + "repo": "nix-litex", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 08e00e5f..f55427a9 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ inputs.nmigen.flake = false; inputs.nmigen-soc.url = "git+https://git.libre-soc.org/git/nmigen-soc.git"; inputs.nmigen-soc.flake = false; - inputs.nix-litex.url = "github:L-as/tock-litex"; + inputs.nix-litex.url = "github:lschuermann/nix-litex?ref=staging"; inputs.nix-litex.flake = false; outputs = { self, nixpkgs, c4m-jtag, nmigen, nmigen-soc, nix-litex }: @@ -21,14 +21,16 @@ forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + litex = pkgs: import "${nix-litex}/pkgs" { inherit pkgs; }; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; }); - litexPkgs = pkgs: import "${nix-litex}/pkgs" { inherit pkgs; }; + lib = nixpkgs.lib; in { overlay = final: prev: { python3Packages = prev.python3Packages.override { - overrides = pfinal: pprev: { + overrides = lib.composeExtensions (litex final).pythonOverlay (pfinal: pprev: { libresoc-ieee754fpu = pfinal.callPackage ./nix/ieee754fpu.nix {}; libresoc-openpower-isa = pfinal.callPackage ./nix/openpower-isa.nix {}; c4m-jtag = pfinal.callPackage (import ./nix/c4m-jtag.nix { src = c4m-jtag; version = getv c4m-jtag; }) {}; @@ -46,11 +48,11 @@ nmigen = pprev.nmigen.overrideAttrs (_: { src = nmigen; }); - }; + }); }; 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-ls180 = final.callPackage (import ./nix/ls180.nix { version = getv self; }) {}; libresoc-pinmux = final.callPackage (import ./nix/pinmux.nix { version = getv self; }) {}; }; @@ -58,7 +60,7 @@ soc = nixpkgsFor.${system}.python3Packages.libresoc-soc; pre-litex = nixpkgsFor.${system}.libresoc-pre-litex; pinmux = nixpkgsFor.${system}.libresoc-pinmux; - ilang = nixpkgsFor.${system}.libresoc-ilang; + ls180 = nixpkgsFor.${system}.libresoc-ls180; openpower-isa = nixpkgsFor.${system}.python3Packages.libresoc-openpower-isa; }); diff --git a/nix/ilang.nix b/nix/ilang.nix deleted file mode 100644 index 14099df4..00000000 --- a/nix/ilang.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ version, litexPkgs }: - -{ stdenv, python3Packages, yosys, libresoc-verilog }: - -stdenv.mkDerivation { - pname = "libresoc.il"; - inherit version; - - src = ../src/soc/litex/florent; - - strictDeps = true; - - nativeBuildInputs = (with python3Packages; [ - python migen c4m-jtag nmigen-soc python libresoc-ieee754fpu libresoc-openpower-isa - ]) ++ (with litexPkgs; [ litex litedram liteeth liteiclink litescope litesdcard ]); - - postPatch = '' - patchShebangs --build . - - export PYTHONPATH="${../src}:$PYTHONPATH" - ''; - - configurePhase = "true"; - - buildPhase = '' - runHook preBuild - cp ${libresoc-verilog} libresoc/libresoc.v - ./ls180soc.py --build --platform=ls180sram4k --num-srams=2 --srams4k - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - mkdir $out - mv build/ls180sram4k/gateware/ls180sram4k.v $out/ls180.v - mv build/ls180sram4k/gateware/mem.init $out - mv build/ls180sram4k/gateware/mem_1.init $out - mv libresoc/libresoc.v $out - mv libresoc/SPBlock_512W64B8W.v $out - runHook postInstall - ''; - - fixupPhase = "true"; -} diff --git a/nix/ls180.nix b/nix/ls180.nix new file mode 100644 index 00000000..03d1395f --- /dev/null +++ b/nix/ls180.nix @@ -0,0 +1,42 @@ +{ version }: + +{ stdenv, python3Packages, yosys, libresoc-pre-litex, libresoc-pinmux }: + +stdenv.mkDerivation { + pname = "libresoc-ls1804k"; + inherit version; + + src = ../src/soc/litex/florent; + + nativeBuildInputs = with python3Packages; [ + python libresoc-soc litex-unchecked litedram-unchecked liteeth-unchecked liteiclink-unchecked litescope-unchecked litesdcard-unchecked + ]; + + postPatch = '' + patchShebangs --build . + ''; + + configurePhase = "true"; + + buildPhase = '' + runHook preBuild + export PINMUX="$(mktemp -d)" + ln -s ${libresoc-pinmux} "$PINMUX/ls180" + cp ${libresoc-pre-litex} libresoc/libresoc.v + ./ls180soc.py --build --platform=ls180sram4k --num-srams=2 --srams4k + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir $out + mv build/ls180sram4k/gateware/ls180sram4k.v $out/ls180.v + mv build/ls180sram4k/gateware/mem.init $out + mv build/ls180sram4k/gateware/mem_1.init $out + mv libresoc/libresoc.v $out + mv libresoc/SPBlock_512W64B8W.v $out + runHook postInstall + ''; + + fixupPhase = "true"; +} diff --git a/nix/pre-litex.nix b/nix/pre-litex.nix index 7f259e33..cf405e1a 100644 --- a/nix/pre-litex.nix +++ b/nix/pre-litex.nix @@ -11,7 +11,7 @@ let script = '' --enable-xics --enable-sram4x4kblock --disable-svp64 \ $out ''; in -runCommand "libresoc-pre-litex.v" { +runCommand "libresoc-ls1804k-pre-litex.v" { inherit version; nativeBuildInputs = (with python3Packages; [