我正在尝试实现一个 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 ;
测试台文件:
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 的默认端口映射将组件的 INTEGER 类型本地端口地址连接到 std_logic_vector实体的类型端口。