Text VHDL-包中的类型声明
我试图在7段显示屏上滚动文本。文本将从键盘输入,我使用BASYS2作为FPGA。我的键盘界面完成了,我的七段控制器也完成了。但我的换档杆模块有问题。在处理扫描码时,我需要使用字节数组。我在一个包中声明了这样的类型,即“mypackage2”。然而,据我所知,换档杆模块无法使用该类型,即“reg_阵列”。我需要改变什么,或者我在这里缺少什么?由于我不熟悉VHDL,我可能会犯一些基本错误。此外,我编写的包不会显示在窗口左侧的项目层次结构中。感谢您的帮助。多谢各位 编辑:我注意到我不应该像下面那样使用reg数组:Text VHDL-包中的类型声明,text,vhdl,shift,segment,Text,Vhdl,Shift,Segment,我试图在7段显示屏上滚动文本。文本将从键盘输入,我使用BASYS2作为FPGA。我的键盘界面完成了,我的七段控制器也完成了。但我的换档杆模块有问题。在处理扫描码时,我需要使用字节数组。我在一个包中声明了这样的类型,即“mypackage2”。然而,据我所知,换档杆模块无法使用该类型,即“reg_阵列”。我需要改变什么,或者我在这里缺少什么?由于我不熟悉VHDL,我可能会犯一些基本错误。此外,我编写的包不会显示在窗口左侧的项目层次结构中。感谢您的帮助。多谢各位 编辑:我注意到我不应该像下面那样使用
Data\u out:out reg\u数组(REGSIZE-1向下到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;
以下是最新的错误:
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.
您已经定义了两次字节数组的大小。在包文件中,您已将
reg\u数组
定义为16个reg
的固定数组。但在体系结构中,您试图通过再次使用(REGSIZE-1降到0)
定义reg\u数组的大小来指定shift\u reg
的大小,就像reg\u数组
是一个可变大小的数组一样
您可以保留reg\u数组的固定声明,并将shift\u reg
定义为:
signal shift_reg : reg_array;
或者保留对shift\u reg
的定义,并将reg\u数组
声明为可变宽度数组,如:
type reg_array is array (natural range <>) of reg; -- variable-length array of bytes
type reg\u数组是reg;--可变长度字节数组
代码中似乎还有一些错误,但其中一些错误可能是由此问题引发的。继续(新问题)
我将从这里继续,而不是开始一个新的话题。如果我这样做是错误的,请纠正我的错误
我所有的代码都编译成功了,但我认为与我所写的和原理图显示的不一致
这是我的顶级模块:
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输出是优化的牺牲品。具体来说,KeyboardController
的输出是否在合成中得到优化?DoRead
输入未被驱动,这可能是原因,但没有偷看键盘控制器代码,这只是一种预感。是的,我刚刚注意到了您提到的问题并对其进行了更改。谢谢你的回答。剩下的错误呢?reg\u数组的包定义使用了to
,但您在代码中使用了downto
。他们不能混在一起。您可以更改其中一个以保持一致。和scan\u dav
不能转换为布尔值。请尝试(Scan_dav='1')
。谢谢您的帮助,现在就完成了。我可能对我的顶级模块有一些问题,我仔细检查了我的连接,所有的连接似乎都在正确的顺序和位置。问题可能是什么?如果是一个新问题,创建一个新问题-这个网站不是一个“论坛”,它是一个定义良好(通常是!)的问题和这些问题的答案的集合。OK,那么我会问一个新问题。>具体来说,KeyboardController的输出是否正在优化>合成中?我不明白你在这里的意思。我不认为DoRead会导致任何不好的结果,但为了以防万一,我将它从键盘接口模块以及顶部模块中删除了。仍然存在问题:/I我决定单独测试所有模块,因此我开始为每个模块创建项目。移位器似乎是一个没有编译的。我收到2个错误,这对我来说是完全陌生的。以下是错误:ERROR:Pack:2309-找到太多适合此设备的“IOB”类型的绑定组件。错误:Pack:18-该设计对于给定的设备和包来说太大。请查看“设计摘要”部分,查看您的设计所需的资源是否超过设备中的可用资源。
这些错误是什么意思?(顺便说一句,我取消了shifter中的scan_dav输入)很抱歉像这样发送垃圾邮件,但我已经取得了一些进展。我在包中将regarray的宽度减少到4,并且成功编译了移位器模块。如何在不改变数组大小的情况下消除此错误,因为移动4个元素将不起作用,因为我使用的是4位七段显示。编辑:换档杆模块本身的示意图仍然损坏。它没有我声明的输入/输出,而是两个输入和一个输出,即I、S和O。。
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;