我正在尝试实现一个rom模块,并为它建立了一个测试平台。rom.vhd的检查语法显示‘正确’,它也显示‘正确’的测试台文件,但当我点击simluate时,它显示了一些错误。
下面是代码和显示的错误。
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 ;testbench文件:
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 ; 错误是:
错误:模拟器:29-0 ns :在rom_tb(tb)中,文件D:/VHDLPrograms/Tb/ rom / rom _tb.vhd:实体rom到组件rom的默认端口映射将组件的整型本地端口地址连接到实体的std_logic_vector类型端口。
发布于 2013-07-11 04:26:41
检查上面发布的(良好的)测试平台是否真的就是您正在模拟的那个。
如果您使用Xilinx工具为VHDL实体生成测试台,那么它会自动将所有端口数据类型转换为std_logic_vector,因此,在您修复它之前,生成的测试台将不会工作。您报告的错误听起来好像您的项目中有多个"rom_tb“文件。如果这不是问题所在,请尝试"re-run all“或" Project /Clean Project Files”,然后尝试"re-run all“,以消除所有文件的过期编译版本。
编辑:布线后仿真具有相反的问题。整数端口已通过synth/P&R过程转换为std_logic_vector。一种解决方案是创建一个包装器文件,它看起来像你的" ROM“实体,但是架构将地址端口转换为"unsigned”,然后是"std_logic_vector",并将其传递到ROM的后期解析版本。
运行一次或两次PAR后模拟是很好的,以获得对工具的信心,但这不应该是例行公事。通常,行为模拟和解析后静态时序分析已经足够好了,除非您正在追踪工具错误(不正确的合成)或异步逻辑(跨时钟域)。
https://stackoverflow.com/questions/17579716
复制相似问题