2024-07-17 03:26:36 +00:00
|
|
|
{ stdenv, ghdl-llvm, ghdl-mcode, ghdl-gcc, backend }:
|
2020-10-21 23:04:26 +00:00
|
|
|
|
|
|
|
let
|
2024-06-21 17:22:16 +00:00
|
|
|
ghdl = if backend == "llvm" then ghdl-llvm else if backend == "gcc" then ghdl-gcc else ghdl-mcode;
|
2020-10-21 23:04:26 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "ghdl-test-simple";
|
|
|
|
meta.timeout = 300;
|
|
|
|
nativeBuildInputs = [ ghdl ];
|
|
|
|
buildCommand = ''
|
|
|
|
cp ${./simple.vhd} simple.vhd
|
|
|
|
cp ${./simple-tb.vhd} simple-tb.vhd
|
|
|
|
mkdir -p ghdlwork
|
|
|
|
ghdl -a --workdir=ghdlwork --ieee=synopsys simple.vhd simple-tb.vhd
|
|
|
|
ghdl -e --workdir=ghdlwork --ieee=synopsys -o sim-simple tb
|
2024-06-21 17:22:16 +00:00
|
|
|
'' + (if backend == "llvm" || backend == "gcc" then ''
|
2020-10-21 23:04:26 +00:00
|
|
|
./sim-simple --assert-level=warning > output.txt
|
|
|
|
'' else ''
|
|
|
|
ghdl -r --workdir=ghdlwork --ieee=synopsys tb > output.txt
|
|
|
|
'') + ''
|
|
|
|
diff output.txt ${./expected-output.txt} && touch $out
|
|
|
|
'';
|
|
|
|
}
|