-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframebuffer.v
67 lines (56 loc) · 1.83 KB
/
framebuffer.v
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
67
/*
* framebuffer.v
*
* copyright (c) 2021 hirosh dabui <hirosh@dabui.de>
*
* permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* the software is provided "as is" and the author disclaims all warranties
* with regard to this software including all implied warranties of
* merchantability and fitness. in no event shall the author be liable for
* any special, direct, indirect, or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, whether in an
* action of contract, negligence or other tortious action, arising out of
* or in connection with the use or performance of this software.
*
*/
`timescale 1 ns/10 ps
`default_nettype none
module framebuffer
#(
parameter XSIZE = 128,
parameter YSIZE = 64,
parameter ADDR_DEPTH = XSIZE*YSIZE/8,
parameter DATA_WIDTH = 8
) (
input clk,
input [$clog2(ADDR_DEPTH)-1:0] wr_addr,
input [$clog2(ADDR_DEPTH)-1:0] rd_addr,
input [DATA_WIDTH-1:0] in,
output [DATA_WIDTH-1:0] out,
input cs,
input we
);
reg [DATA_WIDTH -1:0] fb_buffer[0:ADDR_DEPTH-1];
integer idx;
initial begin
$display("ADDR_DEPTH:", ADDR_DEPTH);
$display("DATA_WIDTH:", DATA_WIDTH);
for (idx = 0; idx < ADDR_DEPTH; idx = idx + 1) begin
fb_buffer[idx] = 0;
end
//$readmemh("fb.mem", fb_buffer); // 8x16*256
end
reg [DATA_WIDTH -1:0] out_buf;
always @(posedge clk) begin
if (cs) begin
out_buf <= fb_buffer[rd_addr];
if (we) begin
fb_buffer[wr_addr] <= in;
end
end
end
assign out = cs ? out_buf : 'hz;
endmodule