69 lines
2.0 KiB
Nix
69 lines
2.0 KiB
Nix
|
{
|
||
|
description = "ice40 testing";
|
||
|
|
||
|
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 ;
|
||
|
|
||
|
rot-sim = pkgs.runCommandCC "rot-sim" {} ''
|
||
|
cp "${./rot.v}" rot.v
|
||
|
${verilator}/bin/verilator --cc -O3 --exe --build --trace ${./sim_main.cpp} rot.v
|
||
|
mv obj_dir "$out"
|
||
|
'';
|
||
|
|
||
|
rot-trace = pkgs.runCommand "rot-trace" {} ''
|
||
|
mkdir "$out"
|
||
|
${rot-sim}/Vrot $out/trace.vcd
|
||
|
'';
|
||
|
|
||
|
rot-trace-view = pkgs.writeScriptBin "rot-view" ''
|
||
|
${pkgs.gtkwave}/bin/gtkwave ${rot-trace}/trace.vcd
|
||
|
'';
|
||
|
|
||
|
rot-synth = pkgs.runCommand "rot-synth" {} ''
|
||
|
mkdir "$out"
|
||
|
${pkgs.yosys}/bin/yosys -p "read -vlog95 ${./rot.v} ; synth_ice40 -json $out/synth.json"
|
||
|
'';
|
||
|
|
||
|
rot-route = pkgs.runCommand "rot-route" {} ''
|
||
|
mkdir "$out"
|
||
|
${pkgs.nextpnr}/bin/nextpnr-ice40 --pcf ${./rot.pcf} --json ${rot-synth}/synth.json --asc $out/routed.asc --up5k --top rot --freq 12
|
||
|
'';
|
||
|
|
||
|
rot-pack = pkgs.runCommand "rot-pack" {} ''
|
||
|
mkdir "$out"
|
||
|
${pkgs.icestorm}/bin/icepack ${rot-route}/routed.asc $out/packed.bin
|
||
|
'';
|
||
|
|
||
|
rot-upload = pkgs.writeScriptBin "rot-upload" ''
|
||
|
${pkgs.icestorm}/bin/iceprog ${rot-pack}/packed.bin
|
||
|
'';
|
||
|
|
||
|
deps = with pkgs; [
|
||
|
yosys nextpnrWithGui icestorm verilator
|
||
|
];
|
||
|
in rec {
|
||
|
packages.verilator = verilator;
|
||
|
|
||
|
packages.rot-sim = rot-sim;
|
||
|
packages.rot-trace = rot-trace;
|
||
|
packages.rot-trace-view = rot-trace-view;
|
||
|
|
||
|
packages.rot-synth = rot-synth;
|
||
|
packages.rot-route = rot-route;
|
||
|
packages.rot-pack = rot-pack;
|
||
|
packages.rot-upload = rot-upload;
|
||
|
|
||
|
devShells.default = pkgs.mkShell {
|
||
|
packages = deps;
|
||
|
};
|
||
|
}
|
||
|
);
|
||
|
}
|