Synthesizing

This commit is contained in:
xenia 2024-01-17 12:25:36 +01:00
parent fdd0dd925a
commit 69c367c344
3 changed files with 37 additions and 7 deletions

View File

@ -10,6 +10,7 @@
let pkgs = nixpkgs.legacyPackages.${sys}; let pkgs = nixpkgs.legacyPackages.${sys};
verilator = import ./verilator.nix pkgs ; verilator = import ./verilator.nix pkgs ;
yosys = pkgs.yosys;
vflags = ''-Wpedantic -Wwarn-lint -Wwarn-style -Wno-PINCONNECTEMPTY -CFLAGS "-Wpedantic -std=c++20"''; vflags = ''-Wpedantic -Wwarn-lint -Wwarn-style -Wno-PINCONNECTEMPTY -CFLAGS "-Wpedantic -std=c++20"'';
@ -31,8 +32,17 @@
mkdir "$out/bin" && cp "$out/Valu" "$out/bin/alu-sim" mkdir "$out/bin" && cp "$out/Valu" "$out/bin/alu-sim"
''; '';
deps = with pkgs; [ alu-synth = pkgs.runCommandCC "alu-synth" {} ''
yosys nextpnrWithGui icestorm verilator mkdir -p "$out"
find ${./verilog-src} -name '*.v' -exec ${yosys}/bin/yosys -Q -p "synth_ice40 -top topmost -json $out/synth.json -dsp" {} +
'';
alu-synth-view = pkgs.writeScriptBin "alu-synth-view" ''
${pkgs.nextpnrWithGui}/bin/nextpnr-ice40 --up5k --package sg48 --pcf ${./fpga-files/rot.pcf} --json ${alu-synth}/synth.json --gui
'';
deps = [
yosys pkgs.nextpnrWithGui pkgs.icestorm verilator
]; ];
in rec { in rec {
packages.verilator = verilator; packages.verilator = verilator;
@ -40,6 +50,9 @@
packages.lint = lint; packages.lint = lint;
packages.alu-sim = alu-sim; packages.alu-sim = alu-sim;
packages.alu-synth = alu-synth;
packages.alu-synth-view = alu-synth-view;
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = deps; packages = deps;
}; };

View File

@ -1,5 +1,5 @@
set_io D0 23 set_io clk 39
set_io D1 27 set_io op[0] 40
set_io D2 21 set_io op[1] 41
set_io D3 25 set_io op[2] 42
set_io clk 35 set_io xor_reduce 10

17
verilog-src/topmost.v Normal file
View File

@ -0,0 +1,17 @@
// Dummy module for connecting ALU and similar things, without having to break all inputs and outputs into separate pads
module topmost(input clk, input [2:0] op, output xor_reduce);
reg [31:0] A;
reg [31:0] B;
wire [31:0] O;
alu alu(.A(A), .B(B), .op(op), .O(O), .Fflow(), .Fzero());
always @(posedge clk) begin
A <= A + 1;
B <= B + 3;
end
assign xor_reduce = ^ O;
endmodule