初级会员
- 积分
- 53
- 金钱
- 53
- 注册时间
- 2019-8-12
- 在线时间
- 15 小时
|
1金钱
如题,自己想显示下32*16的字符(或者说任意大小字符),自己在16*8的例程上改了下,但目前的效果是前半和后半位置反了,拼起来才可以,请大神看下程序哪里有问题?(字模取向和例程不一样)
- module lcd_dis(
- input lcd_pclk,
- input sys_rst_n,
- input [10:0] pixel_xpos,
- input [10:0] pixel_ypos,
- input [10:0] h_disp,
- input [10:0] v_disp,
- output reg [23:0] pixel_data
- );
-
-
-
- //参数定义
- ////CHAR
- localparam FON_X_START =11'd1;
- localparam FON_Y_START =11'd1;
- localparam FON_WIDTH =11'd8;
- localparam FON_HIGHT =11'd16;
-
- localparam FON1_X_START =11'd1;
- localparam FON1_Y_START =11'd17;
- localparam FON1_WIDTH =11'd16;
- localparam FON1_HIGHT =11'd32;
- ////SETTINGS
- localparam BACK_COLOR =24'hFF00FF; //背景色:
- localparam FORE_COLOR =24'hFFFFFF; //前景色:
-
- //REG
- reg [127:0] numb [9:0];
- //ASIGN
- reg [511:0] numb3216 [9:0];
- //字符串赋值
- always @(posedge lcd_pclk) begin
- numb[0] <= 128'h00000018244242424242424224180000;/*"0",0*/
- numb[1] <= 128'h000000101C10101010101010107C0000;/*"1",1*/
- numb[2] <= 128'h0000003C4242424020100804427E0000;/*"2",2*/
- numb[3] <= 128'h0000003C4242402018204042423C0000;/*"3",3*/
- numb[4] <= 128'h00000020303028242422FE2020F80000;/*"4",4*/
- numb[5] <= 128'h0000007E0202021E22404042221C0000;/*"5",5*/
- numb[6] <= 128'h000000182402023A4642424244380000;/*"6",6*/
- numb[7] <= 128'h0000007E422020101008080808080000;/*"7",7*/
- numb[8] <= 128'h0000003C4242422418244242423C0000;/*"8",8*/
- numb[9] <= 128'h0000001C22424242625C404024180000;/*"9",9*/
- end
- //字符串赋值
- always @(posedge lcd_pclk) begin
- numb3216[0] <= 512'h000000000000000000000000C007600C30181830183018200C600C600C600C600C600C600C600C600C601820183018303018600CC00700000000000000000000;/*"0",0*/
- numb3216[1] <= 512'h00000000000000000000000000018001F8018001800180018001800180018001800180018001800180018001800180018001C003F81F00000000000000000000;/*"1",1*/
- numb3216[2] <= 512'h000000000000000000000000E007101C0818043004300C300C30003000180008000400020001800040002020102008200430FC1FFC1F00000000000000000000;/*"2",2*/
- numb3216[3] <= 512'h000000000000000000000000E003180E0C0C0C180C180C180018000C0006C003000E00180010003000300C300C300C100C18180CE00300000000000000000000;/*"3",3*/
- numb3216[4] <= 512'h000000000000000000000000000C000E000E000F800E800E400E600E200E100E100E080E040E040EFE7F000E000E000E000E000E000EC07F0000000000000000;/*"4",4*/
- numb3216[5] <= 512'h000000000000000000000000F03FF03F10001000100008000800C807280C1818081000300030003000300C300C3004180418080CF00300000000000000000000;/*"5",5*/
- numb3216[6] <= 512'h000000000000000000000000800FC010203010301800180008000C008C0F6C183C301C600C600C600C600C601860182030306018C00700000000000000000000;/*"6",6*/
- numb3216[7] <= 512'h000000000000000000000000F83FF83F1C100C0804080404000400020002000100010001800080008000C000C000C000C000C000C00000000000000000000000;/*"7",7*/
- numb3216[8] <= 512'h000000000000000000000000E007300C18180C300C300C301C3038187008E007B007180E0C1C063806300630063006300C18180CE00300000000000000000000;/*"8",8*/
- numb3216[9] <= 512'h000000000000000000000000E00318040C080C180610063006300630063006380C3C1836F03100300018001800180C0C0C060C03F00100000000000000000000;/*"9",9*/
- end
-
-
- //根据像素点,显示字符
- always @(posedge lcd_pclk or negedge sys_rst_n) begin
- if(!sys_rst_n)
- pixel_data <= BACK_COLOR;
- // else if((pixel_xpos>=FON_X_START)
- // &&(pixel_xpos<FON_X_START+FON_WIDTH)
- // &&(pixel_ypos>=FON_Y_START)
- // &&(pixel_ypos<FON_Y_START+FON_HIGHT)) begin
- // if(numb[0][(pixel_xpos-FON_X_START)+(pixel_ypos-FON_Y_START)*8])
- // pixel_data <= FORE_COLOR;
- // else
- // pixel_data <= BACK_COLOR;
- // end
- //
- // else if((pixel_xpos>=FON_X_START+FON_WIDTH*1)
- // &&(pixel_xpos<FON_X_START+FON_WIDTH*2)
- // &&(pixel_ypos>=FON_Y_START)
- // &&(pixel_ypos<FON_Y_START+FON_HIGHT))begin
- // if(numb[1][(FON_Y_START+FON_HIGHT-pixel_ypos-1)*8+(pixel_xpos-(FON_X_START+FON_WIDTH*1))])
- // pixel_data <= FORE_COLOR;
- // else
- // pixel_data <= BACK_COLOR;
- // end
- //
- // else if((pixel_xpos>=FON_X_START+FON_WIDTH*2)
- // &&(pixel_xpos<FON_X_START+FON_WIDTH*3)
- // &&(pixel_ypos>=FON_Y_START)
- // &&(pixel_ypos<FON_Y_START+FON_HIGHT))begin
- // if(numb[2][(FON_Y_START+FON_HIGHT-pixel_ypos-1)*8+(pixel_xpos-(FON_X_START+FON_WIDTH*2))])
- // pixel_data <= FORE_COLOR;
- // else
- // pixel_data <= BACK_COLOR;
- // end
- //
- // else if((pixel_xpos>=FON1_X_START)
- // &&(pixel_xpos<FON1_X_START+FON1_WIDTH)
- // &&(pixel_ypos>=FON1_Y_START)
- // &&(pixel_ypos<FON1_Y_START+FON1_HIGHT)) begin
- // if(numb3216[0][(pixel_xpos-FON1_X_START)+(pixel_ypos-FON1_Y_START)*16])
- // pixel_data <= FORE_COLOR;
- // else
- // pixel_data <= BACK_COLOR;
- // end
- // else if((pixel_xpos>=FON1_X_START+FON1_WIDTH*0)
- // &&(pixel_xpos<FON1_X_START+FON1_WIDTH*1)
- // &&(pixel_ypos>=FON1_Y_START)
- // &&(pixel_ypos<FON1_Y_START+FON1_HIGHT))begin
- // if(numb3216[7][(FON1_Y_START+FON1_HIGHT-pixel_ypos-1)*16+((pixel_xpos-(FON1_X_START+FON1_WIDTH*0))%8)+(FON1_WIDTH/8-(pixel_xpos-(FON1_X_START+FON1_WIDTH*0))/8)*8])
- // pixel_data <= FORE_COLOR;
- // else
- // pixel_data <= BACK_COLOR;
- // end
-
- else if((pixel_xpos>=FON1_X_START+FON1_WIDTH*1)
- &&(pixel_xpos<FON1_X_START+FON1_WIDTH*2)
- &&(pixel_ypos>=FON1_Y_START)
- &&(pixel_ypos<FON1_Y_START+FON1_HIGHT))begin
- if(numb3216[7][(FON1_Y_START+FON1_HIGHT-pixel_ypos-1)*16+((pixel_xpos-(FON1_X_START+FON1_WIDTH*1))%8)+(FON1_WIDTH/8-(pixel_xpos-(FON1_X_START+FON1_WIDTH*1))/8)*8])
- pixel_data <= FORE_COLOR;
- else
- pixel_data <= BACK_COLOR;
- end
- // else if((pixel_xpos>=FON_X_START+FON_WIDTH*2)
- // &&(pixel_xpos<FON1_X_START+FON1_WIDTH*3)
- // &&(pixel_ypos>=FON1_Y_START)
- // &&(pixel_ypos<FON1_Y_START+FON1_HIGHT))begin
- // if(numb3216[1][(FON1_Y_START+FON1_HIGHT-pixel_ypos-1)*16+(pixel_xpos-(FON1_X_START+FON1_WIDTH*1))%8+(FON1_WIDTH/8-(pixel_xpos-(FON1_X_START+FON1_WIDTH*1))/8)*8])
- // pixel_data <= FORE_COLOR;
- // else
- // pixel_data <= BACK_COLOR;
- // end
- else
- pixel_data <= BACK_COLOR;
- end
- endmodule
复制代码 下面注释的可以不用看,我还待修改,我觉得主要是if(numb3216[7][(FON1_Y_START+FON1_HIGHT-pixel_ypos-1)*16+((pixel_xpos-(FON1_X_START+FON1_WIDTH*1))%8)+(FON1_WIDTH/8-(pixel_xpos-(FON1_X_START+FON1_WIDTH*1))/8)*8])这段有问题,但不知道怎么改。
|
最佳答案
查看完整内容[请看2#楼]
问题解决了,上述我的思路没问题,但可能是FON1_WIDTH/8这里的结果不是整数,导致最后的结果除了问题,我把部分运算单独列了出来,然后有if去实现,最后实现了显示,如果说大家觉得是其他地方有问题还请告知,谢谢。
|