2012-12-11 44 views
3

我想滾動7段顯示器上的文本。文本將從鍵盤輸入,我使用BASYS2作爲FPGA。我的鍵盤界面已經完成,還有我的七段控制器。但是我的移位器模塊有問題。在處理掃描碼時,我需要使用一組字節。我在一個包中聲明瞭這種類型,即「mypackage2」。然而,據我瞭解,移位器模塊無法使用該類型,即「reg_array」。我需要改變什麼,還是有什麼我在這裏失蹤?由於我是VHDL的新手,我可能會犯一些基本錯誤。另外,我編寫的軟件包不會顯示在窗口左側的項目層次結構中。任何幫助表示讚賞。謝謝。包中的VHDL類型聲明

編輯:我注意到我不應該使用reg數組,如下所示:Data_out : out reg_array(REGSIZE-1 downto 0),因爲它的寬度已經指定。所以我改變了我的代碼一點點,減少錯誤的數量爲3

這裏的轉換器模塊:

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
use IEEE.STD_LOGIC_ARITH.ALL; 
use work.mypackage2.all; 

entity shifter is 
    generic (REGSIZE : integer := 16); -- Text will be composed of 16 characters 
    port(clk  : in std_logic; 
     Scan_Dav : in std_logic; -- this is '1' when there is a new scancode 
     Data_in : in std_logic_vector(7 downto 0); --scancode from keyboard 
     Data_out : out reg_array); 
end shifter; 

architecture bhv of shifter is 

     signal shift_reg : reg_array; 
begin 
    process (clk, Scan_Dav) begin 
     if rising_edge(clk) then 
      if Scan_Dav = '1' then 
       shift_reg(REGSIZE-1 downto 1) <= shift_reg(REGSIZE-2 downto 0); 
       shift_reg(15) <= shift_reg(0); 
      end if; 
     end if; 
     Data_out <= shift_reg; 
    end process; 
end bhv; 

這裏的包:

library IEEE; 
use IEEE.STD_LOGIC_1164.all; 

package mypackage2 is 

    subtype reg is std_logic_vector(7 downto 0); -- a byte 
     type reg_array is array (0 to 15) of reg; -- array of bytes 

end mypackage2; 


package body mypackage2 is 

end mypackage2; 

而這些都是最新的錯誤:

ERROR:HDLParsers:807 - "F:/Projeilk/Shifter.vhd" Line 22. shift_reg can not be used with range downto. 
ERROR:HDLParsers:807 - "F:/Projeilk/Shifter.vhd" Line 22. shift_reg can not be used with range downto. 

回答

0

您已經定義了兩次字節數組的大小。在軟件包文件中,您已將reg_array定義爲16個reg的固定陣列。但是在架構中,您試圖通過將reg_array的大小再次與(REGSIZE-1 downto 0)一起定義大小來指定shift_reg的大小,就好像reg_array是可變大小的數組。

您可以保持reg_array固定聲明並定義shift_reg爲:

signal shift_reg : reg_array; 

或保留shift_reg你的定義,並宣佈reg_array像一個可變寬度的數組:

type reg_array is array (natural range <>) of reg; -- variable-length array of bytes 

它看起來你在代碼中可能會有更多的錯誤,但其中一些可能會從這個問題中級聯起來。

+0

是的,我剛剛注意到你提到的問題並改變了它。謝謝您的回答。剩下的錯誤呢? – John

+0

'reg_array'的包定義使用'to',但是您在代碼中使用'downto'。他們不能混合。您可以更改爲一致。而'scan_dav'不能轉換爲布爾值。嘗試'(Scan_dav ='1')'。 –

+0

謝謝你的幫助,現在就完成了。我可能對我的頂級模塊也有一些疑問 – John

-1

續(新的問題)

我會繼續在這裏不是打開一個新的話題。如果我錯了,請糾正我的錯誤。

所有我的代碼編譯成功,但我認爲與我寫的和什麼原理圖顯示不一致。

這是我的頂層模塊:

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_ARITH.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
use work.mypackage2.all; 

entity TopModule is 
    generic (REGSIZE : integer := 16); 
    Port (Clk  : in STD_LOGIC; 
      Reset  : in std_logic; -- System Reset 
      PS2_Clk : in std_logic; -- Keyboard Clock Line 
      PS2_Data : in std_logic; -- Keyboard Data Line 
      ANODES  : out STD_LOGIC_VECTOR(3 downto 0); 
      SEGMENTS : out STD_LOGIC_VECTOR(6 downto 0)); 
