2013-05-15 60 views
-1

在以下代碼中,我將存儲按鈕播放器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 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 

如何解決這些警告?

WARNING:Xst:2211 - "grid.v" line 104: Instantiating black box module <dummyModule>. 
WARNING:Xst:1710 - FF/Latch <player2> (without init value) has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_0> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_1> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_2> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_3> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_4> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_5> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_6> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_7> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <player2History_8> has a constant value of 0 in block <Grid_Display>. This FF/Latch will be trimmed during the optimization process. 
WARNING:Xst:2036 - Inserting OBUF on port <led> driven by black box <dummyModule>. Possible simulation mismatch. 

問候

+0

-1爲我們傾銷大量的代碼和編譯器輸出而沒有顯示你自己的公平努力。請將您的問題縮小爲能夠再現您問題的最小示例。是VETSMOD。 – Philippe

回答

5

所有你對FF /鎖存微調基本上可以歸結爲問題是player2History總是0,因此它被優化掉了警告。

它看起來不應該總是爲0,但它證明是真實的,因爲您使用了錯誤類型的阻塞語句的一個有趣的副作用。

的問題是在你總是塊以下兩行:然後

always @(posedge clk25) begin 
player1History= button^player2History; 
player2History= button^player1History; 

你的邏輯計算是這樣的:

  1. 在時間player2History(P2H)的開始是零。
  2. 在時鐘的某個位置上,假設按鈕不爲零。此時p2h仍然爲零,因此p1h = button^0僅表示p1h被賦予了按鈕的值。
  3. 現在下面的語句是評估,你正在評估button^p1h,但由於我們剛分配p1h = button,你真的評估button^button,這是我們所知道的是始終爲0
  4. 由於在這種情況下P2H是不可能的永遠是非零的,拖鞋已從您的設計中刪除。

你可能意思做的是使P1H和P2H 阻塞賦值,與<=運營商。當你使用非阻塞的時候,它意味着兩個語句都是並行的,所以p1h和p2h都是對它們的舊值進行求值,而不是先計算第一行,然後在第二行使用這個結果。

理解阻塞和非阻塞語句之間的差異在verilog中非常重要,如果您不理解概念或何時使用它們,那麼您應該尋求額外的培訓資料。

+0

+1爲煩惱閱讀整個事情... :) – EML