feat: use BRAM as video memory

This commit is contained in:
Luca 2024-10-25 20:27:37 +02:00
parent 195990d2b1
commit 6b988087bd
3 changed files with 52 additions and 1 deletions

View File

@ -26,7 +26,7 @@ pixelflut.frames: pixelflut.fasm
pixelflut.fasm: arty_a7_35t.xdc pixelflut.json pixelflut.fasm: arty_a7_35t.xdc pixelflut.json
nextpnr-xilinx --chipdb "$(CHIPDB_DIR)/$(PART).bin" --fasm $@ --json pixelflut.json --xdc arty_a7_35t.xdc nextpnr-xilinx --chipdb "$(CHIPDB_DIR)/$(PART).bin" --fasm $@ --json pixelflut.json --xdc arty_a7_35t.xdc
pixelflut.json: pixelflut.v dvi.v pixelflut.json: pixelflut.v dvi.v xc7_bram.v
yosys -q -p 'synth_xilinx -top pixelflut; write_json $@' $^ yosys -q -p 'synth_xilinx -top pixelflut; write_json $@' $^
dvi_tb.vcd: dvi_tb.vvp dvi_tb.vcd: dvi_tb.vvp

View File

@ -47,4 +47,14 @@ module pixelflut (
.hs (dvi_hs), .hs (dvi_hs),
.vs (dvi_vs), .vs (dvi_vs),
); );
xc7_bram ram (
.out_clk (dvi_bus_clk),
.out_data(dvi_bus_data),
.out_addr(dvi_bus_addr),
.in_clk (),
.in_data (),
.in_addr (),
.in_wren (),
);
endmodule endmodule

41
xc7_bram.v Normal file
View File

@ -0,0 +1,41 @@
module xc7_bram #(
parameter NUM_BLOCKS = 50,
) (
input out_clk,
output [15:0] out_data,
input [23:0] out_addr,
input in_clk,
input [15:0] in_data,
input [23:0] in_addr,
input [1:0] in_wren,
);
wire [31:0] porta_out [NUM_BLOCKS-1:0];
wire [15:0] porta_addr, portb_addr;
assign out_data = porta_out[out_addr[16:11]][15:0];
assign porta_addr = {1'b1, out_addr[10:0], 4'b1};
assign portb_addr = {1'b1, in_addr[10:0], 4'b1};
genvar i;
generate
for (i = 0; i < NUM_BLOCKS; i = i + 1) begin
RAMB36E1 #(
.READ_WIDTH_A (18),
.WRITE_WIDTH_B(18),
) bram_block (
.DOADO (porta_out[i]),
.ADDRARDADDR(porta_addr),
.CLKARDCLK (out_clk),
.ENARDEN (1'b1),
.ADDRBWRADDR(portb_addr),
.CLKBWRCLK (in_clk),
.ENBWREN (in_addr[16:11] == i),
.WEBWE ({6'b0, in_wren}),
.DIBDI ({16'h0000, in_data}),
);
end
endgenerate
endmodule