VHDL - 移动一个字节数组

时间:2012-12-12 12:10:38

标签: arrays scroll byte vhdl shift

我遇到了一个移位器模块的问题,它会移动由字节组成的数组的索引。

shifter.vhd:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use work.mypackage2.all; -- contains the type reg array

entity shifter is
    generic ( REGSIZE  : integer := 8);
    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 shifter;

architecture bhv of shifter is

    signal shift_reg : reg_array;
begin
    process (clk) begin
        if rising_edge(clk) then
                if Scan_Dav = '1' then
                    shift_reg <= shift_reg(shift_reg'high-1 downto 0) & Data_in;
                end if;
          end if;
    end process;
     Data_out <= shift_reg;
end bhv;

这是一个移位器,用于保存键盘上的扫描码,输出数组将用于滚动七段显示的文本。我的包包含用于定义移位器输出的类型声明:

mypackage2.vhd:

--  Package File Template
--
--  Purpose: This package defines supplemental types, subtypes, 
--       constants, and functions 


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 (7 downto 0) of reg; -- array of bytes

end mypackage2;


package body mypackage2 is

end mypackage2;

我遇到了问题。此代码的RTL原理图如下所示:

RTL of shifter:

我很困惑为什么会发生这种情况,有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

你的“my_shifter”似乎很好 - 本身。 Xilinx工具可以成功编译它,RTL查看器可以成功显示它,自定义信号显示在一个pagkage中。

然而,使用7段控制器在顶层设计中嵌入“my_shifter”,我设法重现了让你困惑的“错误”的症状 - 它不会显示在顶层图的RTL视图中。

注意“综合报告”中的警告我发现其他一些信号没有连接,允许综合工具优化掉整个移位器!通过查看摘要中生成的触发器数量来确认

修复那些错过的连接,并且确定Shifter在RTL视图中正确连接了所有端口。

所以我撤回了我的建议,即RTL查看器可能是错误的(在这方面!)但强化了我的建议,即解决基本设计问题是一种非常糟糕的方式。

这就是模拟的用途。

否则你的工作比必要的要困难得多,并且误解了问题所在。

相关问题