2013-12-12 35 views
0

我的用于此RAM的2D数组完美工作。在读出数据之前,我有处理多个触发器的任务。所以现在我试图在RAM中创建一个数据缓冲区,所以当多个触发器触发时,它可以存储稍后可以读出的数据。我只是想知道两件事:用于数据缓冲区的VHDL中的3D数组

1)这是如何设置3D数组?有没有海量的信息

2)有没有更好的方式为我的数据做缓冲区?

数据的格式为:数据[buff_num] [word_num] [二进制]

每个字为32位,通常有14个字,我想我所做的缓冲器深8位。

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use ieee.numeric_std.all; 

entity ipbus_dpram is 
    generic(
    ADDR_WIDTH: natural 
    ); 
    port(
    clk: in std_logic; 
    rst: in std_logic; 
    rclk: in std_logic; 
    we: in std_logic := '0'; 
    d: in std_logic_vector(31 downto 0); 
    rdata: out std_logic_vector(ADDR_WIDTH - 1 downto 0); 
    addr: in std_logic_vector(ADDR_WIDTH - 1 downto 0); 
    w_addr: out std_logic(ADDR_WIDTH - 1 downto 0); 
    w_buf_shift: in std_logic; 
    en_write: in std_logic; 

    ); 

end ipbus_dpram; 

architecture rtl of ipbus_dpram is 

    type ram_array is array(7 downto 0, 13 downto 0) of std_logic_vector(31 downto 0);  
    shared variable ram: ram_array; 
    signal w_shel, r_shel : integer; 
    signal sel, wsel: integer; 
    signal ack: std_logic; 

    signal w_shift: unsigned(7 downto 0); 
    signal r_shift: unsigned(7 downto 0); 

begin 

    sel <= to_integer(unsigned(r_addr(addr_width-1 downto 0))); 

    process(clk) 
    begin 
    if rising_edge(clk) then 
     rdata <= ram(r_shel, sel); 

     if (en_write='1') then 
     r_shel <= to_integer(unsigned(r_shift)); 
     r_shift <= r_shift +1; 
     end if; 
    end if; 
    end process; 

    wsel <= to_integer(unsigned(addr)); 

    process(rclk) 
    begin 
    if rising_edge(rclk) then 

     if we = '1' then 
     ram(w_shel, wsel) := d; 
     end if; 
     if w_buf_shift = '1' then 
     w_shel <= to_integer(unsigned(w_shift)); 
     w_shift <= w_shift + 1; 
     end if; 
    end if; 
    end process; 

end rtl; 

回答

1

哇......这是一个很大数量的寄存器,你试图合成! 3D向量是2^8 = 256宽×2^14 = 16384长×32深= 134,217,728个寄存器!你需要更大的船。其实你会需要一艘还不存在的船。也许有一天他们会建立一个足够大的FPGA来处理你的需求,但是那天不是今天。

您需要更智能地存储您的数据。您需要使用DRAM或SRAM等片外存储器,或者需要使用FIFO临时缓冲数据。

+0

你能解释一下我在这种情况下如何使用FIFO吗? – fiz

+0

另外 - 我想我已经正确地初始化阵列? – fiz

+0

FIFO =先进先出。查看如何使用您拥有的FPGA架构创建FIFO,因为晶格和xilinx与actel都略有不同。您需要有一个负责写入FIFO的流程,另一个负责从FIFO读取数据。我通常把每个文件放在两个单独的文件中,以保持清洁。关于FIFO的一些注意事项: 1.您绝不能写入完整的FIFO 2.您绝不能从空FIFO读取 祝您好运! – Russell