Xilinx VHDL RAM 的初始化

2019-03-25 08:51发布

在网上找到一个RAM的程序,如下。
但我还想加一个Restart的输入口,加了一个process,当Restart和clk为1的时候通过data(10)<="11111111";进行初始化,可是报错说RAM连了太多的驱动。

请教高人,有没有别的办法初始化呢

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

entity ram is         
generic(width:integer :=8;length:integer:=256);                              
port(clk:in std_logic;
      r_add,w_add:in std_logic_vector(7 downto 0);
                restart,r_en,w_en:in std_logic;
      d_in:in std_logic_vector(width-1 downto 0);
      d_out:out std_logic_vector(width-1 downto 0));
end entity;
architecture art of ram is
type memory is array (0 to length-1) of std_logic_vector(width-1 downto 0);
signal data:memory;
begin
process(clk,w_add,w_en,d_in)
begin
   if clk'event and clk='1' then
    if w_en='1' then              
    data(conv_integer(w_add))<=d_in;
   end if;
  end if;
end process;
process(clk,r_add,r_en,data)
begin
    if clk'event and clk='1' then
        if r_en='1' then
     d_out<=data(conv_integer(r_add));
    end if;
   end if;
end process;
end art;

[ 本帖最后由 timdong 于 2012-10-28 01:31 编辑 ] 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
6条回答
流浪的猥琐
2019-03-26 00:51
din在第一个process里对data赋值了,就不能在另一个process里面再对data(10)赋值,会报错multi drivers,还有,你的restart是想做什么?要是做启动的初始化的话直接计数,到了就复位就是了。还有,你贴的程序不全还是你下的程序就这么多,w_addr和r_addr是ram的标志位,读写分开标志,是双口ram的模式,两个标志位都没有改变,在ram里存储数据的地址就不会变,数据一直覆盖。还有,你这个程序是在FPGA内构造一个ram,不是控制外部ram哦,你看看是不是符合你的需求

一周热门 更多>