2012-02-21 35 views
2

我一直在試圖調試這個VHDL代碼兩天了,但我只是沒有看到錯誤在哪裏。下面是代碼:發現信號和常量值警告的1位鎖存

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_ARITH.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 


entity SSDDriver is 
    Port (cp : in std_logic; 
       iin : in std_logic; 
       an : buffer std_logic_vector (3 downto 0); 
       --7=a, 6=b ... 
       segments: out std_logic_vector (7 downto 0)); 
end SSDDriver; 

architecture Behavioral of SSDDriver is 
    signal cpo : std_logic; 
    --broj BCD znamenki 
    constant BCD_NUMBERS : integer := 4; 
    --broj bitova ulaznog broja 
    constant BITS : integer := 14; 
    --broj kodiran BCD-om 
    signal BCDNumber : std_logic_vector (BCD_NUMBERS*4-1 downto 0) := (others => '0'); 
    signal BCDForDecoder: std_logic_vector (3 downto 0); 
    signal number: integer range 0 to 9999; 
begin 
    decoder: entity BCDToSSD port map (bcd => BCDForDecoder, segm => segments (7 downto 1)); 
    counter: entity djelitelj generic map (COUNTTO => 25000) port map (cpIn => cp, CpOut=> cpo); 
    --tocka je uvijek ugasena 
    segments(0) <= '1'; 

    process (iin) 
    begin 
     if iin='1' then 
      number<=3245; 
     else 
      number<=1111; 
     end if; 
    end process; 

    SwitchDisplay: process (cpo) 
    begin 
     if rising_edge(cpo) then 
      if an="0111" then 
       an<="1011"; 
       BCDForDecoder<=BCDNumber(11 downto 8); 
      elsif an="1011" then 
       an<="1101"; 
       BCDForDecoder<=BCDNumber(7 downto 4); 
      elsif an="1101" then 
       an<="1110"; 
       BCDForDecoder<=BCDNumber(3 downto 0); 
      else 
       an<="0111"; 
       BCDForDecoder<=BCDNumber(15 downto 12); 
      end if; 
     end if; 
    end process SwitchDisplay; 

    DoubleDabble: process (number) 
     variable num : std_logic_vector (BITS-1 downto 0); 
     variable bcd : std_logic_vector (BCD_NUMBERS*4-1 downto 0) := (others => '0'); 
     variable old_number: integer range 0 to 9999; 
    begin 
     if number/= old_number then 
      num := conv_std_logic_vector(number, BITS); 

      for i in 0 to BITS-1 loop 
       bcd(BCD_NUMBERS*4-1 downto 1) := bcd(BCD_NUMBERS*4-2 downto 0); 
       bcd(0) := num(BITS-1); 
       num(BITS-1 downto 1) := num(BITS-2 downto 0); 
       num(0) :='0'; 

       if(i < BITS-1 and bcd(3 downto 0) > "0100") then 
        bcd(3 downto 0) := bcd(3 downto 0) + "0011"; 
       end if; 

       if(i < BITS-1 and bcd(7 downto 4) > "0100") then 
        bcd(7 downto 4) := bcd(7 downto 4) + "0011"; 
       end if; 

       if(i < BITS-1 and bcd(11 downto 8) > "0100") then 
        bcd(11 downto 8) := bcd(11 downto 8) + "0011"; 
       end if; 

       if(i < BITS-1 and bcd(15 downto 12) > "0100") then 
        bcd(15 downto 12) := bcd(15 downto 12) + "0011"; 
       end if; 
      end loop; 
      BCDNumber <= bcd; 
     else 

     end if; 

     old_number := number; 
    end process DoubleDabble; 
end Behavioral; 

這裏會產生警告:

