Litex work
authorLas Safin <me@las.rs>
Sat, 18 Sep 2021 20:09:45 +0000 (20:09 +0000)
committerLas Safin <me@las.rs>
Sat, 18 Sep 2021 20:09:45 +0000 (20:09 +0000)
flake.lock
flake.nix
nix/ilang.nix [deleted file]
nix/ls180.nix [new file with mode: 0644]
nix/pre-litex.nix

index 0fd76ec07b1f8f640f89e0e9a68a00d088446ef7..adb206962b55da9708ca3c6e840783083ce6e914 100644 (file)
     "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"
       }
     },
index 08e00e5f3278a29b1ac40747576fd5e3e4f61534..f55427a9ec0e488a3e33e32ef6ee8f249df05cf5 100644 (file)
--- 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 }:
 
       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; }) {};
             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 (file)
index 14099df..0000000
+++ /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 (file)
index 0000000..03d1395
--- /dev/null
@@ -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";
+}
index 7f259e33f4902c7b31dd0b17e2ed4b77fc43e1e6..cf405e1a3a010617f88fb0e9454506b64cde3584 100644 (file)
@@ -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; [