【发布时间】:2015-04-29 08:48:40
【问题描述】:
过去两天我一直在与这个问题作斗争。在这种情况下,我希望 data_out 发送“111”,看看整个内存是如何被“1”填充的。我将显示代码,然后使问题更精确:
entity tile_library is
Port (
data_out : out std_logic_vector(2 downto 0);
data_in : in std_logic_vector(5 downto 0);
clk : in std_logic);
end tile_library;
architecture Behavioral of tile_library is
type memory_type is array (0 to 63) of std_logic_vector(255 downto 0);
signal memory : memory_type := (others=> (others=>'1'));
signal something_to_convert : std_logic_vector(5 downto 0) := "000000";
begin
process(clk) begin
if rising_edge(clk) then
if memory(to_integer(unsigned(data_in)))(5) = '1' then
data_out <= "111";
else
data_out <= "000";
end if;
end if;
end process;
end Behavioral;
如果我替换
if memory(to_integer(unsigned(data_in)))(5) = '1' then
与
if memory(to_integer(unsigned(something_to_convert)))(5) = '1' then
我的 nexys 3 卡上的输出是“111”。
这让我相信 data_in 不是它应该的样子。
因此,我向您展示了在我的测试中生成 data_in 到 tile_library 的代码:
entity tile_memory is
Port (
data_out : out std_logic_vector(5 downto 0);
clk : in std_logic);
end tile_memory;
architecture Behavioral of tile_memory is
begin
process(clk)
begin
if rising_edge(clk) then
data_out <= "000000";
end if;
end process;
end Behavioral;
为了进一步混淆,我可以补充一点,根据模拟,if memory(to_integer(unsigned(data_in)))(5) = '1' then 和 @ 我得到完全相同的输入和输出信号(也是正确的,“111”) 987654326@。当我在我的 Nexys 3 卡上运行它时;但是,它们会产生不同的结果。
我在这里做错了什么?
【问题讨论】:
-
这一行:
signal memory : memory_type := (others=> (others=>'1'));包含内存的预初始化,在综合中可能不支持。出于诊断目的,为什么不直接发送data_in而不必担心它可能是什么? -
如果不替换,您没有指出输出是什么。 @BrianDrummond 指出的情况更糟。您的内存类型 memory_type 被初始化为 std_logic_vector 的所有 '1' 的所有 256 个元素,这是所有 64 个位置的元素类型。除非您有某种方式将不同的值写入内存,否则它可以被优化掉。从字面上看,data_in 是不是无关紧要,而且它也可能在综合中被优化掉,它总是全 0。