end TopModule; 

architecture Top_arch of TopModule is 

    component clkdivide is 
     Port (clkin: in std_logic; 
       clkout:out std_logic); 
    end component; 

    component SevenSegmentController is 
     Port ( CLK: in std_logic; 
        DEC1, DEC2, DEC3, DEC4: in std_logic_vector(7 downto 0); 
        SEGMENTS: out std_logic_vector(6 downto 0); 
        ANODES: out std_logic_vector(3 downto 0)); 
    end component; 

    component KeyboardController is 
     port (Clk : in std_logic; -- System Clock 
       Reset : in std_logic; -- System Reset 
       PS2_Clk : in std_logic; -- Keyboard Clock Line 
       PS2_Data : in std_logic; -- Keyboard Data Line 
       DoRead : in std_logic; -- From outside when reading the scan code 
       Scan_Err : out std_logic; -- To outside : Parity or Overflow error 
       Scan_DAV : out std_logic; -- To outside when a scan code has arrived 
       Scan_Out : out std_logic_vector(7 downto 0)); 
    end component; 

    component shifter is 
     port (clk  : in std_logic; 
       Scan_Dav : in std_logic; 
       Data_in : in std_logic_vector(7 downto 0); 
       Data_out : out reg_array); 
    end component; 

    signal clk2, scandav, scanerr, doread: std_logic; 
    signal sarray: reg_array; 
    signal datain: std_logic_vector(7 downto 0); 

    begin 
     L1: SevenSegmentController 
      port map (SEGMENTS=> SEGMENTS, CLK=> clk2, ANODES=> ANODES, 
      DEC1=> sarray(15), DEC2=> sarray(14), 
      DEC3=> sarray(13),DEC4=> sarray(12)); 

     L2: clkdivide 
      port map (clkin=>Clk , clkout=>clk2); 

     L3: KeyboardController 
      port map (Clk=> clk2, Reset=> Reset, PS2_Clk=> PS2_Clk, 
      PS2_Data=> PS2_Data, DoRead=> doread, Scan_Err=> scanerr, 
      Scan_DAV=> scandav, Scan_Out=>datain); 

     L4: shifter 
      port map (clk=>clk2, Scan_Dav=>scandav, Data_in=> datain, 
      Data_out=>sarray); 
end Top_arch; 

這是RTL示意圖: RTL of Top Module

的組件不會彼此,鍵盤接口的輸出連接應該被引導到移位器,然後移位器到七段控制器,但移位器本身都是。這裏有什麼問題?

+0

我仔細檢查了我的連接,似乎都按照正確的順序排列。可能是什麼問題? – John

+0

如果這是一個新問題,請創建一個新問題 - 本網站不是「論壇」,它是一個定義明確的(通常是!)問題和回答這些問題的集合 –

+0

好吧,那麼我會問一個新問題。 – John

0

我無法添加評論,所以我必須添加另一個答案。很快看,我沒有看到你的頂級任何嚴重錯誤。我懷疑RTL輸出是優化的犧牲品。具體而言,KeyboardController的輸出在綜合中被優化了嗎? DoRead輸入沒有被驅動,這可能是原因,但沒有偷看KeyboardController代碼,它只是一個預感。

+0

>具體來說,KeyboardController的輸出在合成中被優化爲 >? 我沒有得到你的意思。我不認爲DoRead會導致任何問題,但只是爲了防止它從鍵盤接口模塊和頂層模塊中移除。仍然有問題:/ – John

+0

我決定單獨測試所有模塊,所以我開始爲每個模塊創建項目。移位器似乎是不編譯的。我收到2個錯誤,這對我來說完全是陌生人。以下是錯誤: '錯誤:包裝:2309 - 找到適合此設備的類型「IOB」的過多保稅複合物。 錯誤:包裝:18 - 設計對於給定的設備和包裝太大。 請檢查「設計摘要」部分,看看您的設計對於 哪些資源要求超出設備可用資源。「 這些錯誤是什麼意思? (我取消了移位器btw中的scan_dav輸入。) – John

+0

對不起,我已經取得了一些進展。我將包裝中的regarray寬度減少到4,並且移植模塊編譯成功。如何在不改變數組大小的情況下襬脫此錯誤,因爲我使用的是4位數的七段顯示器,所以移動4個元素將無法使用。 編輯:移位器模塊本身的原理圖仍然斷開。它沒有我聲明的輸入/輸出,而是兩個輸入和一個輸出,如I,S和O.我在這裏非常困惑.. – John