-
Notifications
You must be signed in to change notification settings - Fork 0
/
top.v
50 lines (38 loc) · 851 Bytes
/
top.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
module top(
input CLK,
input SCK,
input CS,
input MOSI,
output TMP,
output STORE);
reg [2:0] SCKr;
reg [2:0] CSr;
reg [1:0] MOSIr;
wire SCK_risingedge = (SCKr[2:1]==2'b01); // now we can detect SCK rising edges
wire CS_endmessage = (CSr[2:1]==2'b01); // message stops at rising edge
wire MOSI_data = MOSIr[1];
assign STORE = CS_endmessage;
always @(posedge CLK)
SCKr <= {SCKr[1:0], SCK};
always @(posedge CLK)
CSr <= {CSr[1:0], CS};
always @(posedge CLK)
MOSIr <= {MOSIr[0], MOSI};
assign TMP = ^lcd_data[23:0];
reg [23:0] lcd_data;
reg [23:0] tmp_data;
always @(posedge CLK)
begin
if(SCK_risingedge)
begin
tmp_data <= {tmp_data[22:0], MOSI_data};
end
end
always @(posedge CLK)
begin
if(CS_endmessage)
begin
lcd_data <= tmp_data;
end
end
endmodule