xplicitone
Newbie level 1
Hello,
I'm trying to print characters at particular locations on the LCD of the Spartan 3e using Verilog. I've initialized it, but can't seem to print characters where I want to on the board.
Thank you.
Added after 10 minutes:
Here is my initialization code. I'm trying to display numbers in particular spots on the LCD, for example.
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01:14:32 02/24/2010
// Design Name:
// Module Name:
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module LCD(LCD_RS,LCD_RW,LCD_E,LCD_DATA,inclk,outclk);
output LCD_RS,LCD_RW,LCD_E;
reg LCD_RS,LCD_RW,LCD_E;
output [3:0] LCD_DATA;
reg [3:0] LCD_DATA;
input inclk;
reg [3:0] Init_List[33:0]; //This creates 12 - 4 bit memory locations
//reg [3:0] Char_List[21:0]; //This creates 12 - 4 bit memory locations
integer counter;
reg done;
integer count;
output outclk;
reg outclk;
reg [1:0] state;
integer sec0;
integer sec1;
integer min0;
initial
begin
sec0 = 12; //for 0 on array below
sec1 = 12;
min0 = 12;
state = 0;
count = 0;
outclk = 0;
counter=0;
done=0;
Init_List[0]=4'b0011; //Init
Init_List[1]=4'b0011;
Init_List[2]=4'b0011;
Init_List[3]=4'b0010;
Init_List[4]=4'b0010;
Init_List[5]=4'b1000;
Init_List[6]=4'b0000;
Init_List[7]=4'b0110;
Init_List[8]=4'b0000;
Init_List[9]=4'b1100;
Init_List[10]=4'b0000;
Init_List[11]=4'b0001;
Init_List[12]=4'b0011; //0
Init_List[13]=4'b0000;
Init_List[14]=4'b0011; //1
Init_List[15]=4'b0001;
Init_List[16]=4'b0011; //2
Init_List[17]=4'b0010;
Init_List[18]=4'b0011; //3
Init_List[19]=4'b0011;
Init_List[20]=4'b0011; //4
Init_List[21]=4'b0100;
Init_List[22]=4'b0011; //5
Init_List[23]=4'b0101;
Init_List[24]=4'b0011; //6
Init_List[25]=4'b0110;
Init_List[26]=4'b0011; //7
Init_List[27]=4'b0111;
Init_List[28]=4'b0011; //8
Init_List[29]=4'b1000;
Init_List[30]=4'b0011; //9
Init_List[31]=4'b1001;
Init_List[32]=4'b0011; //:
Init_List[33]=4'b1010;
end
always @(posedge inclk) //slowing down the clock
begin
if (count >= 2500000)
begin
count = 0;
outclk = !outclk;
end
else
begin
count = count + 1;
end
end
always@(posedge outclk)
begin
LCD_RW=0; //write mode always
if (counter < 12)
LCD_RS=0; //command mode
else
LCD_RS=1; //data mode
LCD_DATA=Init_List[counter]; //putting data on a bus
if (! done)
begin
LCD_E = 1;
done = 1;
end
else
begin
//Once counter reaches 11, the LCD is ready to receive ASCII data
case (state) // switch based on control signals
0:
begin
if (counter < 11)
begin
LCD_E = 0;
done = 0;
counter = counter + 1;
end
else
state = 1;
end
1:
begin
if (sec0 < 31)
begin
counter = sec0;
sec0 = sec0 + 1;
LCD_E = 0;
done = 0;
end
else
begin
sec0 = 12; //0 sec reset
counter = sec0;
LCD_E = 0;
done = 0;
state = 2;
end
end
2:
begin
if (sec1 < 23) //5 secs
begin
counter = sec1;
sec1 = sec1 + 1;
state = 1;
end
else
begin
sec1 = 12; //0 secs
counter = sec1;
state = 3;
end
end
3:
begin
min0 = min0 + 1;
state = 1;
end
//counter = counter + 1;
endcase
end
end
endmodule
I'm trying to print characters at particular locations on the LCD of the Spartan 3e using Verilog. I've initialized it, but can't seem to print characters where I want to on the board.
Thank you.
Added after 10 minutes:
Here is my initialization code. I'm trying to display numbers in particular spots on the LCD, for example.
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01:14:32 02/24/2010
// Design Name:
// Module Name:
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module LCD(LCD_RS,LCD_RW,LCD_E,LCD_DATA,inclk,outclk);
output LCD_RS,LCD_RW,LCD_E;
reg LCD_RS,LCD_RW,LCD_E;
output [3:0] LCD_DATA;
reg [3:0] LCD_DATA;
input inclk;
reg [3:0] Init_List[33:0]; //This creates 12 - 4 bit memory locations
//reg [3:0] Char_List[21:0]; //This creates 12 - 4 bit memory locations
integer counter;
reg done;
integer count;
output outclk;
reg outclk;
reg [1:0] state;
integer sec0;
integer sec1;
integer min0;
initial
begin
sec0 = 12; //for 0 on array below
sec1 = 12;
min0 = 12;
state = 0;
count = 0;
outclk = 0;
counter=0;
done=0;
Init_List[0]=4'b0011; //Init
Init_List[1]=4'b0011;
Init_List[2]=4'b0011;
Init_List[3]=4'b0010;
Init_List[4]=4'b0010;
Init_List[5]=4'b1000;
Init_List[6]=4'b0000;
Init_List[7]=4'b0110;
Init_List[8]=4'b0000;
Init_List[9]=4'b1100;
Init_List[10]=4'b0000;
Init_List[11]=4'b0001;
Init_List[12]=4'b0011; //0
Init_List[13]=4'b0000;
Init_List[14]=4'b0011; //1
Init_List[15]=4'b0001;
Init_List[16]=4'b0011; //2
Init_List[17]=4'b0010;
Init_List[18]=4'b0011; //3
Init_List[19]=4'b0011;
Init_List[20]=4'b0011; //4
Init_List[21]=4'b0100;
Init_List[22]=4'b0011; //5
Init_List[23]=4'b0101;
Init_List[24]=4'b0011; //6
Init_List[25]=4'b0110;
Init_List[26]=4'b0011; //7
Init_List[27]=4'b0111;
Init_List[28]=4'b0011; //8
Init_List[29]=4'b1000;
Init_List[30]=4'b0011; //9
Init_List[31]=4'b1001;
Init_List[32]=4'b0011; //:
Init_List[33]=4'b1010;
end
always @(posedge inclk) //slowing down the clock
begin
if (count >= 2500000)
begin
count = 0;
outclk = !outclk;
end
else
begin
count = count + 1;
end
end
always@(posedge outclk)
begin
LCD_RW=0; //write mode always
if (counter < 12)
LCD_RS=0; //command mode
else
LCD_RS=1; //data mode
LCD_DATA=Init_List[counter]; //putting data on a bus
if (! done)
begin
LCD_E = 1;
done = 1;
end
else
begin
//Once counter reaches 11, the LCD is ready to receive ASCII data
case (state) // switch based on control signals
0:
begin
if (counter < 11)
begin
LCD_E = 0;
done = 0;
counter = counter + 1;
end
else
state = 1;
end
1:
begin
if (sec0 < 31)
begin
counter = sec0;
sec0 = sec0 + 1;
LCD_E = 0;
done = 0;
end
else
begin
sec0 = 12; //0 sec reset
counter = sec0;
LCD_E = 0;
done = 0;
state = 2;
end
end
2:
begin
if (sec1 < 23) //5 secs
begin
counter = sec1;
sec1 = sec1 + 1;
state = 1;
end
else
begin
sec1 = 12; //0 secs
counter = sec1;
state = 3;
end
end
3:
begin
min0 = min0 + 1;
state = 1;
end
//counter = counter + 1;
endcase
end
end
endmodule