generated from saji/ecp5-template
Compare commits
3 commits
20b16b6d40
...
0d2719c39f
Author | SHA1 | Date | |
---|---|---|---|
saji | 0d2719c39f | ||
saji | 63811b929a | ||
saji | 3188fdefa5 |
33
flake.lock
33
flake.lock
|
@ -1,5 +1,22 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1726560853,
|
||||||
|
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "flake-utils",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1723637854,
|
"lastModified": 1723637854,
|
||||||
|
@ -18,8 +35,24 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
27
flake.nix
27
flake.nix
|
@ -5,17 +5,9 @@
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ nixpkgs, ... }:
|
outputs = inputs@{ nixpkgs, flake-utils, ... }:
|
||||||
let
|
let
|
||||||
# litex-overlay = final: prev: {
|
python-overlay = import ./python.nix;
|
||||||
# pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
|
|
||||||
# (python-final: python-prev: {
|
|
||||||
# litex = python-final.callPackage (import ./litex.nix) { };
|
|
||||||
# # can add more packages here!
|
|
||||||
# })
|
|
||||||
# ];
|
|
||||||
# };
|
|
||||||
litex-overlay = import ./litex;
|
|
||||||
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
|
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
|
||||||
forAllSystems = function:
|
forAllSystems = function:
|
||||||
nixpkgs.lib.genAttrs systems (system: function (
|
nixpkgs.lib.genAttrs systems (system: function (
|
||||||
|
@ -23,38 +15,31 @@
|
||||||
inherit system;
|
inherit system;
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
overlays = [
|
overlays = [
|
||||||
]; # patches, version pins, new pkgs here.
|
python-overlay
|
||||||
|
];
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
in {
|
in {
|
||||||
packages = forAllSystems (pkgs: {
|
packages = forAllSystems (pkgs: {
|
||||||
sim = import ./sim/package.nix pkgs;
|
sim = import ./sim/package.nix pkgs;
|
||||||
|
|
||||||
});
|
});
|
||||||
devShells = forAllSystems (pkgs: {
|
devShells = forAllSystems (pkgs: {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
(python3.withPackages (ps: with ps; [
|
(python3.withPackages (ps: with ps; [
|
||||||
cocotb
|
|
||||||
amaranth
|
amaranth
|
||||||
]))
|
]))
|
||||||
yosys
|
yosys
|
||||||
nextpnr
|
nextpnr
|
||||||
pkgsCross.riscv64.buildPackages.gcc
|
|
||||||
gnumake
|
|
||||||
wishbone-tool
|
|
||||||
# simulators
|
# simulators
|
||||||
verilog
|
iverilog
|
||||||
verilator
|
verilator
|
||||||
# support package
|
# support package
|
||||||
trellis
|
trellis
|
||||||
# loader
|
# loader
|
||||||
openfpgaloader
|
openfpgaloader
|
||||||
ecpdap # easier to poke probes.
|
ecpdap # easier to poke probes.
|
||||||
|
|
||||||
# for building the simulator
|
|
||||||
cmake
|
|
||||||
ninja
|
|
||||||
mdbook
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
13
pdm.lock
13
pdm.lock
|
@ -5,7 +5,7 @@
|
||||||
groups = ["default", "dev"]
|
groups = ["default", "dev"]
|
||||||
strategy = ["inherit_metadata"]
|
strategy = ["inherit_metadata"]
|
||||||
lock_version = "4.5.0"
|
lock_version = "4.5.0"
|
||||||
content_hash = "sha256:00a75da930aaa4d4233631525c1b6bb3c9642e99065be33cf83e74d4ad611d08"
|
content_hash = "sha256:fbfe1db54d73aa2641413610d5e62d87b02de247293e2af3cd53ee0c283318db"
|
||||||
|
|
||||||
[[metadata.targets]]
|
[[metadata.targets]]
|
||||||
requires_python = "==3.12.*"
|
requires_python = "==3.12.*"
|
||||||
|
@ -29,11 +29,14 @@ files = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "amaranth-boards"
|
name = "amaranth-boards"
|
||||||
version = "0"
|
version = "0.1.dev250"
|
||||||
summary = "Placeholder package name reserved for Amaranth HDL"
|
requires_python = "~=3.8"
|
||||||
|
git = "https://github.com/amaranth-lang/amaranth-boards.git"
|
||||||
|
revision = "19b97324ecf9111c5d16377af79f82aad761c476"
|
||||||
|
summary = "Board and connector definitions for Amaranth HDL"
|
||||||
groups = ["default"]
|
groups = ["default"]
|
||||||
files = [
|
dependencies = [
|
||||||
{file = "amaranth_boards-0-py3-none-any.whl", hash = "sha256:0cc6af682122197b532eef7c2d378a59905ac5e63ec5c69b9147b1e05bf2c600"},
|
"amaranth<0.7,>=0.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -7,7 +7,7 @@ authors = [
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"amaranth>=0.5.1",
|
"amaranth>=0.5.1",
|
||||||
"amaranth-boards>=0",
|
"amaranth-boards @ git+https://github.com/amaranth-lang/amaranth-boards.git",
|
||||||
]
|
]
|
||||||
requires-python = "==3.12.*"
|
requires-python = "==3.12.*"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
18
python.nix
Normal file
18
python.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# overlay python patched version with amaranth/boards updated.
|
||||||
|
final: prev: {
|
||||||
|
python3 = prev.python3.override {
|
||||||
|
packageOverrides = pyfinal: pyprev: {
|
||||||
|
amaranth = pyprev.amaranth.overridePythonAttrs {
|
||||||
|
version = "0.6.0.dev53";
|
||||||
|
src = prev.pkgs.fetchFromGitHub {
|
||||||
|
owner = "amaranth-lang";
|
||||||
|
repo = "amaranth";
|
||||||
|
rev = "e30d822a7d93ee615e70e95a9958051dcc794802";
|
||||||
|
hash = "sha256-A46CMWGvqUFTp3geFFccUM9M7iECmNndzWm2GxA8XbE";
|
||||||
|
};
|
||||||
|
doCheck = false;
|
||||||
|
# installCheckPhase = "${prev.python3.interpreter} -m unittest discover -t . -s tests -v";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from amaranth.vendor import LatticeECP5Platform
|
from amaranth.vendor import LatticeECP5Platform
|
||||||
from amaranth.build import Resource, Pins, Attrs, Clock, Subsignal, PinsN, Connector
|
from amaranth.build import Resource, Pins, Attrs, Clock, Subsignal, PinsN, Connector
|
||||||
from amaranth_boards.resources import SDRAMResource
|
from amaranth_boards.resources import SDRAMResource, LEDResources, ButtonResources
|
||||||
|
|
||||||
|
|
||||||
class Colorlight_5A75B_R82Platform(LatticeECP5Platform):
|
class Colorlight_5A75B_R82Platform(LatticeECP5Platform):
|
||||||
|
@ -23,8 +23,10 @@ class Colorlight_5A75B_R82Platform(LatticeECP5Platform):
|
||||||
Subsignal("copi", Pins("T8", dir="o")),
|
Subsignal("copi", Pins("T8", dir="o")),
|
||||||
Attrs(IO_TYPE="LVCMOS33"),
|
Attrs(IO_TYPE="LVCMOS33"),
|
||||||
),
|
),
|
||||||
Resource("usr_btn", 0, Pins("R7", dir="i"), Attrs(IO_TYPE="LVCMOS33")),
|
*LEDResources(pins="T6", invert=True, attrs=Attrs(IO_TYPE="LVCMOS33", DRIVE="4")),
|
||||||
Resource("usr_led", 0, Pins("T6", dir="o"), Attrs(IO_TYPE="LVCMOS33")),
|
*ButtonResources(
|
||||||
|
pins="R7", invert=True, attrs=Attrs(IO_TYPE="LVCMOS33", PULLMODE="UP")
|
||||||
|
),
|
||||||
SDRAMResource(
|
SDRAMResource(
|
||||||
0,
|
0,
|
||||||
clk="C8",
|
clk="C8",
|
||||||
|
|
26
tests/test_platform.py
Normal file
26
tests/test_platform.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
from amaranth import Elaboratable, Module, Signal
|
||||||
|
from amaranth.lib.io import Buffer
|
||||||
|
from groovylight.platforms.colorlight_5a75b_v8_2 import Colorlight_5A75B_R82Platform
|
||||||
|
|
||||||
|
|
||||||
|
class Blinky(Elaboratable):
|
||||||
|
def elaborate(self, platform):
|
||||||
|
m = Module()
|
||||||
|
|
||||||
|
m.submodules.led = led = Buffer("o", platform.request("led", dir="-"))
|
||||||
|
state = Signal()
|
||||||
|
counter = Signal(24)
|
||||||
|
|
||||||
|
with m.If(counter == 0):
|
||||||
|
m.d.sync += [counter.eq(~0), state.eq(~state)]
|
||||||
|
with m.Else():
|
||||||
|
m.d.sync += counter.eq(counter - 1)
|
||||||
|
|
||||||
|
m.d.comb += led.o.eq(state)
|
||||||
|
|
||||||
|
return m
|
||||||
|
|
||||||
|
|
||||||
|
def test_platform():
|
||||||
|
plat = Colorlight_5A75B_R82Platform()
|
||||||
|
plat.build(Blinky())
|
Loading…
Reference in a new issue