我有一個關於將字符打印到LCD屏幕的問題。將字符打印到LCD - Verilog HDL
我正在使用Altera DE1-SoC 5CSEMA5F31C6N和LT24 Terasic LCD。
我有一個關於在液晶顯示器上打印一行字母的問題。
我依靠屏幕左上角(0,0)處的x和y計數器屏幕上的光柵。 遞增x一路行結束,一旦達到了目的,重設X爲0,則增加y,然後再繼續計數的X,直到屏幕年底
我是創建數組以打印字符值(8x8像素)
長陣列將所有字符的「每行像素」連接在一起,然後當計數器在屏幕上進行柵格化時,每個字符的像素將打印到LCD。
例如。 row0 - 打印所有字符的第一行像素。 row1 - 爲所有字符打印第二行像素。
然而,當我嘗試打印2個字符,字符的被打印的順序顛倒[從原點(0,0)]
例如如果我想打印'我'然後'M'。我實際上依次得到'M'和'I'。
當我嘗試打印3個字符,然後沒有字符顯示!
我真的很努力理解爲什麼是這樣的情況下,作爲計數器值用於測試角色的當前位,然後繪製像素
任何幫助,將不勝感激。
我有基本的Verilog理解,但舒適的C語言編程
謝謝
代碼片段如下。
////////////////////////////// code ////////////////////////////////////////////
reg [0] totalCharData [23:0]; // pixel row0
reg [1] totalCharData [23:0]; // pixel row1
reg [2] totalCharData [23:0]; // pixel row2
reg [3] totalCharData [23:0]; // pixel row3
reg [4] totalCharData [23:0]; //
reg [5] totalCharData [23:0]; //
reg [6] totalCharData [23:0]; //
reg [7] totalCharData [23:0]; // pixel row 7
// character ‘I'
totalCharData[7][7:0] = 8'b11111111;
totalCharData[6][7:0] = 8'b11111111;
totalCharData[5][7:0] = 8'b00111100;
totalCharData[4][7:0] = 8'b00111100;
totalCharData[3][7:0] = 8'b00111100;
totalCharData[2][7:0] = 8'b00111100;
totalCharData[1][7:0] = 8'b11111111;
totalCharData[0][7:0] = 8'b11111111;
// character ‘M'
totalCharData[7][15:8] = 8'b11100111;
totalCharData[6][15:8] = 8'b11101111;
totalCharData[5][15:8] = 8'b11111111;
totalCharData[4][15:8] = 8'b11111111;
totalCharData[3][15:8] = 8'b11010011;
totalCharData[2][15:8] = 8'b11000011;
totalCharData[1][15:8] = 8'b11000011;
totalCharData[0][15:8] = 8'b11000011;
// character ‘E'
totalCharData[7][23:16] = 8'b11111111;
totalCharData[6][23:16] = 8'b11111111;
totalCharData[5][23:16] = 8'b11100000;
totalCharData[4][23:16] = 8'b11111111;
totalCharData[3][23:16] = 8'b11111111;
totalCharData[2][23:16] = 8'b11100000;
totalCharData[1][23:16] = 8'b11111111;
totalCharData[0][23:16] = 8’b11111111;
// X Counter
always @ (posedge clock or posedge resetApp) begin
if (resetApp) begin
xAddr <= 8'b0;
end else if (pixelReady) begin
if (xAddr < (WIDTH-1)) begin
xAddr <= xAddr + 8'd1;
end else begin
xAddr <= 8'b0;
end
end
end
// Y Counter
always @ (posedge clock or posedge resetApp) begin
if (resetApp) begin
yAddr <= 9'b0;
end else if (pixelReady && (xAddr == (WIDTH-1))) begin
if (yAddr < (HEIGHT-1)) begin
yAddr <= yAddr + 9'd1;
end else begin
yAddr <= 9'b0;
end
end
end
// draw characters to the lcd
always @ (posedge clock or posedge resetApp) begin
if (resetApp) begin
pixelData[15:0] <= 16'h0000; ; // wipe the full screen with background
end else begin // whilst bitton held, make blue
if ((xAddr>=0) && (xAddr<24) && (yAddr>=0) && (yAddr<8))begin // draw complete row of pixels for all the characters in line
if ((totalCharData[yAddr][xAddr] == 1'b1))begin // test the current bit using the counters
pixelData[15:0] <= 16'hFFE0; // yellow - draw pixel if the current bit is 1 as defined
end
else begin
pixelData[15:0] <= 16'h0000;
end // else
end else begin
pixelData[15:0] <= 16'h0000; // black screen
end
end
end