summaryrefslogtreecommitdiff
path: root/platform/wavelet3d/gfx_bootrom.sv
blob: 2c4581e44fe503e74058b5fcd8eea85bf40261b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module gfx_bootrom
import gfx::*;
(
	input  logic      clk,
	                  rst_n,

	       gfx_axil.s axis
);

	localparam ROM_WORDS_LOG = 8;

	enum int unsigned
	{
		WAIT,
		READ,
		RDATA,
		READY
	} state;

	word read, rom[1 << ROM_WORDS_LOG];
	logic[ROM_WORDS_LOG - 1:0] read_addr;

	assign axis.bvalid = 0;
	assign axis.wready = 0;
	assign axis.awready = 0;

	always_ff @(posedge clk or negedge rst_n)
		if (~rst_n) begin
			state <= WAIT;
			axis.rvalid <= 0;
			axis.arready <= 0;
		end else begin
			axis.arready <= 0;

			unique case (state)
				WAIT:
					if (axis.arvalid & ~axis.arready)
						state <= READ;

				READ:
					state <= RDATA;

				RDATA: begin
					state <= READY;
					axis.rvalid <= 1;
				end

				READY:
					if (axis.rready) begin
						state <= WAIT;
						axis.rvalid <= 0;
						axis.arready <= 1;
					end
			endcase
		end

	always_ff @(posedge clk) begin
		read <= rom[read_addr];
		read_addr <= axis.araddr[$bits(read_addr) + SUBWORD_BITS - 1:SUBWORD_BITS];
		axis.rdata <= read;
	end

	initial
		$readmemh("gfx_bootrom.hex", rom);

endmodule