3

7 セグメント ディスプレイでテキストをスクロールしようとしています。テキストはキーボードから入力し、FPGA として BASYS2 を使用しています。キーボード インターフェイスと 7 セグメント コントローラーが完成しました。しかし、シフター モジュールに問題があります。スキャンコードを扱っているので、バイト配列を使用する必要があります。そのようなタイプをパッケージ、つまり「mypackage2」で宣言しました。ただし、私が理解している限り、シフターモジュールはそのタイプ、つまり「reg_array」を使用できません。何を変更する必要がありますか、またはここに欠けているものはありますか? 私は 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.
4

3 に答える 3

1

バイト配列のサイズを 2 回定義しました。パッケージ ファイルではreg_array、16 の固定配列として定義しましたreg。しかし、アーキテクチャでは、可変サイズの配列であるかのように、 のサイズを再度shift_reg定義することで のサイズを指定しようとしています。reg_array(REGSIZE-1 downto 0)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 

コードにさらにいくつかのエラーがあるようですが、そのうちのいくつかはこの問題から連鎖している可能性があります。

于 2012-12-11T20:48:04.437 に答える
0

まだコメントを追加できないので、別の回答を追加する必要があります。ざっと見てみると、あなたのトップレベルに厳密な問題は見当たりません。RTL 出力が最適化の犠牲になっていると思われます。具体的には、KeyboardController最適化された出力は合成で取り除かれますか? 入力が駆動されDoReadていないことが原因である可能性がありますが、KeyboardController コードをのぞき見しない限り、それはただの予感です。

于 2012-12-11T22:22:16.960 に答える
-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

コンポーネントは相互にリンクされていません。キーボードインターフェイスの出力はシフターに送られ、次にシフターは7セグメントコントローラーに送られますが、シフターはすべてそれ自体です。ここでの問題は何ですか?

于 2012-12-11T21:31:16.383 に答える