-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRLE_RAM_Interface.v
71 lines (63 loc) · 1.25 KB
/
RLE_RAM_Interface.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
68
69
70
71
`timescale 1ns / 1ps
module RLE_RAM_Interface(clk, rst, a, spo, E, R, G, B);
input clk, rst;
input [7:0] spo;
output reg E;
output reg [15:0] a;
output reg [7:0] R, G, B;
parameter HOLD_CLK = 1;
reg [15:0] hold_cnt;
parameter RBA = 0, GBA = 16384, BBA = 32768;
reg [14:0] offset;
reg [2:0] state;
parameter [2:0] r1 = 0, r2 = 1, g1 = 2, g2 = 3, b1 = 4, b2 = 5, hold = 6;
always @ (posedge clk or posedge rst) begin
if (rst) begin
E = 0;
R = 0;
G = 0;
B = 0;
offset = 0;
state = r1;
hold_cnt = 0;
end
else begin
E = 0;
if (offset < GBA) begin
if (state == r1) begin
a = offset + RBA;
state = r2;
end
else if (state == r2) begin
R = spo;
state = g1;
end
else if (state == g1) begin
a = offset + GBA;
state = g2;
end
else if (state == g2) begin
G = spo;
state = b1;
end
else if (state == b1) begin
a = offset + BBA;
state = b2;
end
else if (state == b2) begin
B = spo;
E = 1;
offset = offset + 1;
state = hold;
end
else if (state == hold) begin
hold_cnt = hold_cnt + 1;
if (hold_cnt >= HOLD_CLK) begin
hold_cnt = 0;
state = r1;
end
end
end
end
end
endmodule