-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory.sv
29 lines (26 loc) · 819 Bytes
/
memory.sv
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
module memory #(
parameter RAM_SIZE_BYTES = 4096
) (
input wire clk_in,
input wire do_write,
input wire [$clog2(RAM_SIZE_BYTES)-1:0] write_address,
input wire [7:0] data_in,
input wire [$clog2(RAM_SIZE_BYTES)-1:0] read_address,
output logic [7:0] data_out /*,
input wire [$clog2(RAM_SIZE_BYTES)-1:0] read_address_gfx,
output logic [7:0] data_out_gfxA*/
);
logic [7:0] mem[0:RAM_SIZE_BYTES-1];
initial begin
$readmemh("fontset.bin", mem, 0);
$readmemb("rom.bin", mem, 'h200);
end
always_ff @(negedge clk_in) begin
if (do_write) begin
mem[write_address] <= data_in;
end
//$display("MEM : Reading address %h (%h)", read_address, mem[read_address]);
data_out <= mem[read_address];
//data_out_gfx <= mem[read_address_gfx];
end
endmodule