我想滾動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.
是的,我剛剛注意到你提到的問題並改變了它。謝謝您的回答。剩下的錯誤呢? – John
'reg_array'的包定義使用'to',但是您在代碼中使用'downto'。他們不能混合。您可以更改爲一致。而'scan_dav'不能轉換爲布爾值。嘗試'(Scan_dav ='1')'。 –
謝謝你的幫助,現在就完成了。我可能對我的頂級模塊也有一些疑問 – John