2013-11-28 62 views
0

對於一個項目,我試圖將我從sc_lv<8>型輸入端口收到的值轉換爲sc_uint<8>型信號。順便說一下,輸入端口連接到sc_signal_rv<8>頻道。如何正確地將sc_lv轉換爲sc_uint?

我試着用這條線鑄造輸入數據:

sc_in< sc_lv<8> > data_in; 

// Other declarations 

sc_signal< sc_uint<8> > tx_data; 

// Other declarations 
// Assume that all else is properly declared 

sc_uint<8> temp; 
temp = (sc_uint<8>)data_in->read(); // Casting 
tx_data.write(temp); 

但我在模擬過程中得到這樣的警告:

Warning: (W211) sc_logic value 'Z' cannot be converted to bool

我雖然做了逐案影響,但我不完全確定。

任何想法?

回答

0

這是一個警告,它會告訴你4值到2值的轉換,它會丟失信息。所以警告是很好的,讓你覺得很可笑

0

同意魔法師。 但是,最好讓您的程序在沒有任何警告的情況下進行編譯,換句話說,警告是一個問題,您應該通過明確演員修改代碼來回答:

sc_uint<8> temp = static_cast< sc_uint<8> >(data_in->read()); 
相關問題