2024-01-10 22:08:18 +01:00
|
|
|
{
|
2024-01-12 13:45:05 +01:00
|
|
|
description = "fox32 on FPGA";
|
2024-01-10 22:08:18 +01:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
|
|
flake-utils.lib.eachDefaultSystem (sys:
|
|
|
|
let pkgs = nixpkgs.legacyPackages.${sys};
|
|
|
|
|
|
|
|
verilator = import ./verilator.nix pkgs ;
|
|
|
|
|
2024-01-17 12:24:12 +01:00
|
|
|
vflags = ''-Wpedantic -Wwarn-lint -Wwarn-style -Wno-PINCONNECTEMPTY -CFLAGS "-Wpedantic -std=c++20"'';
|
2024-01-12 22:32:45 +01:00
|
|
|
|
2024-01-12 13:44:33 +01:00
|
|
|
verilate-src = cmd: ''
|
|
|
|
cp -r ${./verilog-src} ./verilog-src
|
|
|
|
cp -r ${./simulation} ./simulation
|
|
|
|
find ./verilog-src/ -name '*.v' -exec ${verilator}/bin/verilator ${vflags} ${cmd} {} +
|
2024-01-10 22:08:18 +01:00
|
|
|
'';
|
|
|
|
|
2024-01-12 13:44:33 +01:00
|
|
|
lint = pkgs.runCommand "lint" {} ''
|
|
|
|
${verilate-src "--lint-only"}
|
|
|
|
echo "compiler didn't get angry :3"
|
|
|
|
: 3 > $out
|
2024-01-10 22:08:18 +01:00
|
|
|
'';
|
|
|
|
|
2024-01-12 13:44:33 +01:00
|
|
|
alu-sim = pkgs.runCommandCC "alu-sim" {} ''
|
2024-01-12 22:32:45 +01:00
|
|
|
${verilate-src "--cc --build --exe ./simulation/tester.cpp ./simulation/test_alu.cpp"}
|
2024-01-12 13:44:33 +01:00
|
|
|
mv obj_dir "$out"
|
|
|
|
mkdir "$out/bin" && cp "$out/Valu" "$out/bin/alu-sim"
|
2024-01-10 22:08:18 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
deps = with pkgs; [
|
|
|
|
yosys nextpnrWithGui icestorm verilator
|
|
|
|
];
|
|
|
|
in rec {
|
|
|
|
packages.verilator = verilator;
|
|
|
|
|
2024-01-12 13:44:33 +01:00
|
|
|
packages.lint = lint;
|
2024-01-10 22:08:18 +01:00
|
|
|
|
2024-01-12 13:44:33 +01:00
|
|
|
packages.alu-sim = alu-sim;
|
2024-01-10 22:08:18 +01:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
packages = deps;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|