-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_lcd.v
101 lines (59 loc) · 1.6 KB
/
init_lcd.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
module init_lcd (dataA, dataB, result,clk, clk_en, reset, start, done, read_write, register_select, enable_op, data_out);
input clk, clk_en, reset, start;
input [31:0] dataA, dataB;
output read_write;
output reg [7:0] data_out;
output reg [31:0] result;
output reg register_select, enable_op, done;
reg [1:0] state;
reg [31:0] counter;
parameter idle_state = 2'b00, busy_state = 2'b01, end_state = 2'b11;
assign read_write = 1'b0;
always @ (posedge clk) begin
if (reset) begin
counter <= 32'd0;
register_select <= 1'b0;
state <= idle_state;
result <= 32'd0;
data_out <= 8'b0;
done <= 1'b0;
enable_op <= 1'b1;
end
else begin
if (clk_en) begin
case (state)
idle_state: begin
done <= 1'b0;
enable_op <= 1'b1;
if(start) begin
register_select <= dataA [0];
data_out <= dataB [7:0];
counter <= 32'd0;
state <= busy_state;
end
end
busy_state: begin
if (counter < 32'd100000) begin
counter <= counter + 32'd1;
end
else begin
counter <= 32'd0;
state <= end_state;
enable_op <= 1'b0;
end
end
end_state: begin
if (counter < 32'd100000) begin
counter <= counter + 32'd1;
end
else begin
result <= 32'd1;
done <= 1'b1;
state <= idle_state;
end
end
endcase
end
end
end
endmodule