Verilog Xilinx中的意外警告
在下面的代码中,我存储了播放器1和播放器2按下按钮的历史记录。代码编译时没有错误,但有警告。我无法解决这些警告。我在这里张贴代码Verilog Xilinx中的意外警告,verilog,xilinx,Verilog,Xilinx,在下面的代码中,我存储了播放器1和播放器2按下按钮的历史记录。代码编译时没有错误,但有警告。我无法解决这些警告。我在这里张贴代码 module game(clk50,red,green,blue,hsync,vsync, button,led); input [8:0] button; input clk50; output red; output green; output blue,led; output hsync; output vsync; // divide i
module game(clk50,red,green,blue,hsync,vsync, button,led);
input [8:0] button;
input clk50;
output red;
output green;
output blue,led;
output hsync;
output vsync;
// divide input clock by two, and use a global
// clock buffer for the derived clock
reg clk25_int;
always @(posedge clk50) begin
clk25_int <= ~clk25_int;
end
wire clk25;
BUFG bufg_inst(clk25, clk25_int);
wire [9:0] xpos;
wire [9:0] ypos;
Grid_Display Grid_Displayinst(clk25,xpos, ypos, red, green, blue, button,led);
endmodule
module Grid_Display(clk25,xpos,ypos,red,green,blue, button,led);
input clk25;
input [9:0] xpos;//responsible for current pixel display location
input [9:0] ypos;// responsible for current display row
input [8:0] button;
//spartan 3 kit has 3-bits per pixel, so 2^3 means 8 colours can be selected.
output red; // colour 1
output green; // colour 2
output blue; // colur 3
output led;
//reg tempRed,tempGreen,tempBlue, GridRed,GridGreen,GridBlue;
reg player1,player2;
reg [8:0] player1History=0,player2History=0;
wire grid = ((xpos >= 4 && xpos <= 799 && ypos >= 160 && ypos <= 165) ||
(xpos >= 4 && xpos <= 790 && ypos >= 310 && ypos <= 315) ||
(xpos >= 200 && xpos <= 205 && ypos >= 0 && ypos <= 520) ||
(xpos >= 440 && xpos <= 445 && ypos >= 0 && ypos <= 520));
always @(posedge clk25)
begin
player1History= button ^ player2History;
player2History= button ^ player1History;
player1 = ((player1History[0] && (xpos >=50 && xpos<=150 && ypos >= 20 && ypos <=120) ) || (player1History[1] && (xpos >=250 && xpos<=350 && ypos >= 20 && ypos <=120))
|| (player1History[2] && (xpos >=490 && xpos<=590 && ypos >= 20 && ypos <=120)) || (player1History[3] && (xpos >=50 && xpos<=150 && ypos >= 180 && ypos <=280))
|| (player1History[4] && (xpos >=250 && xpos<=350 && ypos >= 180 && ypos <=280)) || (player1History[5] && (xpos >=490 && xpos<=590 && ypos >= 180 && ypos <=280))
|| (player1History[6] && (xpos >=50 && xpos<=150 && ypos >= 330 && ypos <=430)) || (player1History[7] && (xpos >=250 && xpos<=350 && ypos >= 330 && ypos <=430))
|| (player1History[8] && (xpos >=490 && xpos<=590 && ypos >= 330 && ypos <=430)));
player2 = ((player2History[0] && (xpos >=50 && xpos<=150 && ypos >= 20 && ypos <=120) ) || (player2History[1] && (xpos >=250 && xpos<=350 && ypos >= 20 && ypos <=120))
|| (player2History[2] && (xpos >=490 && xpos<=590 && ypos >= 20 && ypos <=120)) || (player2History[3] && (xpos >=50 && xpos<=150 && ypos >= 180 && ypos <=280))
|| (player2History[4] && (xpos >=250 && xpos<=350 && ypos >= 180 && ypos <=280)) || (player2History[5] && (xpos >=490 && xpos<=590 && ypos >= 180 && ypos <=280))
|| (player2History[6] && (xpos >=50 && xpos<=150 && ypos >= 330 && ypos <=430)) || (player2History[7] && (xpos >=250 && xpos<=350 && ypos >= 330 && ypos <=430))
|| (player2History[8] && (xpos >=490 && xpos<=590 && ypos >= 330 && ypos <=430)));
end
assign red = (grid || player1 );
assign green = (grid || player2);
assign blue = (grid );
endmodule
模块游戏(clk50、红色、绿色、蓝色、hsync、vsync、按钮、led);
输入[8:0]按钮;
输入clk50;
输出红色;
输出绿色;
输出蓝色,led;
输出hsync;
输出vsync;
//将输入时钟除以二,并使用全局时钟
//派生时钟的时钟缓冲区
注册clk25_int;
始终@(posedge clk50)开始
clk25 int=4&&xpos=160&&ypos=4&&xpos=310&&ypos=200&&xpos=0&&ypos=440&&xpos=0&&ypos=50&&xpos=20&&ypos=250&&xpos=20&&ypos=490&&xpos=20&&ypos=50&&xpos=180&&ypos=250&&xpos=180&&ypos=50&&xpos=330&&ypos=330xpos=20&&ypos=250&&xpos=20&&ypos=490&&xpos=20&&ypos=50&&xpos=180&&ypos=250&&xpos=180&&ypos=490&&xpos=180&&ypos=50&&xpos=330&&ypos=490&&xpos=330&&ypos=490&&xpos您关于FF/闩锁修剪的所有警告基本上归结为一个问题,即player2History总是0,因此,它正在被优化
看起来它不应该总是0,但事实证明它是真的,因为您使用了错误类型的阻塞语句这一事实产生了一个有趣的副作用
问题在于“始终”块中的这两行:
always @(posedge clk25) begin
player1History= button ^ player2History;
player2History= button ^ player1History;
然后,您的逻辑的计算结果如下:
在时间开始时,player2History(p2h)为零
在时钟的某个边缘,假设按钮为非零。此时p2h仍然为零,因此p1h=button^0
只意味着p1h被分配了button的值李>
现在计算下一个语句,您正在计算button^p1h
,但由于我们刚刚分配了p1h=button
,您实际上在计算button^button
,我们知道它总是0
因为在这种情况下p2h不可能是非零的,所以从您的设计中删除了触发器
您可能的意思是做p1h和p2h非阻塞分配,使用-1将大量代码和编译器输出转储到我们身上,而不显示您自己的合理努力。请把你的问题缩小到能再现你的问题的最小的例子。要小心。
always @(posedge clk25) begin
player1History= button ^ player2History;
player2History= button ^ player1History;