2017-02-18 39 views
0

我正在嘗試製作可合成的Verilog代碼,它可以檢測'x'或無效輸入。基本上,x不合成,所以我避免x。我試圖在每個時鐘週期讀取輸入,如果是01,那麼我將加載到一個新的寄存器中。這是代碼;Verilog中可合成'X'或無效輸入檢測系統

[email protected](posedge clk) 
begin 
    if(in & gate_check == 0 | in & gate_check == 1) 
    begin 
     load_input_8 <= {in,load_input_8[8:1]}; 
    end 
end 

因此,我在檢查輸入數據的有效性後,將新輸入加載到load_input_8寄存器中。順便說一下,gate_check的值爲1,即`gate_check = 1。

但是,這只是將1的值存儲到load_input_8中。沒有0正在存儲在load_input_8。加載輸入時電路也有奇怪的行爲。這是模擬圖片; enter image description here 謝謝。

+0

只有'in = 1'才能滿足你的條件。 –

+0

@Laleh,謝謝。問題解決了。 –

回答

0

感謝@Laleh幫助解決了這個問題。有問題()。這是正確的代碼;

[email protected](posedge clk) 
begin 
    if((in & gate_check) == 0 | (in & gate_check) == 1) 
    begin 
     load_input_8 <= {in,load_input_8[8:1]}; 
    end 
end