1{ stdenv, fetchFromGitHub, lib
2, cmake, pkg-config, openjdk
3, libuuid, python3
4, silice, yosys, nextpnr, verilator
5, dfu-util, icestorm, trellis
6}:
7
8stdenv.mkDerivation rec {
9 pname = "silice";
10 version = "unstable-2022-08-05";
11
12 src = fetchFromGitHub {
13 owner = "sylefeb";
14 repo = pname;
15 rev = "e26662ac757151e5dd8c60c45291b44906b1299f";
16 sha256 = "sha256-Q1JdgDlEErutZh0OfxYy5C4aVijFKlf6Hm5Iv+1jsj4=";
17 fetchSubmodules = true;
18 };
19
20 nativeBuildInputs = [
21 cmake
22 pkg-config
23 openjdk
24 ];
25 buildInputs = [
26 libuuid
27 ];
28 propagatedBuildInputs = [
29 (python3.withPackages (p: with p; [ edalize ]))
30 ];
31
32 postPatch = ''
33 patchShebangs antlr/antlr.sh
34 # use nixpkgs version
35 rm -r python/pybind11
36 '';
37
38 installPhase = ''
39 make install
40 mkdir -p $out
41 cp -ar ../{bin,frameworks,lib} $out/
42 '';
43
44 passthru.tests =
45 let
46 testProject = project: stdenv.mkDerivation {
47 name = "${silice.name}-test-${project}";
48 nativeBuildInputs = [
49 silice
50 yosys
51 nextpnr
52 verilator
53 dfu-util
54 icestorm
55 trellis
56 ];
57 src = "${src}/projects";
58 sourceRoot = "projects/${project}";
59 buildPhase = ''
60 targets=$(cut -d " " -f 2 configs | tr -d '\r')
61 for target in $targets ; do
62 make $target ARGS="--no_program"
63 done
64 '';
65 installPhase = ''
66 mkdir $out
67 for target in $targets ; do
68 cp -r BUILD_$target $out/
69 done
70 '';
71 };
72 in {
73 # a selection of test projects that build with the FPGA tools in
74 # nixpkgs
75 audio_sdcard_streamer = testProject "audio_sdcard_streamer";
76 bram_interface = testProject "bram_interface";
77 blinky = testProject "blinky";
78 pipeline_sort = testProject "pipeline_sort";
79 };
80
81 meta = with lib; {
82 description = "Open source language that simplifies prototyping and writing algorithms on FPGA architectures";
83 homepage = "https://github.com/sylefeb/Silice";
84 license = licenses.bsd2;
85 maintainers = [ maintainers.astro ];
86 };
87}