xilinx FPGA ROM IP核的使用(VHDL&ISE)

目录

1.新建工程之后 建一个ip核文件:

2.编写顶层文件或者激励文件:(一定一定点击下面这个例化模板 去对ip核进行例化)

3.查看rtl图:

  4编写测试文件:

5.仿真图:

工程下载链接:https://download.csdn.net/download/qq_43811597/86488775


1.新建工程之后 建一个ip核文件:

 

 

 根据所存数据的最大值来设置数据位宽(但位宽不知道需不需要换算,还是说将最大的那个数设为位宽)

根据所存数据个数来设置数据深度(他这里的深度好像不用根据个数去换算,直接就是深度=数据个数)

我本来以为我存700个数据 那么深度就是10,结果一直报错 不能生成ip核

就是这个加载coe这块会变红,还有就是一直报错:the memory initialization vector can contain between 1 to write depth A number of entires. 

one or more of the parameters are invalid. please correct and try again.

然后我看到深度那个范围很大,就把深度直接改成数据个数了,没有错误出现,但是宽度需不需要改 暂时不确定

 在这里是将matlab产生的数据导入到rom当中(放coe文件的路径不能有中文,并且xilinx系列的rom放coe文件,altera系列放mif文件),可以点击show看是否coe文件有效

 matlab生成数据步骤链接:http://t.csdn.cn/OvDPP

2.编写顶层文件或者激励文件:(一定一定点击下面这个例化模板 去对ip核进行例化)

 在ram.vho  点开是一个.vho的文件,里面就有你建的ip核的元件声明和例化(ip核的名字跟顶层文件或者其他的测试或者其他模块名字不要重!!!我找了一周的错) 

这里可以先建立一个top文件,对rom进行例化,以及地址数据的产生

顶层代码如下:


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;


entity top is
PORT (
    clk : IN STD_LOGIC;
    rst_n : IN STD_LOGIC;
    dout : OUT STD_LOGIC_VECTOR(10 DOWNTO 0)
  );
end top;

architecture Behavioral of top is

COMPONENT rom
  PORT (
    clka : IN STD_LOGIC;
    addra : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
    douta : OUT STD_LOGIC_VECTOR(10 DOWNTO 0)
  );
END COMPONENT;

signal addr :  STD_LOGIC_VECTOR(9 DOWNTO 0):= (others => '0');

begin

u0 : rom
  PORT MAP (
    clka => clk,
    addra => addr,
    douta => dout
  );
  
process(clk)
begin
    if (rst_n = '1') then
        addr <= (others => '0');
    elsif (rising_edge(clk)) then
        if  addr = "1010111100" then
            addr <= (others => '0');
        else
            addr <= addr + '1';
        end if;
    end if;
end process;
end Behavioral;

3.查看rtl图:

  4编写测试文件:

 tb文件如下:


LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
 

 
ENTITY top_tb IS
END top_tb;
 
ARCHITECTURE behavior OF top_tb IS 
 
    -- Component Declaration for the Unit Under Test (UUT)
 
    COMPONENT top
    PORT(
         clk : IN  std_logic;
         rst_n : IN STD_LOGIC;
         dout : OUT  std_logic_vector(10 downto 0)
        );
    END COMPONENT;
    

   --Inputs
   signal clk : std_logic := '0';
signal rst_n : std_logic := '1';
 	--Outputs
   signal dout : std_logic_vector(10 downto 0);

   -- Clock period definitions
   constant clk_period : time := 10 ns;
 
BEGIN
 
	-- Instantiate the Unit Under Test (UUT)
   uut: top PORT MAP (
          clk => clk,
          rst_n => rst_n,
          dout => dout
        );

   -- Clock process definitions
   clk_process :process
   begin
		clk <= '0';
		wait for clk_period/2;
		clk <= '1';
		wait for clk_period/2;
   end process;
 

   -- Stimulus process
   stim_proc: process
   begin		
      -- hold reset state for 100 ns.
      
      rst_n <= '0';

      wait for clk_period*10;

      -- insert stimulus here 

      wait;
   end process;

END;

5.仿真图:

可以看到最开始的数据和吻合的(注意生成地址数据时,要符合时钟)

 

 可以看出最后的数据也是吻合的

 

 

注:另外我们也可以不建立top文件,直接建立tb文件,在tb文件中产生时钟和地址数据即可:


LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
 

 
ENTITY rom_tb IS
END rom_tb;
 
ARCHITECTURE behavior OF rom_tb IS 
 
    -- Component Declaration for the Unit Under Test (UUT)
 
    COMPONENT rom
    PORT(
         clka : IN  std_logic;
         addra : IN  std_logic_vector(9 downto 0);
         douta : OUT  std_logic_vector(10 downto 0)
        );
    END COMPONENT;
    

   --Inputs
   signal clka : std_logic := '0';
   signal addra : std_logic_vector(9 downto 0) := (others => '0');

 	--Outputs
   signal douta : std_logic_vector(10 downto 0);

   -- Clock period definitions
   constant clka_period : time := 10 ns;
 
BEGIN
 
	-- Instantiate the Unit Under Test (UUT)
   uut: rom PORT MAP (
          clka => clka,
          addra => addra,
          douta => douta
        );

   -- Clock process definitions
   clka_process :process
   begin
		clka <= '0';
		wait for clka_period/2;
		clka <= '1';
		wait for clka_period/2;
   end process;
 

   -- Stimulus process
   stim_proc: process
   begin		
      -- hold reset state for 100 ns.
      
      addra <= (others => '0');
      
      if  addra = "1010111100" then
        addra <= (others => '0');
     else
        addra <= addra + '1';
      end if;
      wait for 100 ns;	

      wait for clka_period*10;

      -- insert stimulus here 

      wait;
   end process;

END;

工程下载链接:https://download.csdn.net/download/qq_43811597/86488775

  • 4
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值