nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 ghdl-llvm,
4 ghdl-mcode,
5 ghdl-gcc,
6 backend,
7}:
8
9let
10 ghdl =
11 if backend == "llvm" then
12 ghdl-llvm
13 else if backend == "gcc" then
14 ghdl-gcc
15 else
16 ghdl-mcode;
17in
18stdenv.mkDerivation {
19 name = "ghdl-test-simple";
20 meta.timeout = 300;
21 nativeBuildInputs = [ ghdl ];
22 buildCommand = ''
23 cp ${./simple.vhd} simple.vhd
24 cp ${./simple-tb.vhd} simple-tb.vhd
25 mkdir -p ghdlwork
26 ghdl -a --workdir=ghdlwork --ieee=synopsys simple.vhd simple-tb.vhd
27 ghdl -e --workdir=ghdlwork --ieee=synopsys -o sim-simple tb
28 ''
29 + (
30 if backend == "llvm" || backend == "gcc" then
31 ''
32 ./sim-simple --assert-level=warning > output.txt
33 ''
34 else
35 ''
36 ghdl -r --workdir=ghdlwork --ieee=synopsys tb > output.txt
37 ''
38 )
39 + ''
40 diff output.txt ${./expected-output.txt} && touch $out
41 '';
42}