-
Notifications
You must be signed in to change notification settings - Fork 1
/
LCD_Controller_MIPS.sv
58 lines (52 loc) · 1.09 KB
/
LCD_Controller_MIPS.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
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
module LCD_Controller_MIPS #(
parameter clk_wait = 16)
(
input reset,clk, iRS, LCD_start,
input [7:0] DATA,
output [7:0] LCD_DATA,
output logic LCD_EN, LCD_DONE,
output LCD_RW, LCD_RS, LCD_ON
);
//Turn on the LCD Display
assign LCD_ON = 1;
//Assign outputs
assign LCD_DATA = DATA;
assign LCD_RW = 1'b0;
assign LCD_RS = iRS;
// Internal connections
enum {start, init, delay, done} state, next_state;
logic [4:0] counter;
//Reset
always_ff @(posedge clk) begin
state = (reset)? start : next_state;
end
//FSM
always_ff @(posedge clk) begin
unique case(state)
start:begin
LCD_DONE = 1'b0;
LCD_EN = 1'b0;
counter = 0;
next_state = init; // Go to delay state
end
init: begin
LCD_EN = 1'b1;
next_state = delay;
end
delay:begin
if(counter<clk_wait) //wait until the parameter we defined
counter = counter+1;
else
next_state = done; //finish the wait
end
done: begin
LCD_EN = 1'b0;
LCD_DONE = 1'b1; //set the flag for done
counter = 0;
if (LCD_start) begin
next_state = start;
end
end
endcase
end
endmodule : LCD_Controller_MIPS