module lcd(clk,sf_ce0, lcd_rs, lcd_rw,
lcd_e, lcd_4, lcd_5, lcd_6, lcd_7);
parameter k = 18;
input clk; // synthesis attribute PERIOD clk "50 MHz"
// synthesis attribute PERIOD clk "50 MHz"
reg [k+8:0] count=0;
output reg sf_ce0; // high for full LCD access
reg lcd_busy=1;
reg lcd_stb;
reg [5:0] lcd_code;
reg [6:0] lcd_stuff;
output reg lcd_rs;
output reg lcd_rw;
output reg lcd_7;
output reg lcd_6;
output reg lcd_5;
output reg lcd_4;
output reg lcd_e;
reg [127:0] input1,input2;
initial
begin
input1 = " hello ";
input2 = " everyone ";
end
always @ (posedge clk) begin
count <= count + 1;
sf_ce0 <= 1;
case (count[k+8:k+2])
0: lcd_code = 6'h03; // power-on initialization
1: lcd_code = 6'h03;
2: lcd_code = 6'h03;
3: lcd_code = 6'h02;
4: lcd_code = 6'h02; // function set
5: lcd_code = 6'h08;
6: lcd_code = 6'h00; // entry mode set
7: lcd_code = 6'h06;
8: lcd_code = 6'h00; // display on/off control
9: lcd_code = 6'h0C;
10: lcd_code = 6'h00; // display clear
11: lcd_code = 6'h01;
12: lcd_code = {2'b10,input1[127:124]};
13: lcd_code = {2'b10,input1[123:120]};
14: lcd_code = {2'b10,input1[119:116]};
15: lcd_code = {2'b10,input1[115:112]};
16: lcd_code = {2'b10,input1[111:108]};
17: lcd_code = {2'b10,input1[107:104]};
18: lcd_code = {2'b10,input1[103:100]};
19: lcd_code = {2'b10,input1[99:96]};
20: lcd_code = {2'b10,input1[95:92]};
21: lcd_code = {2'b10,input1[91:88]};
22: lcd_code = {2'b10,input1[87:84]};
23: lcd_code = {2'b10,input1[83:80]};
24: lcd_code = {2'b10,input1[79:76]};
25: lcd_code = {2'b10,input1[75:72]};
26: lcd_code = {2'b10,input1[71:68]};
27: lcd_code = {2'b10,input1[67:64]};
28: lcd_code = {2'b10,input1[63:60]};
29: lcd_code = {2'b10,input1[59:56]};
30: lcd_code ={2'b10,input1[55:52]};
31: lcd_code = {2'b10,input1[51:48]};
32: lcd_code = {2'b10,input1[47:44]};
33: lcd_code = {2'b10,input1[43:40]};
34: lcd_code = {2'b10,input1[39:36]};
35: lcd_code = {2'b10,input1[35:32]};
36: lcd_code = {2'b10,input1[31:28]};
37: lcd_code = {2'b10,input1[27:24]};
38: lcd_code = {2'b10,input1[23:20]};
39: lcd_code = {2'b10,input1[19:16]};
40: lcd_code = {2'b10,input1[15:12]};
41: lcd_code = {2'b10,input1[11:08]};
42: lcd_code = {2'b10,input1[07:04]};
43: lcd_code = {2'b10,input1[03:00]};
44: lcd_code = 6'h0c;
45: lcd_code = 6'h00;
46: lcd_code = {2'b10,input2[127:124]};
47: lcd_code = {2'b10,input2[123:120]};
48: lcd_code = {2'b10,input2[119:116]};
49: lcd_code = {2'b10,input2[115:112]};
50: lcd_code = {2'b10,input2[111:108]};
51: lcd_code = {2'b10,input2[107:104]};
52: lcd_code = {2'b10,input2[103:100]};
53: lcd_code = {2'b10,input2[99:96]};
54: lcd_code = {2'b10,input2[95:92]};
55: lcd_code = {2'b10,input2[91:88]};
56: lcd_code = {2'b10,input2[87:84]};
57: lcd_code = {2'b10,input2[83:80]};
58: lcd_code = {2'b10,input2[79:76]};
59: lcd_code = {2'b10,input2[75:72]};
60: lcd_code = {2'b10,input2[71:68]};
61: lcd_code = {2'b10,input2[67:64]};
62: lcd_code = {2'b10,input2[63:60]};
63: lcd_code = {2'b10,input2[59:56]};
64: lcd_code ={2'b10,input2[55:52]};
65: lcd_code = {2'b10,input2[51:48]};
66: lcd_code = {2'b10,input2[47:44]};
67: lcd_code = {2'b10,input2[43:40]};
68: lcd_code = {2'b10,input2[39:36]};
69: lcd_code = {2'b10,input2[35:32]};
70: lcd_code = {2'b10,input2[31:28]};
71: lcd_code = {2'b10,input2[27:24]};
72: lcd_code = {2'b10,input2[23:20]};
73: lcd_code = {2'b10,input2[19:16]};
74: lcd_code = {2'b10,input2[15:12]};
75: lcd_code = {2'b10,input2[11:08]};
76: lcd_code = {2'b10,input2[07:04]};
77: lcd_code = {2'b10,input2[03:00]};
default: lcd_code = 6'h10;
endcase
//if (lcd_rw) // comment-out for repeating display
// lcd_busy <= 0; // comment-out for repeating display
lcd_stb <= ^count[k+1:k+0] & ~lcd_rw & lcd_busy; // clkrate / 2^(k+2)
lcd_stuff <= {lcd_stb,lcd_code};
{lcd_e,lcd_rs,lcd_rw,lcd_7,lcd_6,lcd_5,lcd_4} <= lcd_stuff;
end
endmodule
- - - Updated - - -
//ucf file
NET "lcd_e" LOC = "M18" ;
NET "lcd_rs" LOC = "L18" ;
NET "lcd_rw" LOC = "L17" ;
NET "lcd_4" LOC = "R15";
NET "lcd_5" LOC = "R16" ;
NET "lcd_6" LOC = "P17";
NET "lcd_7" LOC = "M15" ;
NET "clk" LOC = "C9";
NET "sf_ce0" LOC = "D16";
- - - Updated - - -
@arishu
try this code.