2013-07-10 75 views
1

我正在尝试实现一个ROM模块并为其构建测试平台。 rom.vhd的检查语法显示'正确',它也显示'正确'的测试平台文件,但是当我点击simluate时会显示一些错误。在xilinx(vhdl)中实现ROM

以下是显示的代码和错误。

LIBRARY ieee ; 
USE ieee.std_logic_1164.all ; 
---------------- 

entity rom is 
port (clk : in std_logic ; 
    address : in integer range 0 to 15 ; 
    data_out : out std_logic_vector(7 downto 0)) ; 
end entity ; 

------------------ 
architecture arch of rom is 

signal reg_address : integer range 0 to 15 ; 
type memory is array (0 to 15) of std_logic_vector(7 downto 0) ; 
constant myrom : memory := (
2 => "11111111" , --255 
3 => "11010101" , 
4 => "01101000" , 
6 => "10011011" , 
8 => "01101101" , 
9 => "00110111" , 
others => "00000000") ; 
begin 
process(clk) 
begin 
if(clk'event and clk = '1') then 
    reg_address <= address ; 
end if ; 
end process ; 
--------------- 
data_out <= myrom(reg_address) ; 
end architecture ; 

测试台的文件:

LIBRARY ieee ; 
USE ieee.std_logic_1164.all ; 
---------------- 

entity rom_tb is 
end entity ; 

----------------------- 
architecture tb of rom_tb is 
component rom is 
port (clk : in std_logic ; 
    address : in integer range 0 to 15 ; 
    data_out : out std_logic_vector(7 downto 0)) ; 
end component ; 
-------------------------- 
signal clk_tb : std_logic := '0' ; 
signal address_tb : integer := 0 ; 
signal data_out_tb : std_logic_vector(7 downto 0) ; 
-------------------------- 
begin 
dut : rom port map (
    clk => clk_tb , 
    address => address_tb , 
    data_out => data_out_tb) ; 
------------------ 
clk_tb <= not clk_tb after 20ns ; 
address_tb <= 1 after 30ns , 
       2 after 60ns , 
       3 after 90ns , 
        4 after 120ns , 
       5 after 150ns , 
       6 after 180ns , 
       7 after 210ns , 
       8 after 240ns , 
       9 after 270ns , 
       10 after 300ns , 
       11 after 330ns , 
       12 after 360ns , 
       13 after 390ns , 
       14 after 420ns , 
       15 after 450ns ; 
end architecture ; 

错误是:

ERROR:模拟器:29 - 在时间0 ns:在rom_tb(TB),文件 d:/ VHDLPrograms/TB/ROM /rom_tb.vhd:实体ROM的默认端口映射到 组件ROM将组件的INTEGER类型本地端口地址连接到实体的std_logic_vector类型端口 。

+0

我刚刚使用ISE 14.4和ISim构建了新Xilinx项目中的代码,我无法重新创建您的问题。 –

+0

意味着它正在工作。你是否得到了输出。 – AbKDs

+0

http://i.stack.imgur.com/Q7MhE.png –

回答

3

检查您上面张贴的(良好)测试平台实际上是您正在模拟的测试平台。

如果您使用Xilinx工具为您的ROM等VHDL实体生成测试台,它将自动将所有端口数据类型转换为std_logic [_vector],以便生成的测试台在修复之前不会运行。您报告的错误听起来好像您的项目中存在多个“rom_tb”文件。如果这不是问题,那么尝试“重新运行所有”或“项目/清理项目文件”,然后“重新运行所有”以消除所有文件的过时编译版本。

编辑:后路线模拟有相反的问题。整数端口已由合成/ P & R进程转换为std_logic_vector。一种解决方案是创建一个类似于“Rom”实体的包装文件,但体系结构将地址端口转换为“无符号”,然后“std_logic_vector”,并将其传递给ROM的后PAR版本。

运行一次或两次后PAR模拟以获得对工具的信心是很好的,但它不应该是例行公事。通常情况下,除非您正在追逐工具错误(错误合成)或异步逻辑(跨越时钟域),否则行为仿真和后PAR静态时序分析已经足够好了。