• 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进行例化,以及地址数据的产生

    顶层代码如下:

    1. library IEEE;
    2. use IEEE.STD_LOGIC_1164.ALL;
    3. use ieee.std_logic_1164.all;
    4. use ieee.std_logic_unsigned.all;
    5. use ieee.std_logic_arith.all;
    6. entity top is
    7. PORT (
    8. clk : IN STD_LOGIC;
    9. rst_n : IN STD_LOGIC;
    10. dout : OUT STD_LOGIC_VECTOR(10 DOWNTO 0)
    11. );
    12. end top;
    13. architecture Behavioral of top is
    14. COMPONENT rom
    15. PORT (
    16. clka : IN STD_LOGIC;
    17. addra : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
    18. douta : OUT STD_LOGIC_VECTOR(10 DOWNTO 0)
    19. );
    20. END COMPONENT;
    21. signal addr : STD_LOGIC_VECTOR(9 DOWNTO 0):= (others => '0');
    22. begin
    23. u0 : rom
    24. PORT MAP (
    25. clka => clk,
    26. addra => addr,
    27. douta => dout
    28. );
    29. process(clk)
    30. begin
    31. if (rst_n = '1') then
    32. addr <= (others => '0');
    33. elsif (rising_edge(clk)) then
    34. if addr = "1010111100" then
    35. addr <= (others => '0');
    36. else
    37. addr <= addr + '1';
    38. end if;
    39. end if;
    40. end process;
    41. end Behavioral;

    3.查看rtl图:

      4编写测试文件:

     tb文件如下:

    1. LIBRARY ieee;
    2. USE ieee.std_logic_1164.ALL;
    3. ENTITY top_tb IS
    4. END top_tb;
    5. ARCHITECTURE behavior OF top_tb IS
    6. -- Component Declaration for the Unit Under Test (UUT)
    7. COMPONENT top
    8. PORT(
    9. clk : IN std_logic;
    10. rst_n : IN STD_LOGIC;
    11. dout : OUT std_logic_vector(10 downto 0)
    12. );
    13. END COMPONENT;
    14. --Inputs
    15. signal clk : std_logic := '0';
    16. signal rst_n : std_logic := '1';
    17. --Outputs
    18. signal dout : std_logic_vector(10 downto 0);
    19. -- Clock period definitions
    20. constant clk_period : time := 10 ns;
    21. BEGIN
    22. -- Instantiate the Unit Under Test (UUT)
    23. uut: top PORT MAP (
    24. clk => clk,
    25. rst_n => rst_n,
    26. dout => dout
    27. );
    28. -- Clock process definitions
    29. clk_process :process
    30. begin
    31. clk <= '0';
    32. wait for clk_period/2;
    33. clk <= '1';
    34. wait for clk_period/2;
    35. end process;
    36. -- Stimulus process
    37. stim_proc: process
    38. begin
    39. -- hold reset state for 100 ns.
    40. rst_n <= '0';
    41. wait for clk_period*10;
    42. -- insert stimulus here
    43. wait;
    44. end process;
    45. END;

    5.仿真图:

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

     

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

     

     

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

    1. LIBRARY ieee;
    2. use ieee.std_logic_1164.all;
    3. use ieee.std_logic_unsigned.all;
    4. use ieee.std_logic_arith.all;
    5. ENTITY rom_tb IS
    6. END rom_tb;
    7. ARCHITECTURE behavior OF rom_tb IS
    8. -- Component Declaration for the Unit Under Test (UUT)
    9. COMPONENT rom
    10. PORT(
    11. clka : IN std_logic;
    12. addra : IN std_logic_vector(9 downto 0);
    13. douta : OUT std_logic_vector(10 downto 0)
    14. );
    15. END COMPONENT;
    16. --Inputs
    17. signal clka : std_logic := '0';
    18. signal addra : std_logic_vector(9 downto 0) := (others => '0');
    19. --Outputs
    20. signal douta : std_logic_vector(10 downto 0);
    21. -- Clock period definitions
    22. constant clka_period : time := 10 ns;
    23. BEGIN
    24. -- Instantiate the Unit Under Test (UUT)
    25. uut: rom PORT MAP (
    26. clka => clka,
    27. addra => addra,
    28. douta => douta
    29. );
    30. -- Clock process definitions
    31. clka_process :process
    32. begin
    33. clka <= '0';
    34. wait for clka_period/2;
    35. clka <= '1';
    36. wait for clka_period/2;
    37. end process;
    38. -- Stimulus process
    39. stim_proc: process
    40. begin
    41. -- hold reset state for 100 ns.
    42. addra <= (others => '0');
    43. if addra = "1010111100" then
    44. addra <= (others => '0');
    45. else
    46. addra <= addra + '1';
    47. end if;
    48. wait for 100 ns;
    49. wait for clka_period*10;
    50. -- insert stimulus here
    51. wait;
    52. end process;
    53. END;

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

  • 相关阅读:
    狄兰·托马斯诗合集▷Do not go gentle into that good night
    C语言学习(四)之分支和跳转
    watch()监听vue2项目角色权限变化更新挂载
    python 文件分割成几份
    java计算机毕业设计律师事务所网站源码+系统+mysql数据库+lw文档
    在Java中使用Spring Boot设置全局的BusinessException
    雷克萨斯品牌舆情监测-危机后,如何重新赢得消费者的认可?
    【Arduino】esp01 Relay 转接板自动ping ip断电重启
    Java—常用API
    RPC和HTTP的理解
  • 原文地址:https://blog.csdn.net/qq_43811597/article/details/126507187