今天休息了。
大致与学长研究了多字符显示,中字符从rom读取后显示问题。
通过学习了ise仿真之后发现,只有当rom字符地址改变时,原地址的中第0位才会输出来data值。
于是自己通过拓宽了状态机的一位,让它在第零位时不取data值,而在第一位取data值。
这里当add值变化的时候,才输出了第16位add值时候的数据data,可是此时add以及变成了17,所以data值变化有1时钟的周期延迟,对于地址端的话是这样。
module vga_display(
data,
vga_clk,
rst_n,
x_pixel,
y_pixel,
pixel_data,
add
);
input [15:0] data ;
input vga_clk ;
input rst_n ;
input [9:0] x_pixel ;
input [9:0] y_pixel ;
//---------------------------------
output reg [23:0] pixel_data;
output reg [11:0] add ;
//---------------------------------
//---------------------------------
parameter white = 24'b1111_1111__1111_1111__1111_1111;
parameter black = 24'b0000_0000__0000_0000__0000_0000;
parameter red = 24'b1111_1111__0000_0000__0000_0000;
parameter green = 24'b0000_0000__1111_1111__0000_0000;
parameter bule = 24'b0000_0000__0000_0000__1111_1111;
//---------------------------------
//28*63
reg [15:0] char [15:0];
reg [3:0] cnt ;
reg [4:0] cnt2;
reg [3:0] cnt3;
always@(posedge vga_clk or negedge rst_n)
if(!rst_n)
begin
cnt2 <= 'd0;
end
else
begin
if(cnt2 == 'd16)
begin
cnt2 <= cnt2;
end
else
begin
cnt2 <= cnt2 + 1'b1;
end
end
always@(posedge vga_clk or negedge rst_n)
if(!rst_n)
begin
add <= 'd16;
cnt3 <= 'd0;
end
else
begin
if(cnt3 == 'd15)
begin
cnt3 <= cnt3;
add <= add;
end
else
begin
cnt3 <= cnt3 + 1'b1;
add <= add + 1'b1;
end
end
always@(posedge vga_clk or negedge rst_n)
if(!rst_n)
cnt <= 'd0;
else
case(cnt)
0:begin
if(cnt2 == 'd1)
begin
char[0 ] <= data;
cnt <= 'd1;
end
end
1:if(cnt2 == 'd2)
begin
char[1 ] <= data;
cnt <='d2;
end
2:if(cnt2 == 'd3)
begin
char[2 ] <= data;
cnt<='d3;
end
3:if(cnt2 == 'd4)
begin
char[3 ] <= data;
cnt <= 'd4;
end
4:if(cnt2 == 'd5)
begin
char[4 ] <= data;
cnt <= 'd5;
end
5:if(cnt2 == 'd6)
begin
char[5 ] <= data;
cnt <= 'd6;
end
6:if(cnt2 == 'd7)
begin
char[6 ] <= data;
cnt <= 'd7;
end
7:if(cnt2 == 'd8)
begin
char[7 ] <= data;
cnt <= 'd8;
end
8:if(cnt2 == 'd9)
begin
char[8 ] <= data;
cnt <= 'd9;
end
9:if(cnt2 == 'd10)
begin
char[9 ] <= data;
cnt <= 'd10;
end
10:if(cnt2 == 'd11)
begin
char[10] <= data;
cnt <= 'd11;
end
11:if(cnt2 == 'd12)
begin
char[11] <= data;
cnt <= 'd12;
end
12:if(cnt2 == 'd13)
begin
char[12] <= data;
cnt <= 'd13;
end
13:if(cnt2 == 'd14)
begin
char[13] <= data;
cnt <= 'd14;
end
14:if(cnt2 == 'd15)
begin
char[14] <= data;
cnt <= 'd15;
end
15:if(cnt2 == 'd16)
begin
char[15] <= data;
cnt <= 'd0;
end
endcase
always@(posedge vga_clk or negedge rst_n)
begin
if(!rst_n)
pixel_data <= black;
else
if(x_pixel <= 320 && y_pixel <= 240)
if(x_pixel <= 64 && y_pixel <= 32)
if(char[y_pixel-1][16-x_pixel])
pixel_data <= black;
else
pixel_data <= white;
else
pixel_data <= green;
else
pixel_data <= bule;
end
endmodule
今天也学会创建ise的rom,感觉最近光了解了软件中的各种东西,创建了coe文件,发现比td中mif文件好复制,不需要描写地址端。
发现对于jupyter notebook,真的很好用。