-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_rx_2bytes_2RGB.v.bak
62 lines (53 loc) · 1.18 KB
/
data_rx_2bytes_2RGB.v.bak
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
module data_rx_2bytes_2RGB(
input wire in_clk, in_nrst,
input wire [7:0] in_data,
input wire [7:0] pwm_value,
output reg last_phase_strobe,
output reg alrst_strobe,
output reg lat_strobe,
output reg led_clk,
output reg [2:0] rgb1, rgb2
);
reg [1:0] cur_phase;
reg tmp_led_clk;
always @(posedge in_clk)
begin
last_phase_strobe <= (cur_phase == 2'b10);
alrst_strobe <= (cur_phase == 2'b10);
lat_strobe <= (cur_phase == 2'b10);
tmp_led_clk <= (cur_phase == 2'b11);
end
always @(negedge in_clk)
led_clk <= tmp_led_clk;
reg [15:0] in_data_buffer;
always @(posedge in_clk)
if (cur_phase[0])
in_data_buffer [15:8] <= in_data;
else
in_data_buffer [7:0] <= in_data;
always @(posedge in_clk)
begin
if (~in_nrst)
cur_phase <= 2'b00;
else
cur_phase <= cur_phase + 1;
end
wire [2:0] tmp_rgb;
color_comparator_rgb555 comparator_inst0(in_data_buffer, pwm_value[4:0], tmp_rgb[0], tmp_rgb[1], tmp_rgb[2]);
always @(posedge in_clk or negedge in_nrst)
begin
if (~in_nrst)
begin
rgb1 <= 3'b000;
rgb2 <= 3'b000;
end
else
begin
if (~cur_phase[0])
if (cur_phase[1])
rgb2 <= tmp_rgb;
else
rgb1 <= tmp_rgb;
end
end
endmodule