使用函数从数组初始化ROM,Synthesis ERROR(VHDL)

时间:2015-11-20 17:58:28

标签: function initialization vhdl rom xilinx-ise

好的,我的ROM初始化功能有问题。 在我遇到问题之前,让我解释一下我的问题和代码的性质。

我想要做的是生成N个ROM,我必须将其用作运行匹配算法的模块的输入。 我的问题是我有一个带有我的签名的文件(总共说64个),我想在不同的ROM中加载,这取决于我生成了多少(在我的情况下为2的幂,例如每个8个签名的8个roms。

我认为最好的方法是将整个文本文件加载到一个数组中(使用体系结构体外部的函数),然后我将使用它(再次在函数中)将数据加载到一个较小的数组中那将是我的ROM。

在我看来合成器只会忽略大阵列,因为我实际上并没有在我的架构中使用它。

现在的问题是,由于第二个数组输入参数与信号有关,因此合成器只是忽略它们并将我的数组绑定为零(第57行)。

有没有人知道如果有一种方法可以让这种架构合成?

library ieee;
use ieee.std_logic_1164.all;
use IEEE.std_logic_signed.all;
use std.textio.all;

entity signatures_rom_partial is 

generic(
        data_width : integer := 160;
        cycle_int  : integer :=32;
        rom_size   : integer := 4
        );

    port (  clk : in std_logic;
            reset : in std_logic;
            readlne: in integer range 0 to cycle_int-1;                     -- user input for array data initialization
            address: in integer range 0 to rom_size-1;                      -- address for data read
            data: out std_logic_vector(data_width-1 downto 0)               -- data output
         );
end signatures_rom_partial;

architecture rom_arch of signatures_rom_partial is

type rom_type is array (0 to cycle_int-1) of bit_vector (data_width-1 downto 0);            -- big array for all signatures, not used in arch
type test_type is array (0 to rom_size-1) of std_logic_vector (data_width-1 downto 0);      -- smaller ROMs used in arch

--Read from file function--
----------------------------------------------------------------------------------------------------------  
impure function InitRomFromFile (RomFileName : in string) return rom_type is                            --
    file RomFile : text is in RomFileName;                                                              --
    variable RomFileLine : line;                                                                        --
    variable rom : rom_type;                                                                            --
                                                                                                        --
begin                                                                                                   --
    for i in rom_type'range loop                                                                        --
        readline (RomFile, RomFileLine);                                                                --
        read (RomFileLine, rom(i));                                                                     --
    end loop;                                                                                           --
    return rom;                                                                                         --
end function;                                                                                           --
----------------------------------------------------------------------------------------------------------

--Function for smaller ROM initialization--
----------------------------------------------------------------------------------------------------------
impure function initPartRom (rom : rom_type; readlne : integer) return test_type is                     --
    variable test_array : test_type;                                                                    --
                                                                                                        --
begin                                                                                                   --
    for j in test_type'range loop                                                                       --
        test_array(j) := to_stdlogicvector(rom(j+readlne));                                             --
    end loop;                                                                                           --
    return test_array;                                                                                  --
end function;                                                                                           --
----------------------------------------------------------------------------------------------------------

constant rom        : rom_type  := InitRomFromFile("signatures_input.txt");
signal test_array   : test_type := initPartRom(rom , readlne);                      --(LINE 57) SYNTHESIZER IGNORES THESE INPUT ARGUMENTS

begin

    process(clk,reset)
    begin
        if reset='1' then
            data<=(others=>'0');
        elsif (clk'event and clk='1') then
            data <= (test_array(address));
        end if;
    end process;

end rom_arch;

使用Xilinx ISE完成合成,使用Modelsim进行仿真,其中,我的创作工作正常:)

感谢您的帮助!

2 个答案:

答案 0 :(得分:2)

使用Xilinx ISE(14.7),即使按功能从外部文件读取初始数据,也可以合成ROM和RAM。

唯一的要求是,读取功能必须在合成时可计算。对于您的代码而言,情况并非如此,因为readlne在调用函数时不是静态的。您应该将其更改为通用而不是输入,并为每个其他ROM实例的此通用分配不同的值。然后它应该按预期工作。

如何从(Xilinx).mem格式的文本文件中读取初始化数据的示例实现可以在命名空间VHDL Library PoCPoC.mem.ocrom中的PoC.mem.ocram中找到/ p>

答案 1 :(得分:-1)

无法合成读取外部文件中数据的函数。我认为合成忽略了这个功能,不是因为它没有被使用,而是因为它不可能合成它(例如当你在无法合成的信号上插入延迟并且被忽略时会发生这种情况通过合成工具)。

如果您需要合成一个ROM,则必须在VHDL代码中对其进行硬编码(例如,常量),而不是在一个外部文件中。在testbench中仅使用外部文件 来初始化不需要合成的内存。