- UID
- 1029342
- 性别
- 男
|
always @ (posedge clk or negedge rst_n)
begin
if(!rst_n)
y_cnt <= 10'b0;
else if(y_cnt == 10'd665)
y_cnt <= 10'b0;
else if(x_cnt ==11'd1039 )
y_cnt <= y_cnt + 1'b1;
end
wire valid;
assign valid = (x_cnt >= 11'd187) && (x_cnt <= 11'd987) && (y_cnt >= 10'd31) && (y_cnt <= 10'd631);//---------------有效显示区坐标--------------------
wire [9:0] xpos;
wire [9:0] ypos;
assign xpos = x_cnt-11'd187;
assign ypos = y_cnt-10'd31;
//-------------------同步信号产生-------------------
reg hsync_r,vsync_r;
always @ (posedge clk or negedge rst_n)
begin
if(!rst_n)
hsync_r <= 1'b1;
else if(x_cnt == 11'd0)
hsync_r <= 1'b0; //产生hsync信号
else if(x_cnt == 11'd120)
hsync_r <= 1'b1;
end
always @ (posedge clk or negedge rst_n)
begin
if(!rst_n)
vsync_r <= 1'b1;
else if(y_cnt == 10'd0)
vsync_r <= 1'b0; //产生vsync信号
else if(y_cnt == 10'd6)
vsync_r <= 1'b1;
end
assign hsync = hsync_r;
assign vsync = vsync_r;
//-----------------显示图像-----------------------
always @ (posedge clk )
begin
if((ypos >= 9'd100 && ypos <= 9'd255)&&(xpos >= 10'd65 && xpos <= 10'd244))
addr <= (ypos-100)*180 + (xpos-65);
else addr<=0;
end
endmodule
图片文件mif:
-- Copyright (C) 2006 Laputa Develop Group
-- PicToMif is a freeware, which can be spread freely,
-- as long as not being used in commerce.
-- Memory Initialization File (.mif) generated by PicToMif can
-- be used in Quartus to initialize the roms or rams.
WIDTH=3;
DEPTH=28080;
ADDRESS_RADIX=UNS;
DATA_RADIX=BIN;
CONTENT BEGIN
0 : 000;
1 : 111;
2 : 111;
3 : 111;
4 : 111;
5 : 111;
6 : 111;
7 : 111;
8 : 111;
9 : 111;
10 : 111;
11 : 111;
12 : 111;
13 : 111;
14 : 111; |
|