2013-07-10 74 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靜態時序分析已經足夠好了。