From 7992b4c965edce3c4709efc014528d99d549502a Mon Sep 17 00:00:00 2001 From: Las Safin Date: Sat, 18 Sep 2021 20:09:45 +0000 Subject: [PATCH] Litex work --- flake.lock | 15 ++++++++------- flake.nix | 14 ++++++++------ nix/{ilang.nix => ls180.nix} | 20 +++++++++----------- nix/pre-litex.nix | 2 +- 4 files changed, 26 insertions(+), 25 deletions(-) rename nix/{ilang.nix => ls180.nix} (59%) 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/ls180.nix similarity index 59% rename from nix/ilang.nix rename to nix/ls180.nix index 14099df4..03d1395f 100644 --- a/nix/ilang.nix +++ b/nix/ls180.nix @@ -1,30 +1,28 @@ -{ version, litexPkgs }: +{ version }: -{ stdenv, python3Packages, yosys, libresoc-verilog }: +{ stdenv, python3Packages, yosys, libresoc-pre-litex, libresoc-pinmux }: stdenv.mkDerivation { - pname = "libresoc.il"; + pname = "libresoc-ls1804k"; 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 ]); + nativeBuildInputs = with python3Packages; [ + python libresoc-soc litex-unchecked litedram-unchecked liteeth-unchecked liteiclink-unchecked litescope-unchecked litesdcard-unchecked + ]; postPatch = '' patchShebangs --build . - - export PYTHONPATH="${../src}:$PYTHONPATH" ''; configurePhase = "true"; buildPhase = '' runHook preBuild - cp ${libresoc-verilog} libresoc/libresoc.v + 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 ''; 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; [ -- 2.30.2