警告:XST:2734 - 房產 「use_dsp48」 是不適用於此 技術。警告:從未使用Xst:1780 - 信號>或分配了 。警告:Xst:737 - 發現信號的1位鎖存器。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的16位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:737 - 發現信號的1位鎖存。 警告:Xst:2734 - 屬性「use_dsp48」不適用於此 技術。警告:Xst:1426 - FF/Latch的初始值bcd_0 妨礙塊SSDDriver中的持續清洗。警告:Xst:1293 - FF/Latch在塊中的值爲0。警告:Xst:1293 - FF/Latch的塊的固定值爲 。警告:Xst:1293 - FF/Latch在塊中有一個 常量值爲0。警告:Xst:1293 - FF/Latch 在塊中具有恆定值0。 警告:在 塊中,Xst:1293 - FF/Latch的常數值爲0。警告:Xst:1293 - FF/Latch的塊的值爲0,常數爲 。警告:Xst:1293 - FF/Latch 在塊中具有恆定值0。警告:Xst:1293 - FF/Latch在塊中的值爲0。 警告:在 塊中,Xst:1293 - FF/Latch的常數值爲0。警告:Xst:1293 - FF/Latch的塊的值爲0,常數爲 。警告:Xst:1293 - FF/Latch 在塊中具有恆定值0。警告:Xst:1293 - FF/Latch在塊中的值爲0。 警告:在 塊中,Xst:1293 - FF/Latch的常數值爲0。警告:Xst:1293 - FF/Latch在塊中有一個 常量值爲0。警告:Xst:1293 - FF/Latch 在塊中具有恆定值0。 警告:在 塊中,Xst:1293 - FF/Latch的常數值爲0。警告:XST:1710 - FF /鎖存

等等...

由於這些警告的結果是,當我實現了模塊,我只得到0000顯示4 7段顯示器。

該VHDL代碼應採用整數變量(範圍從0到9999),並使用4個7段顯示器顯示該數字...

回答

4

轉換爲同步設計的替代方法是讓您的邏輯真正異步。

在DoubleDabble過程中,只需評論最外層的if語句,以便您的BCD轉換邏輯始終運行,並查看得到您的位置。您的邏輯不需要先前的整數值(old_number),它是使得合成器適合的「if number/= old_number」比較(不使用時鐘信號和同步邏輯)。

+0

好的,我已經刪除了最外層的if語句,現在我可以實現它,它有點作品:)最後一位數字正確工作(代表一個),但其他3正在迅速變化。我也得到「下面的信號形成一個組合循環」警告,告訴我bcd信號處於組合循環。任何想法,爲什麼是這樣以及我如何解決這個問題?謝謝:) – xx77aBs 2012-02-21 21:15:44

+2

可能是因爲你在開始for循環之前從未將它設置爲已知值。合成器認爲你想要繼承前一個週期的結果。 OMG! – 2012-02-21 23:14:47

+0

OMG!我不能相信這是問題:)現在你已經告訴我,這是有道理的:)我已經把這個:「bcd:=(others =>'0');」在for循環之前,它工作。非常感謝你 !!!! – xx77aBs 2012-02-21 23:38:11

4

是否有任何理由決定以異步方式完成整個BCD轉換過程?這就是所有鎖存問題都來自(Double Dabble Process)的地方。

我幾乎肯定的是,如果你把它轉換爲同步過程,你應該擺脫「持續清理」和「閂鎖」警告。

「持續清洗」警告會將您的所有鎖存器調整爲其初始值,因此爲什麼您始終看到零。

當您需要註冊事件或實例時,您應該幾乎總是使用時鐘。從信號變爲真的時間開始,當時鍾變高但相信我時,你可能會有一個納秒的時間差,在時間和時間的同步將在未來爲你節省很多問題。

+0

謝謝:)你能告訴我該怎麼做才能將這個過程轉換爲同步?我只是一個初學者,所以我不知道我該怎麼做。 – xx77aBs 2012-02-21 20:16:41

+1

不確定您是否仍想要同步答案。你找到你的解決方案嗎? – 2012-02-23 20:59:10

+0

我得到它異步工作。但如果可以的話,請告訴我如何我可以同步。我這樣做只是爲了學習更多,所以一切都是有價值的:) – xx77aBs 2012-02-23 21:13:05